xmake.lua 1.7 KB

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