xmake.lua 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package("mongo-cxx-driver")
  2. set_homepage("https://github.com/mongodb/mongo-cxx-driver")
  3. set_description("mongodb c++ driver")
  4. set_license("Apache-2.0")
  5. add_urls("https://github.com/mongodb/mongo-cxx-driver/archive/r$(version).zip")
  6. add_versions("3.6.6", "4413de483c5070b48dc5b5c8ee3e32c8e7a2b74b892fe2a55ef78fb758bc01e0")
  7. add_deps("cmake")
  8. add_deps("mongo-c-driver")
  9. if is_plat("windows") then
  10. add_deps("boost")
  11. end
  12. add_configs("shared", {description = "Build shared library.", default = true, type = "boolean", readonly = true})
  13. add_includedirs("include/bsoncxx/v_noabi")
  14. add_includedirs("include/mongocxx/v_noabi")
  15. on_install("windows", "macosx", "linux", function (package)
  16. local configs = {
  17. "-DBUILD_SHARED_AND_STATIC_LIBS=OFF",
  18. "-DBUILD_SHARED_LIBS=ON",
  19. "-DENABLE_TESTS=OFF"}
  20. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  21. if package:version() then
  22. table.insert(configs, "-DBUILD_VERSION=" .. package:version())
  23. end
  24. io.replace("CMakeLists.txt", "add_subdirectory(examples EXCLUDE_FROM_ALL)", "", {plain = true})
  25. io.replace("CMakeLists.txt", "add_subdirectory(benchmark EXCLUDE_FROM_ALL)", "", {plain = true})
  26. io.replace("CMakeLists.txt", "add_subdirectory (docs)", "", {plain = true})
  27. import("package.tools.cmake").install(package, configs, {cmake_build = true, config = (package:debug() and "Debug" or "Release")})
  28. end)
  29. on_test(function (package)
  30. assert(package:has_cxxfuncs("mongocxx::instance{nullptr}",
  31. {configs = {languages = "c++14"}, includes = "mongocxx/instance.hpp"}))
  32. end)