xmake.lua 1.5 KB

1234567891011121314151617181920212223242526272829303132
  1. package("pthreadpool")
  2. set_homepage("https://github.com/Maratyszcza/pthreadpool")
  3. set_description("Portable (POSIX/Windows/Emscripten) thread pool for C/C++")
  4. set_license("BSD-2-Clause")
  5. add_urls("https://github.com/Maratyszcza/pthreadpool.git")
  6. add_versions("2021.05.08", "1787867f6183f056420e532eec640cba25efafea")
  7. if is_plat("windows") then
  8. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  9. end
  10. add_deps("cmake", "fxdiv")
  11. if is_plat("linux") then
  12. add_syslinks("pthread")
  13. end
  14. on_install("windows", "macosx", "linux", function (package)
  15. io.gsub("CMakeLists.txt", "IF%(NOT TARGET fxdiv%).-ENDIF%(%)", "add_library(fxdiv INTERFACE)\ntarget_include_directories(fxdiv INTERFACE \"${FXDIV_SOURCE_DIR}/include\")")
  16. local configs = {"-DPTHREADPOOL_BUILD_TESTS=OFF", "-DPTHREADPOOL_BUILD_BENCHMARKS=OFF"}
  17. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  18. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  19. local fxdiv = package:dep("fxdiv")
  20. if fxdiv and not fxdiv:is_system() then
  21. table.insert(configs, "-DFXDIV_SOURCE_DIR=" .. fxdiv:installdir())
  22. end
  23. import("package.tools.cmake").install(package, configs)
  24. end)
  25. on_test(function (package)
  26. assert(package:has_cfuncs("pthreadpool_create", {includes = "pthreadpool.h"}))
  27. end)