xmake.lua 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. package("libccd")
  2. set_homepage("https://github.com/danfis/libccd/")
  3. set_description("libccd is library for a collision detection between two convex shapes.")
  4. set_license("BSD-3-Clause")
  5. add_urls("https://github.com/danfis/libccd/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/danfis/libccd.git")
  7. add_versions("v2.1", "542b6c47f522d581fbf39e51df32c7d1256ac0c626e7c2b41f1040d4b9d50d1e")
  8. add_configs("double_precision", {description = "Enable double precision floating-point arithmetic.", default = false, type = "boolean"})
  9. on_load("windows", "macosx", "linux", "mingw", "cross", function (package)
  10. if not package.is_built or package:is_built() then
  11. package:add("deps", "cmake")
  12. end
  13. end)
  14. on_install("windows", "macosx", "linux", "mingw", "cross", function (package)
  15. io.replace("src/ccd/ccd_export.h", "def CCD_STATIC_DEFINE", package:config("shared") and " 0" or " 1", {plain = true})
  16. local configs = {}
  17. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  18. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  19. table.insert(configs, "-DCCD_HIDE_ALL_SYMBOLS=" .. (package:config("shared") and "OFF" or "ON"))
  20. table.insert(configs, "-DENABLE_DOUBLE_PRECISION=" .. (package:config("double_precision") and "ON" or "OFF"))
  21. io.replace("src/CMakeLists.txt", " find_library(LIBM_LIBRARY NAMES m)", "", {plain = true})
  22. io.replace("src/CMakeLists.txt", " if(NOT LIBM_LIBRARY)", "if(OFF)", {plain = true})
  23. io.replace("src/CMakeLists.txt", " target_link_libraries(ccd \"${LIBM_LIBRARY}\")", " target_link_libraries(ccd -lm)", {plain = true})
  24. import("package.tools.cmake").install(package, configs)
  25. end)
  26. on_test(function (package)
  27. assert(package:has_cfuncs("ccdFirstDirDefault", {includes = "ccd/ccd.h"}))
  28. end)