xmake.lua 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. package("ignite3")
  2. set_homepage("https://ignite.apache.org")
  3. set_description("Apache Ignite 3 C++ client library")
  4. set_license("Apache-2.0")
  5. add_urls("https://archive.apache.org/dist/ignite/$(version)/apache-ignite-$(version)-cpp.zip",
  6. "https://mirror.fi.ossplanet.net/apache-dist/ignite/$(version)/apache-ignite-$(version)-cpp.zip")
  7. add_versions("3.0.0", "4ef0b6b103fb1d652c486e5783105ca9c81b3ad677248b922d56064e7429ce2f")
  8. add_configs("client", {description = "Build Ignite C++ client", default = false, type = "boolean"})
  9. add_configs("odbc", {description = "Build ODBC driver", default = false, type = "boolean"})
  10. add_deps("cmake")
  11. add_deps("msgpack-c", "mbedtls")
  12. on_load(function (package)
  13. if package:config("client") or package:config("odbc") then
  14. package:add("deps", "openssl")
  15. if package:is_plat("windows", "mingw") then
  16. package:add("syslinks", "wsock32", "ws2_32", "iphlpapi", "crypt32")
  17. elseif package:is_plat("linux", "bsd") then
  18. package:add("syslinks", "dl")
  19. end
  20. end
  21. end)
  22. on_check(function (package)
  23. assert(not (package:is_subhost("msys")),"This package cannot build on Msys")
  24. assert(not (package:is_plat("linux") and package:is_arch("arm64")),"This package cannot build on Linux Arm64")
  25. end)
  26. on_install("windows", "macosx", "linux", "mingw", function (package)
  27. io.replace("CMakeLists.txt", "if (CLANG_FORMAT_BIN)", "if(0)", {plain = true})
  28. -- remove pic hardcode
  29. io.replace("ignite/network/CMakeLists.txt", "set_target_properties(${TARGET} PROPERTIES POSITION_INDEPENDENT_CODE 1)", "", {plain = true})
  30. io.replace("cmake/dependencies.cmake", "set(CMAKE_POSITION_INDEPENDENT_CODE ON)", "", {plain = true})
  31. -- fix find package
  32. io.replace("cmake/dependencies.cmake", "find_package(msgpack REQUIRED)", "find_package(msgpack-c CONFIG REQUIRED)", {plain = true})
  33. io.replace("cmake/dependencies.cmake", [[message( FATAL_ERROR "With USE_LOCAL_DEPS specified you have to set MBEDTLS_SOURCE_DIR to path to the MbedTLS source code")]], "find_package(MbedTLS CONFIG REQUIRED)\nreturn()", {plain = true})
  34. -- fix install headers
  35. io.replace("ignite/common/CMakeLists.txt", "uuid.h", "uuid.h\n detail/mpi.h", {plain = true})
  36. io.replace("ignite/common/detail/bytes.h", "detail/config.h", "config.h", {plain = true})
  37. -- Install ignite-common target
  38. io.replace("ignite/common/CMakeLists.txt", [[ignite_install_headers(FILES ${PUBLIC_HEADERS} DESTINATION ${IGNITE_INCLUDEDIR}/common)]], [[ignite_install_headers(FILES ${PUBLIC_HEADERS} DESTINATION ${IGNITE_INCLUDEDIR}/common)
  39. install(TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")]], {plain = true})
  40. -- Enforce search for MBEDTLS
  41. io.replace("ignite/common/CMakeLists.txt", [[target_link_libraries(${TARGET} PUBLIC MbedTLS::mbedtls)]], [[
  42. find_package(MbedTLS CONFIG REQUIRED)
  43. target_link_libraries(${TARGET} PUBLIC MbedTLS::mbedtls)]], {plain = true})
  44. local configs = {
  45. "-DENABLE_TESTS=OFF",
  46. "-DCMAKE_INSTALL_INCLUDEDIR=" .. path.unix(package:installdir("include")),
  47. "-DWARNINGS_AS_ERRORS=OFF",
  48. "-DUSE_LOCAL_DEPS=ON",
  49. }
  50. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  51. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  52. table.insert(configs, "-DENABLE_ADDRESS_SANITIZER=" .. (package:config("asan") and "ON" or "OFF"))
  53. table.insert(configs,"-DENABLE_CLIENT=" .. (package:config("client") and "ON" or "OFF"))
  54. table.insert(configs,"-DENABLE_ODBC=" .. (package:config("odbc") and "ON" or "OFF"))
  55. local opt = {}
  56. opt.cxflags = "-DMBEDTLS_ALLOW_PRIVATE_ACCESS"
  57. import("package.tools.cmake").install(package, configs, opt)
  58. if package:is_plat("windows") and not package:config("shared") then
  59. io.replace(package:installdir("include/ignite/common/detail/config.h"), "# define IGNITE_API IGNITE_IMPORT", "# define IGNITE_API", {plain = true})
  60. end
  61. end)
  62. on_test(function (package)
  63. assert(package:check_cxxsnippets({test = [[
  64. #include <ignite/tuple/binary_tuple_builder.h>
  65. void test() {
  66. ignite::binary_tuple_builder builder{0};
  67. builder.start();
  68. }
  69. ]]}, {configs = {languages = "c++17"}}))
  70. if package:config("client") then
  71. assert(package:check_cxxsnippets({test = [[
  72. #include <ignite/client/ignite_client.h>
  73. void test() {
  74. ignite::IgniteClientConfiguration cfg;
  75. ignite::IgniteClient::Start(cfg, std::chrono::seconds(1),
  76. [](ignite::IgniteClient&){});
  77. }
  78. ]]}, {configs = {languages = "c++17"}}))
  79. end
  80. end)