2
0

xmake.lua 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. package("geant4")
  2. set_homepage("https://geant4.web.cern.ch/")
  3. set_description("Geant4 is a toolkit for the simulation of the passage of particles through matter.")
  4. add_urls("https://geant4-data.web.cern.ch/releases/geant4$(version).zip", {version = function (version)
  5. if version:ge("11.0") then
  6. return "-v" .. version
  7. else
  8. return format("_%02d_%02d_p%02d", version:major(), version:minor(), version:patch())
  9. end
  10. end})
  11. add_versions("10.7.2", "c07b358c30b5930afcc32b44e899cf901083539f350f4333d65784c2aaa4af38")
  12. add_versions("11.1.0", "8d7df33a4b692493f01a05b82047134a8291d00f113b6a23bdb5253a6527f5a1")
  13. add_deps("cmake")
  14. add_deps("zlib", "expat", "clhep")
  15. add_includedirs("include/Geant4")
  16. if is_plat("windows") then
  17. add_defines("WIN32")
  18. end
  19. on_install("windows", "macosx", "linux", function (package)
  20. if package:is_plat("windows") then
  21. local vs = import("core.tool.toolchain").load("msvc"):config("vs")
  22. if tonumber(vs) < 2019 then
  23. raise("Your compiler is too old to use this library.")
  24. end
  25. end
  26. local configs = {"-DCMAKE_INSTALL_LIBDIR=lib",
  27. "-DGEANT4_ENABLE_TESTING=OFF",
  28. "-DGEANT4_INSTALL_EXAMPLES=OFF",
  29. "-DGEANT4_USE_SYSTEM_CLHEP=ON",
  30. "-DGEANT4_USE_SYSTEM_EXPAT=ON",
  31. "-DGEANT4_USE_SYSTEM_ZLIB=ON",
  32. "-DGEANT4_USE_SYSTEM_PTL=OFF",
  33. "-DGEANT4_USE_TBB=OFF",
  34. "-DGEANT4_USE_GDML=OFF",
  35. "-DGEANT4_USE_TIMEMORY=OFF",
  36. "-DGEANT4_USE_USOLIDS=OFF",
  37. "-DGEANT4_USE_FREETYPE=OFF",
  38. "-DGEANT4_USE_HDF5=OFF"}
  39. io.replace("cmake/Modules/G4OptionalComponents.cmake", "if(WIN32)", "if(FALSE)", {plain = true})
  40. io.replace("cmake/Modules/G4OptionalComponents.cmake", "EXPAT REQUIRED", "EXPAT CONFIG REQUIRED", {plain = true})
  41. io.replace("cmake/Modules/G4OptionalComponents.cmake", "EXPAT::EXPAT", "expat::expat", {plain = true})
  42. io.replace("cmake/Modules/G4OptionalComponents.cmake", "${EXPAT_VERSION_STRING} VERSION_LESS \"2.0.1\"", "FALSE", {plain = true})
  43. if package:is_plat("windows") then
  44. io.replace("cmake/Modules/G4MakeRules_cxx.cmake", "-MD", "-" .. package:config("vs_runtime"), {plain = true})
  45. end
  46. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  47. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  48. table.insert(configs, "-DBUILD_STATIC_LIBS=" .. (package:config("shared") and "OFF" or "ON"))
  49. import("package.tools.cmake").install(package, configs)
  50. package:addenv("PATH", "bin")
  51. local suffix = ""
  52. if package:is_plat("windows") and not package:config("shared") then
  53. suffix = "-static"
  54. end
  55. local expected_links = {"G4physicslists", "G4parmodels", "G4persistency", "G4GMocren", "G4error_propagation", "G4visXXX", "G4VRML", "G4RayTracer", "G4Tree", "G4visHepRep", "G4FR", "G4vis_management", "G4modeling", "G4tasking", "G4readout", "G4run", "G4tracking", "G4event", "G4processes", "G4digits_hits", "G4track", "G4particles", "G4geometry", "G4graphics_reps", "G4materials", "G4analysis", "G4interfaces", "G4intercoms", "G4global", "G4ptl"}
  56. for _, libname in ipairs(expected_links) do
  57. package:add("links", libname .. suffix)
  58. end
  59. end)
  60. on_test(function (package)
  61. assert(package:check_cxxsnippets({test = [[
  62. #include <G4NistManager.hh>
  63. void test() {
  64. using CLHEP::cm;
  65. G4NistManager* nist = G4NistManager::Instance();
  66. G4double env_sizeXY = 20*cm, env_sizeZ = 30*cm;
  67. G4Material* env_mat = nist->FindOrBuildMaterial("G4_WATER");
  68. }
  69. ]]}, {configs = {languages = "c++17"}}))
  70. end)