xmake.lua 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package("marl")
  2. set_homepage("https://github.com/google/marl")
  3. set_description("A hybrid thread / fiber task scheduler written in C++ 11")
  4. set_license("Apache-2.0")
  5. add_urls("https://github.com/google/marl.git", {submodules = false})
  6. add_versions("2025.02.23", "23bbc9bf0017ba75844d5be5b12b15c0134ca276")
  7. add_deps("cmake")
  8. if is_plat("linux", "bsd") then
  9. add_syslinks("pthread")
  10. end
  11. on_install("!mingw or mingw|!i386", function (package)
  12. if package:is_plat("windows") and package:config("shared") then
  13. package:add("defines", "MARL_DLL=1")
  14. end
  15. io.replace("CMakeLists.txt", "POSITION_INDEPENDENT_CODE 1", "", {plain = true})
  16. -- https://github.com/google/marl/pull/234
  17. io.replace("src/scheduler.cpp", "#if defined(_WIN32)", "#if defined(_MSC_VER)", {plain = true})
  18. local configs = {"-DMARL_INSTALL=ON"}
  19. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  20. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  21. table.insert(configs, "-DMARL_BUILD_SHARED=" .. (package:config("shared") and "ON" or "OFF"))
  22. table.insert(configs, "-DMARL_ASAN=" .. (package:config("asan") and "ON" or "OFF"))
  23. import("package.tools.cmake").install(package, configs)
  24. end)
  25. on_test(function (package)
  26. assert(package:check_cxxsnippets({test = [[
  27. #include <marl/scheduler.h>
  28. void test() {
  29. marl::Scheduler scheduler(marl::Scheduler::Config::allCores());
  30. }
  31. ]]}, {configs = {languages = "c++11"}}))
  32. end)