xmake.lua 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package("cpp-ipc")
  2. set_homepage("https://github.com/mutouyun/cpp-ipc")
  3. set_description("A high-performance inter-process communication using shared memory on Linux/Windows")
  4. set_license("MIT")
  5. set_urls("https://github.com/mutouyun/cpp-ipc/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/mutouyun/cpp-ipc.git")
  7. add_versions("v1.4.1", "055bd95a066936e0d6f30eab9fe3b4414aa3ce97d8ac03fbd5c9009591ad170b")
  8. add_versions("v1.3.0", "a5ffb67ff451aa28726ab7801509c5c67feb737db49d2be4f7c70a4e9fad2fee")
  9. add_versions("v1.2.0", "c8df492e08b55e0722eb3e5684163709c1758f3282f05358ff78c694eadb6e60")
  10. add_deps("cmake")
  11. if is_plat("windows") then
  12. add_syslinks("advapi32")
  13. elseif is_plat("linux", "bsd") then
  14. add_syslinks("pthread")
  15. end
  16. on_install("windows", "linux", "mingw", "msys", "cross", function (package)
  17. if package:config("shared") then
  18. package:add("defines", "LIBIPC_LIBRARY_SHARED_USING__")
  19. end
  20. io.replace("src/CMakeLists.txt", "if(NOT MSVC)", "if(NOT WIN32)", {plain = true})
  21. local configs = {"-DLIBIPC_BUILD_TESTS=OFF", "-DLIBIPC_BUILD_DEMOS=OFF", "-DLIBIPC_USE_STATIC_CRT=OFF"}
  22. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  23. table.insert(configs, "-DLIBIPC_BUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  24. local opt = {}
  25. if package:has_tool("cxx", "clang_cl") then
  26. opt.cxflags = "/EHsc"
  27. end
  28. import("package.tools.cmake").install(package, configs, opt)
  29. end)
  30. on_test(function (package)
  31. assert(package:check_cxxsnippets({test = [[
  32. #include "libipc/ipc.h"
  33. void test() { ipc::route cc { "my-ipc-route" }; }
  34. ]]}, {configs = {languages = "c++17"}}))
  35. end)