xmake.lua 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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.3.0", "a5ffb67ff451aa28726ab7801509c5c67feb737db49d2be4f7c70a4e9fad2fee")
  8. add_versions("v1.2.0", "c8df492e08b55e0722eb3e5684163709c1758f3282f05358ff78c694eadb6e60")
  9. add_deps("cmake")
  10. if is_plat("windows") then
  11. add_syslinks("advapi32")
  12. elseif is_plat("linux", "bsd") then
  13. add_syslinks("pthread")
  14. end
  15. on_install("windows", "linux", "mingw", "msys", "cross", function (package)
  16. if package:config("shared") then
  17. package:add("defines", "LIBIPC_LIBRARY_SHARED_USING__")
  18. end
  19. io.replace("src/CMakeLists.txt", "if(NOT MSVC)", "if(NOT WIN32)", {plain = true})
  20. local configs = {"-DLIBIPC_BUILD_TESTS=OFF", "-DLIBIPC_BUILD_DEMOS=OFF", "-DLIBIPC_USE_STATIC_CRT=OFF"}
  21. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  22. table.insert(configs, "-DLIBIPC_BUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  23. local opt = {}
  24. if package:has_tool("cxx", "clang_cl") then
  25. opt.cxflags = "/EHsc"
  26. end
  27. import("package.tools.cmake").install(package, configs, opt)
  28. end)
  29. on_test(function (package)
  30. assert(package:check_cxxsnippets({test = [[
  31. #include "libipc/ipc.h"
  32. void test() { ipc::route cc { "my-ipc-route" }; }
  33. ]]}, {configs = {languages = "c++17"}}))
  34. end)