xmake.lua 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package("ptl")
  2. set_homepage("https://github.com/jrmadsen/PTL")
  3. set_description("Lightweight C++11 multithreading tasking system featuring thread-pool, task-groups, and lock-free task queue")
  4. set_license("MIT")
  5. add_urls("https://github.com/jrmadsen/PTL/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/jrmadsen/PTL.git")
  7. add_versions("v2.0.0", "58e561a3a1de75679faf4d8760d2ff045ced232d4367157b5b4e4f26c8474721")
  8. add_configs("tbb", {description = "Enable TBB support.", default = false, type = "boolean"})
  9. add_deps("cmake")
  10. if is_plat("linux") then
  11. add_syslinks("pthread")
  12. end
  13. on_load("windows", "macosx", "linux", function (package)
  14. if package:config("tbb") then
  15. package:add("deps", "tbb")
  16. end
  17. end)
  18. on_install("windows", "macosx", "linux", function (package)
  19. io.replace("cmake/Templates/PTLConfig.cmake.in", "if(WIN32)", "if(FALSE)", {plain = true})
  20. local configs = {}
  21. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  22. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  23. table.insert(configs, "-DBUILD_STATIC_LIBS=" .. (package:config("shared") and "OFF" or "ON"))
  24. table.insert(configs, "-DPTL_USE_TBB=" .. (package:config("tbb") 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 <PTL/ThreadPool.hh>
  30. #include <PTL/TaskGroup.hh>
  31. void test() {
  32. PTL::ThreadPool tp(4);
  33. auto join = [](long& lhs, long rhs) { return lhs += rhs; };
  34. PTL::TaskGroup<long> foo(join, &tp);
  35. }
  36. ]]}, {configs = {languages = "c++11"}}))
  37. end)