xmake.lua 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package("partio")
  2. set_homepage("http://partio.us/")
  3. set_description("Partio is an open source C++ library for reading, writing and manipulating a variety of standard particle formats (GEO, BGEO, PTC, PDB, PDA).")
  4. set_license("BSD-3-Clause")
  5. add_urls("https://github.com/wdas/partio/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/wdas/partio.git")
  7. add_versions("v1.14.0", "f98874b781e92ab9b5d0575cabc437d27274cd91cb581f80960918efa491f902")
  8. add_versions("v1.14.6", "53a5754d6b2fc3e184953d985c233118ef0ab87169f34e3aec4a7e6d20cd9bd4")
  9. if is_plat("windows") then
  10. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  11. end
  12. add_configs("python", {description = "Enable python support.", default = false, type = "boolean"})
  13. add_configs("tools", {description = "Build utility tools.", default = false, type = "boolean"})
  14. add_deps("cmake", "zlib")
  15. on_load("windows", "macosx", "linux", function (package)
  16. if package:config("python") then
  17. package:add("deps", "swig", "python 3.x")
  18. end
  19. if package:config("tools") then
  20. package:add("deps", "freeglut", "opengl")
  21. end
  22. end)
  23. on_install("windows", "macosx", "linux", function (package)
  24. io.gsub("CMakeLists.txt", "add%_subdirectory%(src/tests%)", "")
  25. io.gsub("CMakeLists.txt", "find%_package%(GLUT REQUIRED%)", "find_package(GLUT)")
  26. io.gsub("CMakeLists.txt", "find%_package%(OpenGL REQUIRED%)", "find_package(OpenGL)")
  27. io.gsub("CMakeLists.txt", "find%_package%(Python(.-) REQUIRED%)", "find_package(Python%1)")
  28. local configs = {"-DCMAKE_DISABLE_FIND_PACKAGE_Doxygen=ON"}
  29. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  30. table.insert(configs, "-DPARTIO_BUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  31. table.insert(configs, "-DCMAKE_DISABLE_FIND_PACKAGE_SWIG=" .. (package:config("python") and "OFF" or "ON"))
  32. table.insert(configs, "-DCMAKE_DISABLE_FIND_PACKAGE_GLUT=" .. (package:config("tools") and "OFF" or "ON"))
  33. import("package.tools.cmake").install(package, configs)
  34. if package:config("python") then
  35. local pyver = package:dep("python"):version()
  36. package:addenv("PYTHONPATH", path.join(package:installdir("lib"), format("python%d.%d", pyver:major(), pyver:minor()), "site-packages"))
  37. end
  38. if package:config("tools") then
  39. package:addenv("PATH", "bin")
  40. end
  41. end)
  42. on_test(function (package)
  43. assert(package:check_cxxsnippets({test = [[
  44. void test() {
  45. Partio::ParticlesDataMutable* particles=Partio::createInterleave();
  46. particles->addParticles(10);
  47. }
  48. ]]}, {configs = {languages = "c++14"}, includes = "Partio.h"}))
  49. if package:config("python") then
  50. local python_exe = package:is_plat("windows") and "python" or "python3"
  51. os.vrunv(python_exe, {"-c", "import partio"})
  52. end
  53. end)