xmake.lua 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package("concurrencpp")
  2. set_homepage("https://github.com/David-Haim/concurrencpp")
  3. set_description("Modern concurrency for C++. Tasks, executors, timers and C++20 coroutines to rule them all")
  4. set_license("MIT")
  5. add_urls("https://github.com/David-Haim/concurrencpp/archive/refs/tags/$(version).tar.gz", {version = function (version)
  6. return "v." .. version
  7. end})
  8. add_urls("https://github.com/David-Haim/concurrencpp.git")
  9. add_versions("0.1.5", "330150ebe11b3d30ffcb3efdecc184a34cf50a6bd43b68e294a496225d286651")
  10. add_versions("0.1.6", "e7d5c23a73ff1d7199d361d3402ad2a710dfccf7630b622346df94a7532b4221")
  11. add_versions("0.1.7", "049f3e83ad1828e0b8b518652de1a3160d5849fdff03d521d0a5af0167338e89")
  12. -- https://github.com/David-Haim/concurrencpp/issues/166
  13. add_patches("0.1.7", "patches/0.1.7/add-include-string.patch", "a4b8c219fcc913a3cbeda1522c408f4b347e12f11ec130dd7df65504dcdccc09")
  14. if is_plat("windows") then
  15. add_syslinks("synchronization", "ws2_32", "mswsock")
  16. elseif is_plat("linux", "bsd") then
  17. add_syslinks("pthread")
  18. end
  19. add_deps("cmake")
  20. on_check(function (package)
  21. assert(package:check_cxxsnippets({test = [[
  22. #include <semaphore>
  23. #include <new>
  24. void test() {
  25. auto x = std::hardware_destructive_interference_size;
  26. }
  27. ]]}, {configs = {languages = "c++20"}}), "package(concurrencpp) Require at least C++20.")
  28. end)
  29. on_load(function (package)
  30. package:add("includedirs", "include/concurrencpp-" .. package:version_str())
  31. if package:is_plat("windows") and package:config("shared") then
  32. package:add("defines", "CRCPP_IMPORT_API")
  33. end
  34. end)
  35. on_install(function (package)
  36. local configs = {}
  37. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  38. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  39. import("package.tools.cmake").install(package, configs)
  40. end)
  41. on_test(function (package)
  42. assert(package:check_cxxsnippets({test = [[
  43. #include "concurrencpp/concurrencpp.h"
  44. #include <iostream>
  45. void test() {
  46. concurrencpp::runtime runtime;
  47. auto result = runtime.thread_executor()->submit([] {
  48. std::cout << "hello world" << std::endl;
  49. });
  50. result.get();
  51. }
  52. ]]}, {configs = {languages = "c++20"}}))
  53. end)