xmake.lua 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package("libunifex")
  2. set_homepage("https://github.com/facebookexperimental/libunifex")
  3. set_description("The 'libunifex' project is a prototype implementation of the C++ sender/receiver async programming model that is currently being considered for standardisation.")
  4. set_license("Apache-2.0")
  5. add_urls("https://github.com/facebookexperimental/libunifex/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/facebookexperimental/libunifex.git")
  7. add_versions("v0.4.0", "d5ce3b616e166da31e6b4284764a1feeba52aade868bcbffa94cfd86b402716e")
  8. add_patches("v0.4.0", "patches/v0.4.0/std-memset.patch", "8108bf13b8071cff16e6d96bf97399ed3e657f59d6a843a078e42e4b3318def4")
  9. if is_plat("linux", "bsd") then
  10. add_syslinks("pthread")
  11. end
  12. add_deps("cmake")
  13. if on_check then
  14. on_check(function (package)
  15. if package:is_plat("windows") then
  16. local vs_toolset = package:toolchain("msvc"):config("vs_toolset")
  17. if vs_toolset then
  18. local vs_toolset_ver = import("core.base.semver").new(vs_toolset)
  19. local minor = vs_toolset_ver:minor()
  20. assert(minor and minor >= 30, "package(libunifex) require vs_toolset >= 14.3")
  21. end
  22. end
  23. assert(package:has_cxxincludes("coroutine", {configs = {languages = "c++20"}}), "package(libunifex) require C++20 with coroutine support")
  24. end)
  25. end
  26. on_install(function (package)
  27. local configs = {"-DBUILD_TESTING=OFF", "-DUNIFEX_BUILD_EXAMPLES=OFF", "-DCMAKE_CXX_STANDARD=20"}
  28. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  29. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  30. if package:is_plat("windows") then
  31. table.insert(configs, "-DCMAKE_COMPILE_PDB_OUTPUT_DIRECTORY=''")
  32. if package:config("shared") then
  33. table.insert(configs, "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON")
  34. end
  35. end
  36. import("package.tools.cmake").install(package, configs)
  37. if package:is_plat("windows") and package:is_debug() then
  38. local dir = package:installdir(package:config("shared") and "bin" or "lib")
  39. os.vcp(path.join(package:buildir(), "source/**.pdb"), dir)
  40. end
  41. end)
  42. on_test(function (package)
  43. assert(package:check_cxxsnippets({test = [[
  44. using namespace unifex;
  45. using namespace std::chrono;
  46. auto delay(milliseconds ms) {
  47. return schedule_after(current_scheduler, ms);
  48. }
  49. ]]}, {configs = {languages = "c++20"}, includes = {"chrono", "unifex/on.hpp", "unifex/scheduler_concepts.hpp"}}))
  50. end)