xmake.lua 1.8 KB

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