xmake.lua 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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_deps("cmake")
  12. if is_plat("windows") then
  13. add_syslinks("synchronization", "ws2_32", "mswsock")
  14. elseif is_plat("linux", "bsd") then
  15. add_syslinks("pthread")
  16. end
  17. on_load(function (package)
  18. package:add("includedirs", "include/concurrencpp-" .. package:version_str())
  19. end)
  20. on_install("macosx", "windows", function (package)
  21. assert(package:has_tool("cxx", "clang", "cl"), "compiler not supported!")
  22. local configs = {}
  23. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  24. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  25. import("package.tools.cmake").install(package, configs)
  26. end)
  27. on_test(function (package)
  28. assert(package:check_cxxsnippets({test = [[
  29. #include "concurrencpp/concurrencpp.h"
  30. #include <iostream>
  31. void test() {
  32. concurrencpp::runtime runtime;
  33. auto result = runtime.thread_executor()->submit([] {
  34. std::cout << "hello world" << std::endl;
  35. });
  36. result.get();
  37. }
  38. ]]}, {configs = {languages = "c++20"}}))
  39. end)