From 0d58c32b254bb5de753f8709ed1135475a9b5a0f Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Fri, 22 Sep 2023 16:45:53 -0500 Subject: [PATCH 01/11] Use CMAKE_BUILD_PARALLEL_LEVEL in compile.sh --- .evergreen/compile.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.evergreen/compile.sh b/.evergreen/compile.sh index fb3572d6a1..5c212b5739 100755 --- a/.evergreen/compile.sh +++ b/.evergreen/compile.sh @@ -19,18 +19,18 @@ fi OS=$(uname -s | tr '[:upper:]' '[:lower:]') if [ -f /proc/cpuinfo ]; then - CONCURRENCY=$(grep -c ^processor /proc/cpuinfo) + CMAKE_BUILD_PARALLEL_LEVEL=$(grep -c ^processor /proc/cpuinfo) elif which sysctl; then - CONCURRENCY=$(sysctl -n hw.logicalcpu) + CMAKE_BUILD_PARALLEL_LEVEL=$(sysctl -n hw.logicalcpu) else - echo "$0: can't figure out what value of -j to pass to 'make'" >&2 + echo "$0: can't figure out what build parallel level to use" >&2 exit 1 fi +export CMAKE_BUILD_PARALLEL_LEVEL case "$OS" in darwin|linux) GENERATOR=${GENERATOR:-"Unix Makefiles"} - CMAKE_BUILD_OPTS="-j $CONCURRENCY" CMAKE_EXAMPLES_TARGET=examples if [ "$RUN_DISTCHECK" ]; then _RUN_DISTCHECK=$RUN_DISTCHECK @@ -39,7 +39,7 @@ case "$OS" in cygwin*) GENERATOR=${GENERATOR:-"Visual Studio 14 2015 Win64"} - CMAKE_BUILD_OPTS="/verbosity:minimal /maxcpucount:$CONCURRENCY" + CMAKE_BUILD_OPTS="/verbosity:minimal" CMAKE_EXAMPLES_TARGET=examples/examples ;; From 36047e9e0a7f0cf668369b92ec09e98f067fc2e1 Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Fri, 22 Sep 2023 12:22:08 -0500 Subject: [PATCH 02/11] Group minimum C Driver library version variables --- CMakeLists.txt | 3 +++ src/bsoncxx/CMakeLists.txt | 11 ++++------- src/mongocxx/CMakeLists.txt | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f3ecddc46a..dd15da2592 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,6 +44,9 @@ else() message(WARNING "Unknown compiler... recklessly proceeding without a version check") endif() +set(LIBBSON_REQUIRED_VERSION 1.24.0) +set(LIBBSON_REQUIRED_ABI_VERSION 1.0) + set(LIBMONGOC_REQUIRED_VERSION 1.24.0) set(LIBMONGOC_DOWNLOAD_VERSION ba5ab6de26a874d33b0abc3d2b46961a69380e7a) # TODO: update to 1.25.0 once C driver 1.25.0 is released. set(LIBMONGOC_REQUIRED_ABI_VERSION 1.0) diff --git a/src/bsoncxx/CMakeLists.txt b/src/bsoncxx/CMakeLists.txt index 1e39d51960..ec9755a04c 100644 --- a/src/bsoncxx/CMakeLists.txt +++ b/src/bsoncxx/CMakeLists.txt @@ -16,6 +16,10 @@ project(BSONCXX) ParseVersion (${BUILD_VERSION} BSONCXX) +set(BSONCXX_VERSION_NO_EXTRA ${BSONCXX_VERSION_MAJOR}.${BSONCXX_VERSION_MINOR}.${BSONCXX_VERSION_PATCH}) +set(BSONCXX_VERSION ${BSONCXX_VERSION_NO_EXTRA}${BSONCXX_VERSION_EXTRA}) +message ("bsoncxx version: ${BSONCXX_VERSION}") + option(BSONCXX_POLY_USE_MNMLSTC "Use MNMLSTC/core for stdx polyfills" OFF) option(BSONCXX_POLY_USE_STD_EXPERIMENTAL "Use std::experimental for stdx polyfills" OFF) option(BSONCXX_POLY_USE_SYSTEM_MNMLSTC "Obtain mnmlstc/core from system" OFF) @@ -65,10 +69,6 @@ if(BSONCXX_POLY_USE_STD_EXPERIMENTAL AND CMAKE_CXX_STANDARD LESS 14) message(FATAL_ERROR "Can only use BSONCXX_POLY_USE_STD_EXPERIMENTAL if CMAKE_CXX_STANDARD is 14 or higher") endif() -set(BSONCXX_VERSION_NO_EXTRA ${BSONCXX_VERSION_MAJOR}.${BSONCXX_VERSION_MINOR}.${BSONCXX_VERSION_PATCH}) -set(BSONCXX_VERSION ${BSONCXX_VERSION_NO_EXTRA}${BSONCXX_VERSION_EXTRA}) -message ("bsoncxx version: ${BSONCXX_VERSION}") - set(BSONCXX_POLY_MNMLSTC_DEPRECATED_INCLUDE_DIRS "") set(BSONCXX_POLY_MNMLSTC_PKGCONFIG_INCLUDE_DIRS "") set(BSONCXX_POLY_MNMLSTC_PKGCONFIG_STATIC_INCLUDE_DIRS "") @@ -87,9 +87,6 @@ if (BSONCXX_POLY_USE_MNMLSTC AND NOT BSONCXX_POLY_USE_SYSTEM_MNMLSTC) ) endif () -set(LIBBSON_REQUIRED_VERSION 1.24.0) -set(LIBBSON_REQUIRED_ABI_VERSION 1.0) - set(bsoncxx_pkg_dep "") set(bsoncxx_boost_pkg_dep "") diff --git a/src/mongocxx/CMakeLists.txt b/src/mongocxx/CMakeLists.txt index ecd52ed45d..8d1c9a5c37 100644 --- a/src/mongocxx/CMakeLists.txt +++ b/src/mongocxx/CMakeLists.txt @@ -16,15 +16,15 @@ project(MONGOCXX) ParseVersion (${BUILD_VERSION} MONGOCXX) +set(MONGOCXX_VERSION_NO_EXTRA ${MONGOCXX_VERSION_MAJOR}.${MONGOCXX_VERSION_MINOR}.${MONGOCXX_VERSION_PATCH}) +set(MONGOCXX_VERSION ${MONGOCXX_VERSION_NO_EXTRA}${MONGOCXX_VERSION_EXTRA}) +message ("mongocxx version: ${MONGOCXX_VERSION}") + option(MONGOCXX_ENABLE_SSL "Enable SSL - if the underlying C driver offers it" ON) option(MONGOCXX_ENABLE_SLOW_TESTS "Run slow tests when invoking the the test target" OFF) set(MONGOCXX_OUTPUT_BASENAME "mongocxx" CACHE STRING "Output mongocxx library base name") -set(MONGOCXX_VERSION_NO_EXTRA ${MONGOCXX_VERSION_MAJOR}.${MONGOCXX_VERSION_MINOR}.${MONGOCXX_VERSION_PATCH}) -set(MONGOCXX_VERSION ${MONGOCXX_VERSION_NO_EXTRA}${MONGOCXX_VERSION_EXTRA}) -message ("mongocxx version: ${MONGOCXX_VERSION}") - set(mongocxx_pkg_dep "") if(TARGET mongoc_shared OR TARGET mongoc_static) From 592864c96a7bd64385b89af8daf3ca01eb6dcd57 Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Fri, 22 Sep 2023 11:19:07 -0500 Subject: [PATCH 03/11] Format CMake config files --- CMakeLists.txt | 242 +++++------ cmake/BsoncxxUtil.cmake | 34 +- cmake/CMakeLists.txt | 24 +- cmake/MongocxxUtil.cmake | 36 +- cmake/ParseVersion.cmake | 59 +-- cmake/make_dist/CMakeLists.txt | 16 +- src/CMakeLists.txt | 20 +- src/bsoncxx/CMakeLists.txt | 229 ++++++----- .../v_noabi/bsoncxx/config/CMakeLists.txt | 14 +- src/bsoncxx/test/CMakeLists.txt | 10 +- src/bsoncxx/third_party/CMakeLists.txt | 136 ++++--- src/mongocxx/CMakeLists.txt | 380 +++++++++--------- .../v_noabi/mongocxx/config/CMakeLists.txt | 34 +- src/mongocxx/test/CMakeLists.txt | 232 +++++------ 14 files changed, 749 insertions(+), 717 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dd15da2592..91471106d8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,33 +15,33 @@ cmake_minimum_required(VERSION 3.15) if(POLICY CMP0025) - cmake_policy(SET CMP0025 NEW) + cmake_policy(SET CMP0025 NEW) endif() project(MONGO_CXX_DRIVER LANGUAGES CXX) if(NOT DEFINED BUILD_TESTING) - set(BUILD_TESTING OFF) # Set this to OFF by default + set(BUILD_TESTING OFF) # Set this to OFF by default endif() if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.8.2") - message(FATAL_ERROR "Insufficient GCC version - GCC 4.8.2+ required") - endif() + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.8.2") + message(FATAL_ERROR "Insufficient GCC version - GCC 4.8.2+ required") + endif() elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "19.0.23506") - message(FATAL_ERROR "Insufficient Microsoft Visual C++ version - MSVC 2015 Update 1+ required") - endif() + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "19.0.23506") + message(FATAL_ERROR "Insufficient Microsoft Visual C++ version - MSVC 2015 Update 1+ required") + endif() elseif(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") - if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.1") - message(FATAL_ERROR "Insufficient Apple clang version - XCode 5.1+ required") - endif() + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.1") + message(FATAL_ERROR "Insufficient Apple clang version - XCode 5.1+ required") + endif() elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "3.5") - message(FATAL_ERROR "Insufficient clang version - clang 3.5+ required") - endif() + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "3.5") + message(FATAL_ERROR "Insufficient clang version - clang 3.5+ required") + endif() else() - message(WARNING "Unknown compiler... recklessly proceeding without a version check") + message(WARNING "Unknown compiler... recklessly proceeding without a version check") endif() set(LIBBSON_REQUIRED_VERSION 1.24.0) @@ -52,12 +52,14 @@ set(LIBMONGOC_DOWNLOAD_VERSION ba5ab6de26a874d33b0abc3d2b46961a69380e7a) # TODO: set(LIBMONGOC_REQUIRED_ABI_VERSION 1.0) set(NEED_DOWNLOAD_C_DRIVER false) + if(TARGET mongoc_shared OR TARGET mongoc_static) - # If these targets exist, then libmongoc has already been included as a project - # sub-directory - message (STATUS "Found libmongoc targets declared in current build scope; version not checked") + # If these targets exist, then libmongoc has already been included as a project + # sub-directory + message(STATUS "Found libmongoc targets declared in current build scope; version not checked") else() find_package(mongoc-${LIBMONGOC_REQUIRED_ABI_VERSION} ${LIBMONGOC_REQUIRED_VERSION} QUIET) + if(mongoc-${LIBMONGOC_REQUIRED_ABI_VERSION}_FOUND) message(STATUS "Found libmongoc ${mongoc-${LIBMONGOC_REQUIRED_ABI_VERSION}_VERSION}, don't need to download it.") else() @@ -73,12 +75,13 @@ if(NEED_DOWNLOAD_C_DRIVER) # Declare mongo-c-driver as a dependency FetchContent_Declare( - mongo-c-driver - GIT_REPOSITORY https://github.com/mongodb/mongo-c-driver.git - GIT_TAG ${LIBMONGOC_DOWNLOAD_VERSION} + mongo-c-driver + GIT_REPOSITORY https://github.com/mongodb/mongo-c-driver.git + GIT_TAG ${LIBMONGOC_DOWNLOAD_VERSION} ) FetchContent_GetProperties(mongo-c-driver) + if(NOT mongo-c-driver_POPULATED) set(OLD_ENABLE_TESTS ${ENABLE_TESTS}) set(OLD_BUILD_TESTING ${BUILD_TESTING}) @@ -88,6 +91,7 @@ if(NEED_DOWNLOAD_C_DRIVER) set(ENABLE_EXTRA_ALIGNMENT OFF) FetchContent_Populate(mongo-c-driver) + # Set ENABLE_TESTS to OFF to disable the test-libmongoc target in the C driver. # This prevents the LoadTests.cmake script from attempting to execute test-libmongoc. # test-libmongoc is not built with the "all" target. @@ -102,6 +106,7 @@ if(NEED_DOWNLOAD_C_DRIVER) set(ENABLE_TESTS ${OLD_ENABLE_TESTS}) set(BUILD_TESTING ${OLD_BUILD_TESTING}) endif() + message(STATUS "Download and configure C driver version ${LIBMONGOC_DOWNLOAD_VERSION} ... end") endif() @@ -114,14 +119,15 @@ endif() # errors. Instead, since we know all our platforms offer the feature, # just hard enable it here. if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - set(COMPILER_HAS_DEPRECATED true) + set(COMPILER_HAS_DEPRECATED true) else() - set(COMPILER_HAS_DEPRECATED_ATTR true) + set(COMPILER_HAS_DEPRECATED_ATTR true) endif() -set (CMAKE_SKIP_BUILD_RPATH false) -set (CMAKE_BUILD_WITH_INSTALL_RPATH false) -set (CMAKE_INSTALL_RPATH_USE_LINK_PATH true) +set(CMAKE_SKIP_BUILD_RPATH false) +set(CMAKE_BUILD_WITH_INSTALL_RPATH false) +set(CMAKE_INSTALL_RPATH_USE_LINK_PATH true) + # Ensure that RPATH is used on OSX set(CMAKE_MACOSX_RPATH 1) @@ -146,14 +152,14 @@ option(BUILD_SHARED_AND_STATIC_LIBS "Build static libraries" OFF) # Allow the user to decide whether to use shared libraries or static libraries # for the mongo-c-driver option(BUILD_SHARED_LIBS_WITH_STATIC_MONGOC - "Use static mongo-c-driver libraries with shared mongo-cxx-driver libraries" - OFF + "Use static mongo-c-driver libraries with shared mongo-cxx-driver libraries" + OFF ) -option (ENABLE_UNINSTALL "Enable creation of uninstall script and associated uninstall build target." ON) +option(ENABLE_UNINSTALL "Enable creation of uninstall script and associated uninstall build target." ON) # Allow the user to enable code coverage -option (ENABLE_CODE_COVERAGE "Enable code coverage." OFF) +option(ENABLE_CODE_COVERAGE "Enable code coverage." OFF) # Disambiguate our options into clear flags if(BUILD_SHARED_LIBS) @@ -179,7 +185,7 @@ else() # Give a fatal error if we have a non-sensical combination if(BUILD_SHARED_AND_STATIC_LIBS) message(FATAL_ERROR - "BUILD_SHARED_LIBS is OFF but BUILD_SHARED_AND_STATIC_LIBS is ON. \ + "BUILD_SHARED_LIBS is OFF but BUILD_SHARED_AND_STATIC_LIBS is ON. \ To build static libraries only, set both BUILD_SHARED_LIBS and BUILD_SHARED_AND_STATIC_LIBS to OFF" ) endif() @@ -194,8 +200,8 @@ To build static libraries only, set both BUILD_SHARED_LIBS and BUILD_SHARED_AND_ set(MONGOCXX_LINK_WITH_STATIC_MONGOC ON CACHE INTERNAL "") endif() - option(MONGOCXX_OVERRIDE_DEFAULT_INSTALL_PREFIX "If enabled, mongocxx will set a default CMAKE_INSTALL_PREFIX if one is not already defined" TRUE) + if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND MONGOCXX_OVERRIDE_DEFAULT_INSTALL_PREFIX) message(WARNING "mongocxx: The default CMAKE_INSTALL_PREFIX is being overridden to the " @@ -203,19 +209,20 @@ if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND MONGOCXX_OVERRIDE_DEFAULT_INS "release. Build with 'MONGOCXX_OVERRIDE_DEFAULT_INSTALL_PREFIX=ON' to opt " "into what will be the default behavior in a future release. Setting install " "path to: ${CMAKE_BINARY_DIR}/install") - set (CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "default install path" FORCE) + set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "default install path" FORCE) endif() set(CMAKE_MODULE_PATH - ${CMAKE_MODULE_PATH} - ${PROJECT_SOURCE_DIR}/cmake - ${PROJECT_SOURCE_DIR}/cmake/make_dist + ${CMAKE_MODULE_PATH} + ${PROJECT_SOURCE_DIR}/cmake + ${PROJECT_SOURCE_DIR}/cmake/make_dist ) include(GNUInstallDirs) -include (ParseVersion) +include(ParseVersion) set(MONGOCXX_CURRENT_VERSION_FILE "") + if(BUILD_VERSION STREQUAL "0.0.0") if(EXISTS ${CMAKE_BINARY_DIR}/VERSION_CURRENT) file(STRINGS ${CMAKE_BINARY_DIR}/VERSION_CURRENT BUILD_VERSION) @@ -224,6 +231,7 @@ if(BUILD_VERSION STREQUAL "0.0.0") file(STRINGS ${MONGOCXX_CURRENT_VERSION_FILE} BUILD_VERSION) else() find_package(PythonInterp) + if(PYTHONINTERP_FOUND) execute_process( COMMAND ${PYTHON_EXECUTABLE} etc/calc_release_version.py @@ -232,10 +240,11 @@ if(BUILD_VERSION STREQUAL "0.0.0") RESULT_VARIABLE CALC_RELEASE_VERSION_RESULT OUTPUT_STRIP_TRAILING_WHITESPACE ) + if(NOT CALC_RELEASE_VERSION_RESULT STREQUAL 0) # If python failed above, stderr would tell the user about it message(FATAL_ERROR - "BUILD_VERSION not specified and could not be calculated\ + "BUILD_VERSION not specified and could not be calculated\ (script invocation failed); specify in CMake command, -DBUILD_VERSION=" ) else() @@ -244,7 +253,7 @@ if(BUILD_VERSION STREQUAL "0.0.0") endif() else() message(FATAL_ERROR - "BUILD_VERSION not specified and could not be calculated\ + "BUILD_VERSION not specified and could not be calculated\ (Python was not found on the system); specify in CMake command, -DBUILD_VERSION=" ) endif() @@ -259,10 +268,11 @@ if(NOT CMAKE_BUILD_TYPE AND NOT isMultiConfig) set(CMAKE_BUILD_TYPE "Release") endif() -if (ENABLE_CODE_COVERAGE) +if(ENABLE_CODE_COVERAGE) if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") message(WARNING "Code coverage results with an optimized (non-Debug) build may be misleading") endif() + if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -g --coverage") elseif(CMAKE_CXX_COMPILER_ID MATCHES "(Apple)?[Cc]lang") @@ -274,12 +284,12 @@ endif() set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -unset (dist_generated CACHE) -unset (dist_generated_depends CACHE) +unset(dist_generated CACHE) +unset(dist_generated_depends CACHE) -set (BUILD_SOURCE_DIR ${CMAKE_BINARY_DIR}) +set(BUILD_SOURCE_DIR ${CMAKE_BINARY_DIR}) -include (MakeDistFiles) +include(MakeDistFiles) add_custom_target(hugo_dir COMMAND ${CMAKE_COMMAND} -E make_directory hugo @@ -339,11 +349,11 @@ add_custom_target(docs set(THIRD_PARTY_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/third_party) -option (ENABLE_TESTS "Build MongoDB C++ Driver tests." ON) +option(ENABLE_TESTS "Build MongoDB C++ Driver tests." ON) -if (ENABLE_TESTS) +if(ENABLE_TESTS) enable_testing() -endif () +endif() add_subdirectory(src) @@ -355,74 +365,74 @@ add_subdirectory(benchmark EXCLUDE_FROM_ALL) # # CMake does not implement anything like 'dist' from autotools. # This implementation is based on the one in GnuCash. - -add_subdirectory (cmake) -add_subdirectory (data) -add_subdirectory (docs) -add_subdirectory (etc) - -set (PACKAGE_PREFIX "mongo-cxx-driver-r${BUILD_VERSION}") -set (DIST_FILE "${PACKAGE_PREFIX}.tar.gz") - -set (top_DIST_local - CMakeLists.txt - CONTRIBUTING.md - CREDITS.json - LICENSE - README.md - THIRD-PARTY-NOTICES - build/.gitignore - ${MONGOCXX_CURRENT_VERSION_FILE} - # This sub-directory is added later, so manually include here - generate_uninstall/CMakeLists.txt +add_subdirectory(cmake) +add_subdirectory(data) +add_subdirectory(docs) +add_subdirectory(etc) + +set(PACKAGE_PREFIX "mongo-cxx-driver-r${BUILD_VERSION}") +set(DIST_FILE "${PACKAGE_PREFIX}.tar.gz") + +set(top_DIST_local + CMakeLists.txt + CONTRIBUTING.md + CREDITS.json + LICENSE + README.md + THIRD-PARTY-NOTICES + build/.gitignore + ${MONGOCXX_CURRENT_VERSION_FILE} + + # This sub-directory is added later, so manually include here + generate_uninstall/CMakeLists.txt ) -set_local_dist (top_DIST ${top_DIST_local}) - -set (ALL_DIST - ${top_DIST} - ${benchmark_DIST} - ${cmake_DIST} - ${docs_DIST} - ${data_DIST} - ${etc_DIST} - ${examples_DIST} - ${src_DIST} +set_local_dist(top_DIST ${top_DIST_local}) + +set(ALL_DIST + ${top_DIST} + ${benchmark_DIST} + ${cmake_DIST} + ${docs_DIST} + ${data_DIST} + ${etc_DIST} + ${examples_DIST} + ${src_DIST} ) # Write a dist manifest -string (REPLACE ";" "\n" ALL_DIST_LINES "${ALL_DIST}") -file (WRITE ${CMAKE_BINARY_DIR}/dist_manifest.txt ${ALL_DIST_LINES}) +string(REPLACE ";" "\n" ALL_DIST_LINES "${ALL_DIST}") +file(WRITE ${CMAKE_BINARY_DIR}/dist_manifest.txt ${ALL_DIST_LINES}) -install (FILES LICENSE README.md THIRD-PARTY-NOTICES - DESTINATION ${CMAKE_INSTALL_DATADIR}/mongo-cxx-driver +install(FILES LICENSE README.md THIRD-PARTY-NOTICES + DESTINATION ${CMAKE_INSTALL_DATADIR}/mongo-cxx-driver ) # This is the command that produces the distribution tarball -add_custom_command (OUTPUT ${DIST_FILE} - COMMAND ${CMAKE_COMMAND} - -D CMAKE_MODULE_PATH=${PROJECT_SOURCE_DIR}/cmake/make_dist - -D PACKAGE_PREFIX=${PACKAGE_PREFIX} - -D MONGOCXX_SOURCE_DIR=${CMAKE_SOURCE_DIR} - -D BUILD_SOURCE_DIR=${BUILD_SOURCE_DIR} - -D SHELL=${SHELL} - "-Ddist_generated=\"${dist_generated}\"" - -P ${PROJECT_SOURCE_DIR}/cmake/make_dist/MakeDist.cmake - - DEPENDS - ${ALL_DIST} ${dist_generated_depends} +add_custom_command(OUTPUT ${DIST_FILE} + COMMAND ${CMAKE_COMMAND} + -D CMAKE_MODULE_PATH=${PROJECT_SOURCE_DIR}/cmake/make_dist + -D PACKAGE_PREFIX=${PACKAGE_PREFIX} + -D MONGOCXX_SOURCE_DIR=${CMAKE_SOURCE_DIR} + -D BUILD_SOURCE_DIR=${BUILD_SOURCE_DIR} + -D SHELL=${SHELL} + "-Ddist_generated=\"${dist_generated}\"" + -P ${PROJECT_SOURCE_DIR}/cmake/make_dist/MakeDist.cmake + + DEPENDS + ${ALL_DIST} ${dist_generated_depends} ) -if(NOT (TARGET dist OR TARGET distcheck)) - add_custom_target (dist DEPENDS ${DIST_FILE}) +if(NOT(TARGET dist OR TARGET distcheck)) + add_custom_target(dist DEPENDS ${DIST_FILE}) - add_custom_target (distcheck DEPENDS dist - COMMAND ${CMAKE_COMMAND} - -D CMAKE_MODULE_PATH=${PROJECT_SOURCE_DIR}/cmake/make_dist - -D CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} - -D PACKAGE_PREFIX=${PACKAGE_PREFIX} - -D CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} - -P ${PROJECT_SOURCE_DIR}/cmake/make_dist/MakeDistCheck.cmake + add_custom_target(distcheck DEPENDS dist + COMMAND ${CMAKE_COMMAND} + -D CMAKE_MODULE_PATH=${PROJECT_SOURCE_DIR}/cmake/make_dist + -D CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} + -D PACKAGE_PREFIX=${PACKAGE_PREFIX} + -D CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} + -P ${PROJECT_SOURCE_DIR}/cmake/make_dist/MakeDistCheck.cmake ) endif() @@ -432,6 +442,7 @@ if(ENABLE_UNINSTALL) else() set(UNINSTALL_PROG "uninstall.sh") endif() + set(UNINSTALL_PROG_DIR "${CMAKE_INSTALL_DATADIR}/mongo-cxx-driver") # Create uninstall program and associated uninstall target @@ -442,14 +453,17 @@ if(ENABLE_UNINSTALL) endif() # Spit out some information regarding the generated build system -message (STATUS "Build files generated for:") -message (STATUS "\tbuild system: ${CMAKE_GENERATOR}") -if (CMAKE_GENERATOR_INSTANCE) - message (STATUS "\tinstance: ${CMAKE_GENERATOR_INSTANCE}") -endif () -if (CMAKE_GENERATOR_PLATFORM) - message (STATUS "\tinstance: ${CMAKE_GENERATOR_PLATFORM}") -endif () -if (CMAKE_GENERATOR_TOOLSET) - message (STATUS "\tinstance: ${CMAKE_GENERATOR_TOOLSET}") -endif () +message(STATUS "Build files generated for:") +message(STATUS "\tbuild system: ${CMAKE_GENERATOR}") + +if(CMAKE_GENERATOR_INSTANCE) + message(STATUS "\tinstance: ${CMAKE_GENERATOR_INSTANCE}") +endif() + +if(CMAKE_GENERATOR_PLATFORM) + message(STATUS "\tinstance: ${CMAKE_GENERATOR_PLATFORM}") +endif() + +if(CMAKE_GENERATOR_TOOLSET) + message(STATUS "\tinstance: ${CMAKE_GENERATOR_TOOLSET}") +endif() diff --git a/cmake/BsoncxxUtil.cmake b/cmake/BsoncxxUtil.cmake index d3a2d14868..0335274e97 100644 --- a/cmake/BsoncxxUtil.cmake +++ b/cmake/BsoncxxUtil.cmake @@ -32,8 +32,8 @@ function(bsoncxx_add_library TARGET OUTPUT_NAME LINK_TYPE) target_include_directories( ${TARGET} PUBLIC - $ - $ + $ + $ ) elseif(BSONCXX_POLY_USE_BOOST) find_package(Boost 1.56.0 REQUIRED) @@ -45,9 +45,9 @@ function(bsoncxx_add_library TARGET OUTPUT_NAME LINK_TYPE) target_include_directories( ${TARGET} PUBLIC - $ - $ - $ + $ + $ + $ ) target_compile_definitions(${TARGET} PRIVATE ${libbson_definitions}) @@ -91,12 +91,12 @@ function(bsoncxx_install BSONCXX_TARGET_LIST BSONCXX_PKG_DEP BSONCXX_BOOST_PKG_D install( FILES - "${CMAKE_CURRENT_BINARY_DIR}/bsoncxx-config-version.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/bsoncxx-config.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/bsoncxx-config-version.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/bsoncxx-config.cmake" DESTINATION - ${CMAKE_INSTALL_LIBDIR}/cmake/bsoncxx-${BSONCXX_VERSION} + ${CMAKE_INSTALL_LIBDIR}/cmake/bsoncxx-${BSONCXX_VERSION} COMPONENT - Devel + Devel ) endfunction(bsoncxx_install) @@ -104,19 +104,19 @@ function(bsoncxx_install_deprecated_cmake NAME) set(PKG "lib${NAME}") configure_package_config_file( - cmake/${PKG}-config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/${PKG}-config.cmake - INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PKG}-${BSONCXX_VERSION} - PATH_VARS PACKAGE_INCLUDE_INSTALL_DIRS PACKAGE_LIBRARY_INSTALL_DIRS + cmake/${PKG}-config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/${PKG}-config.cmake + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PKG}-${BSONCXX_VERSION} + PATH_VARS PACKAGE_INCLUDE_INSTALL_DIRS PACKAGE_LIBRARY_INSTALL_DIRS ) write_basic_package_version_file( - ${CMAKE_CURRENT_BINARY_DIR}/${PKG}-config-version.cmake - VERSION ${BSONCXX_VERSION} - COMPATIBILITY SameMajorVersion + ${CMAKE_CURRENT_BINARY_DIR}/${PKG}-config-version.cmake + VERSION ${BSONCXX_VERSION} + COMPATIBILITY SameMajorVersion ) install( - FILES ${CMAKE_CURRENT_BINARY_DIR}/${PKG}-config.cmake ${CMAKE_CURRENT_BINARY_DIR}/${PKG}-config-version.cmake - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PKG}-${BSONCXX_VERSION} + FILES ${CMAKE_CURRENT_BINARY_DIR}/${PKG}-config.cmake ${CMAKE_CURRENT_BINARY_DIR}/${PKG}-config-version.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PKG}-${BSONCXX_VERSION} ) endfunction(bsoncxx_install_deprecated_cmake) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index e293e3d6e2..1ac493f9a0 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -12,21 +12,21 @@ # See the License for the specific language governing permissions and # limitations under the License. -add_subdirectory (make_dist) +add_subdirectory(make_dist) -set (cmake_MODULES - ParseVersion.cmake - BsoncxxUtil.cmake - MongocxxUtil.cmake +set(cmake_MODULES + ParseVersion.cmake + BsoncxxUtil.cmake + MongocxxUtil.cmake ) -set_local_dist (cmake_DIST_local - CMakeLists.txt - ${cmake_MODULES} +set_local_dist(cmake_DIST_local + CMakeLists.txt + ${cmake_MODULES} ) -set (cmake_DIST - ${cmake_DIST_local} - ${cmake_make_dist_DIST} - PARENT_SCOPE +set(cmake_DIST + ${cmake_DIST_local} + ${cmake_make_dist_DIST} + PARENT_SCOPE ) diff --git a/cmake/MongocxxUtil.cmake b/cmake/MongocxxUtil.cmake index e0ab46e56d..399a35ca00 100644 --- a/cmake/MongocxxUtil.cmake +++ b/cmake/MongocxxUtil.cmake @@ -10,14 +10,14 @@ function(mongocxx_add_library TARGET OUTPUT_NAME LINK_TYPE) ${mongocxx_sources} ) - set_target_properties (${TARGET} PROPERTIES + set_target_properties(${TARGET} PROPERTIES OUTPUT_NAME ${OUTPUT_NAME} VERSION ${MONGOCXX_VERSION} DEFINE_SYMBOL MONGOCXX_EXPORTS ) if(LINK_TYPE STREQUAL "SHARED") - set_target_properties (${TARGET} PROPERTIES + set_target_properties(${TARGET} PROPERTIES CXX_VISIBILITY_PRESET hidden VISIBILITY_INLINES_HIDDEN ON SOVERSION _noabi @@ -33,9 +33,9 @@ function(mongocxx_add_library TARGET OUTPUT_NAME LINK_TYPE) target_include_directories( ${TARGET} PUBLIC - $ - $ - $ + $ + $ + $ ) target_compile_definitions(${TARGET} PRIVATE ${libmongoc_definitions}) @@ -52,7 +52,7 @@ endfunction(mongocxx_add_library) # with associated CMake config files function(mongocxx_install MONGOCXX_TARGET_LIST MONGOCXX_PKG_DEP) install(TARGETS - ${MONGOCXX_TARGET_LIST} + ${MONGOCXX_TARGET_LIST} EXPORT mongocxx_targets RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT runtime LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT runtime @@ -79,12 +79,12 @@ function(mongocxx_install MONGOCXX_TARGET_LIST MONGOCXX_PKG_DEP) install( FILES - "${CMAKE_CURRENT_BINARY_DIR}/mongocxx-config-version.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/mongocxx-config.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/mongocxx-config-version.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/mongocxx-config.cmake" DESTINATION - ${CMAKE_INSTALL_LIBDIR}/cmake/mongocxx-${MONGOCXX_VERSION} + ${CMAKE_INSTALL_LIBDIR}/cmake/mongocxx-${MONGOCXX_VERSION} COMPONENT - Devel + Devel ) endfunction(mongocxx_install) @@ -92,19 +92,19 @@ function(mongocxx_install_deprecated_cmake NAME) set(PKG "lib${NAME}") configure_package_config_file( - cmake/${PKG}-config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/${PKG}-config.cmake - INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PKG}-${MONGOCXX_VERSION} - PATH_VARS PACKAGE_INCLUDE_INSTALL_DIRS PACKAGE_LIBRARY_INSTALL_DIRS + cmake/${PKG}-config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/${PKG}-config.cmake + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PKG}-${MONGOCXX_VERSION} + PATH_VARS PACKAGE_INCLUDE_INSTALL_DIRS PACKAGE_LIBRARY_INSTALL_DIRS ) write_basic_package_version_file( - ${CMAKE_CURRENT_BINARY_DIR}/${PKG}-config-version.cmake - VERSION ${MONGOCXX_VERSION} - COMPATIBILITY SameMajorVersion + ${CMAKE_CURRENT_BINARY_DIR}/${PKG}-config-version.cmake + VERSION ${MONGOCXX_VERSION} + COMPATIBILITY SameMajorVersion ) install( - FILES ${CMAKE_CURRENT_BINARY_DIR}/${PKG}-config.cmake ${CMAKE_CURRENT_BINARY_DIR}/${PKG}-config-version.cmake - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PKG}-${MONGOCXX_VERSION} + FILES ${CMAKE_CURRENT_BINARY_DIR}/${PKG}-config.cmake ${CMAKE_CURRENT_BINARY_DIR}/${PKG}-config-version.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PKG}-${MONGOCXX_VERSION} ) endfunction(mongocxx_install_deprecated_cmake) diff --git a/cmake/ParseVersion.cmake b/cmake/ParseVersion.cmake index 95fe83db8f..0e8abbd5a3 100644 --- a/cmake/ParseVersion.cmake +++ b/cmake/ParseVersion.cmake @@ -1,44 +1,45 @@ -function (ParseVersion VERSION_CONTENTS PREFIX) +function(ParseVersion VERSION_CONTENTS PREFIX) # E.g., "MONGOCXX_VERSION". - string (REPLACE ";" "" VERSION_NAME ${PREFIX} _VERSION) - string (REPLACE ";" "" DIST_VERSION_NAME ${PREFIX} _DIST_VERSION) + string(REPLACE ";" "" VERSION_NAME ${PREFIX} _VERSION) + string(REPLACE ";" "" DIST_VERSION_NAME ${PREFIX} _DIST_VERSION) # A list of version components separated by dots and dashes: "1.3.0-[prerelease-marker]" - string (REGEX MATCHALL "[^.-]+" VERSION ${VERSION_CONTENTS}) + string(REGEX MATCHALL "[^.-]+" VERSION ${VERSION_CONTENTS}) - list (GET VERSION 0 VERSION_MAJOR) - string (REPLACE ";" "" VERSION_MAJOR_NAME ${PREFIX} _VERSION_MAJOR) - set (${VERSION_MAJOR_NAME} ${VERSION_MAJOR} PARENT_SCOPE) + list(GET VERSION 0 VERSION_MAJOR) + string(REPLACE ";" "" VERSION_MAJOR_NAME ${PREFIX} _VERSION_MAJOR) + set(${VERSION_MAJOR_NAME} ${VERSION_MAJOR} PARENT_SCOPE) - list (GET VERSION 1 VERSION_MINOR) - string (REPLACE ";" "" VERSION_MINOR_NAME ${PREFIX} _VERSION_MINOR) - set (${VERSION_MINOR_NAME} ${VERSION_MINOR} PARENT_SCOPE) + list(GET VERSION 1 VERSION_MINOR) + string(REPLACE ";" "" VERSION_MINOR_NAME ${PREFIX} _VERSION_MINOR) + set(${VERSION_MINOR_NAME} ${VERSION_MINOR} PARENT_SCOPE) - list (GET VERSION 2 VERSION_PATCH) - string (REPLACE ";" "" VERSION_PATCH_NAME ${PREFIX} _VERSION_PATCH) - set (${VERSION_PATCH_NAME} ${VERSION_PATCH} PARENT_SCOPE) + list(GET VERSION 2 VERSION_PATCH) + string(REPLACE ";" "" VERSION_PATCH_NAME ${PREFIX} _VERSION_PATCH) + set(${VERSION_PATCH_NAME} ${VERSION_PATCH} PARENT_SCOPE) - string (REPLACE ";" "" VERSION_EXTRA_NAME ${PREFIX} _VERSION_EXTRA) - string (REPLACE ";" "" VERSION_DIST_EXTRA_NAME ${PREFIX} _VERSION_DIST_EXTRA) - list (LENGTH VERSION VERSION_LENGTH) - if (VERSION_LENGTH GREATER 3) - list (GET VERSION 3 VERSION_EXTRA) - set (${VERSION_DIST_EXTRA_NAME} "-${VERSION_EXTRA}" PARENT_SCOPE) - set (${VERSION_EXTRA_NAME} "-pre" PARENT_SCOPE) - set (${VERSION_NAME} + string(REPLACE ";" "" VERSION_EXTRA_NAME ${PREFIX} _VERSION_EXTRA) + string(REPLACE ";" "" VERSION_DIST_EXTRA_NAME ${PREFIX} _VERSION_DIST_EXTRA) + list(LENGTH VERSION VERSION_LENGTH) + + if(VERSION_LENGTH GREATER 3) + list(GET VERSION 3 VERSION_EXTRA) + set(${VERSION_DIST_EXTRA_NAME} "-${VERSION_EXTRA}" PARENT_SCOPE) + set(${VERSION_EXTRA_NAME} "-pre" PARENT_SCOPE) + set(${VERSION_NAME} "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-pre" PARENT_SCOPE) - set (${DIST_VERSION_NAME} + set(${DIST_VERSION_NAME} "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}${VERSION_EXTRA}" PARENT_SCOPE) - else () - set (${VERSION_DIST_EXTRA_NAME} "" PARENT_SCOPE) - set (${VERSION_EXTRA_NAME} "" PARENT_SCOPE) - set (${VERSION_NAME} + else() + set(${VERSION_DIST_EXTRA_NAME} "" PARENT_SCOPE) + set(${VERSION_EXTRA_NAME} "" PARENT_SCOPE) + set(${VERSION_NAME} "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" PARENT_SCOPE) - set (${DIST_VERSION_NAME} + set(${DIST_VERSION_NAME} "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" PARENT_SCOPE) - endif () -endfunction (ParseVersion) + endif() +endfunction(ParseVersion) diff --git a/cmake/make_dist/CMakeLists.txt b/cmake/make_dist/CMakeLists.txt index 8ea7ae8212..9cbb71401f 100644 --- a/cmake/make_dist/CMakeLists.txt +++ b/cmake/make_dist/CMakeLists.txt @@ -12,14 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -set (cmake_make_dist_MODULES - MakeDist.cmake - MakeDistCheck.cmake - MakeDistFiles.cmake +set(cmake_make_dist_MODULES + MakeDist.cmake + MakeDistCheck.cmake + MakeDistFiles.cmake ) -set_dist_list (cmake_make_dist_DIST - CMakeLists.txt - COPYING-CMAKE-SCRIPTS.txt - ${cmake_make_dist_MODULES} +set_dist_list(cmake_make_dist_DIST + CMakeLists.txt + COPYING-CMAKE-SCRIPTS.txt + ${cmake_make_dist_MODULES} ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d1bf5e944d..f6ec5a5c06 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -16,16 +16,16 @@ add_definitions(-DMONGO_CXX_DRIVER_COMPILING) add_subdirectory(bsoncxx) add_subdirectory(mongocxx) -set_local_dist (src_DIST_local - CMakeLists.txt - third_party/catch/main.cpp - third_party/catch/include/catch.hpp - third_party/catch/include/helpers.hpp +set_local_dist(src_DIST_local + CMakeLists.txt + third_party/catch/main.cpp + third_party/catch/include/catch.hpp + third_party/catch/include/helpers.hpp ) -set (src_DIST - ${src_DIST_local} - ${src_bsoncxx_DIST} - ${src_mongocxx_DIST} - PARENT_SCOPE +set(src_DIST + ${src_DIST_local} + ${src_bsoncxx_DIST} + ${src_mongocxx_DIST} + PARENT_SCOPE ) diff --git a/src/bsoncxx/CMakeLists.txt b/src/bsoncxx/CMakeLists.txt index ec9755a04c..8698080449 100644 --- a/src/bsoncxx/CMakeLists.txt +++ b/src/bsoncxx/CMakeLists.txt @@ -14,11 +14,11 @@ project(BSONCXX) -ParseVersion (${BUILD_VERSION} BSONCXX) +ParseVersion(${BUILD_VERSION} BSONCXX) set(BSONCXX_VERSION_NO_EXTRA ${BSONCXX_VERSION_MAJOR}.${BSONCXX_VERSION_MINOR}.${BSONCXX_VERSION_PATCH}) set(BSONCXX_VERSION ${BSONCXX_VERSION_NO_EXTRA}${BSONCXX_VERSION_EXTRA}) -message ("bsoncxx version: ${BSONCXX_VERSION}") +message("bsoncxx version: ${BSONCXX_VERSION}") option(BSONCXX_POLY_USE_MNMLSTC "Use MNMLSTC/core for stdx polyfills" OFF) option(BSONCXX_POLY_USE_STD_EXPERIMENTAL "Use std::experimental for stdx polyfills" OFF) @@ -30,49 +30,49 @@ set(BSONCXX_OUTPUT_BASENAME "bsoncxx" CACHE STRING "Output bsoncxx library base # Count how many polyfill options are true-ish set(BSONCXX_POLY_OPTIONS_SET 0) -foreach (BSONCXX_POLY_OPTION ${BSONCXX_POLY_USE_MNMLSTC} ${BSONCXX_POLY_USE_STD_EXPERIMENTAL} ${BSONCXX_POLY_USE_BOOST} ${BSONCXX_POLY_USE_STD}) - if(${BSONCXX_POLY_OPTION}) - MATH(EXPR BSONCXX_POLY_OPTIONS_SET "${BSONCXX_POLY_OPTIONS_SET}+1") - endif() + +foreach(BSONCXX_POLY_OPTION ${BSONCXX_POLY_USE_MNMLSTC} ${BSONCXX_POLY_USE_STD_EXPERIMENTAL} ${BSONCXX_POLY_USE_BOOST} ${BSONCXX_POLY_USE_STD}) + if(${BSONCXX_POLY_OPTION}) + MATH(EXPR BSONCXX_POLY_OPTIONS_SET "${BSONCXX_POLY_OPTIONS_SET}+1") + endif() endforeach() if(BSONCXX_POLY_OPTIONS_SET GREATER 1) - # You can't ask for more than one polyfill - message(FATAL_ERROR "Cannnot specify more than one bsoncxx polyfill choice") + # You can't ask for more than one polyfill + message(FATAL_ERROR "Cannnot specify more than one bsoncxx polyfill choice") elseif(BSONCXX_POLY_OPTIONS_SET EQUAL 0) - # You can just not say, in which case we endeavor to pick a sane default: - - if(NOT CMAKE_CXX_STANDARD LESS 17) - # If we are in C++17 mode, use the C++17 versions - set(BSONCXX_POLY_USE_STD ON) - message(STATUS "Auto-configuring bsoncxx to use C++17 std library polyfills since C++17 is active and user didn't specify otherwise") - elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - # Otherwise, since MSVC can't handle MNMLSTC, default to boost - set(BSONCXX_POLY_USE_BOOST ON) - message(STATUS "Auto-configuring bsoncxx to use boost std library polyfills since C++17 is inactive and compiler is MSVC") - else() - # Otherwise, we are on a platform that can handle MNMLSTC - set(BSONCXX_POLY_USE_MNMLSTC ON) - message(STATUS "Auto-configuring bsoncxx to use MNMLSTC for polyfills since C++17 is inactive") - endif() - + # You can just not say, in which case we endeavor to pick a sane default: + if(NOT CMAKE_CXX_STANDARD LESS 17) + # If we are in C++17 mode, use the C++17 versions + set(BSONCXX_POLY_USE_STD ON) + message(STATUS "Auto-configuring bsoncxx to use C++17 std library polyfills since C++17 is active and user didn't specify otherwise") + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + # Otherwise, since MSVC can't handle MNMLSTC, default to boost + set(BSONCXX_POLY_USE_BOOST ON) + message(STATUS "Auto-configuring bsoncxx to use boost std library polyfills since C++17 is inactive and compiler is MSVC") + else() + # Otherwise, we are on a platform that can handle MNMLSTC + set(BSONCXX_POLY_USE_MNMLSTC ON) + message(STATUS "Auto-configuring bsoncxx to use MNMLSTC for polyfills since C++17 is inactive") + endif() endif() # It doesn't make sense to say we aren't using MNMLSTC but then # request the system version of it. if(NOT BSONCXX_POLY_USE_MNMLSTC AND BSONCXX_POLY_USE_SYSTEM_MNMLSTC) - MESSAGE(FATAL_ERROR "Can't specify system mnmlstc when not using mnmlstc") + MESSAGE(FATAL_ERROR "Can't specify system mnmlstc when not using mnmlstc") endif() # Can only use STD_EXPERIMENTAL in C++14 mode if(BSONCXX_POLY_USE_STD_EXPERIMENTAL AND CMAKE_CXX_STANDARD LESS 14) - message(FATAL_ERROR "Can only use BSONCXX_POLY_USE_STD_EXPERIMENTAL if CMAKE_CXX_STANDARD is 14 or higher") + message(FATAL_ERROR "Can only use BSONCXX_POLY_USE_STD_EXPERIMENTAL if CMAKE_CXX_STANDARD is 14 or higher") endif() set(BSONCXX_POLY_MNMLSTC_DEPRECATED_INCLUDE_DIRS "") set(BSONCXX_POLY_MNMLSTC_PKGCONFIG_INCLUDE_DIRS "") set(BSONCXX_POLY_MNMLSTC_PKGCONFIG_STATIC_INCLUDE_DIRS "") -if (BSONCXX_POLY_USE_MNMLSTC AND NOT BSONCXX_POLY_USE_SYSTEM_MNMLSTC) + +if(BSONCXX_POLY_USE_MNMLSTC AND NOT BSONCXX_POLY_USE_SYSTEM_MNMLSTC) # For deprecated CMake package config files. set(BSONCXX_POLY_MNMLSTC_DEPRECATED_INCLUDE_DIRS "${CMAKE_INSTALL_INCLUDEDIR}/bsoncxx/v_noabi/bsoncxx/third_party/mnmlstc" @@ -85,53 +85,55 @@ if (BSONCXX_POLY_USE_MNMLSTC AND NOT BSONCXX_POLY_USE_SYSTEM_MNMLSTC) set(BSONCXX_POLY_MNMLSTC_PKGCONFIG_STATIC_INCLUDE_DIRS [[-I${includedir}/bsoncxx/v_noabi/bsoncxx/third_party/mnmlstc ]] ) -endif () +endif() set(bsoncxx_pkg_dep "") set(bsoncxx_boost_pkg_dep "") if(TARGET bson_shared OR TARGET bson_static) - # If these targets exist, then libbson has already been included as a project - # sub-directory - message ("found libbson targets declared in current build scope; version not checked") - - if(NOT BSONCXX_LINK_WITH_STATIC_MONGOC) - set(libbson_target bson_shared) - else() - set(libbson_target bson_static) - endif() - - set(bsoncxx_pkg_dep "find_dependency(bson-${LIBBSON_REQUIRED_ABI_VERSION} REQUIRED)") -else() - # Attempt to find libbson by new package name (without lib). - find_package(bson-${LIBBSON_REQUIRED_ABI_VERSION} ${LIBBSON_REQUIRED_VERSION} QUIET) + # If these targets exist, then libbson has already been included as a project + # sub-directory + message("found libbson targets declared in current build scope; version not checked") - if(bson-${LIBBSON_REQUIRED_ABI_VERSION}_FOUND) - message ("found libbson version ${bson-${LIBBSON_REQUIRED_ABI_VERSION}_VERSION}") if(NOT BSONCXX_LINK_WITH_STATIC_MONGOC) - set(libbson_target mongo::bson_shared) + set(libbson_target bson_shared) else() - set(libbson_target mongo::bson_static) + set(libbson_target bson_static) endif() + set(bsoncxx_pkg_dep "find_dependency(bson-${LIBBSON_REQUIRED_ABI_VERSION} REQUIRED)") - else() - # Require package of old libbson name (with lib). - if(NOT BSONCXX_LINK_WITH_STATIC_MONGOC) - find_package(libbson-${LIBBSON_REQUIRED_ABI_VERSION} ${LIBBSON_REQUIRED_VERSION} REQUIRED) - message ("found libbson version ${BSON_VERSION}") - set(libbson_target ${BSON_LIBRARIES}) - set(libbson_include_directories ${BSON_INCLUDE_DIRS}) - set(libbson_definitions ${BSON_DEFINITIONS}) - set(bsoncxx_pkg_dep "find_dependency(libbson-${LIBBSON_REQUIRED_ABI_VERSION} REQUIRED)") +else() + # Attempt to find libbson by new package name (without lib). + find_package(bson-${LIBBSON_REQUIRED_ABI_VERSION} ${LIBBSON_REQUIRED_VERSION} QUIET) + + if(bson-${LIBBSON_REQUIRED_ABI_VERSION}_FOUND) + message("found libbson version ${bson-${LIBBSON_REQUIRED_ABI_VERSION}_VERSION}") + + if(NOT BSONCXX_LINK_WITH_STATIC_MONGOC) + set(libbson_target mongo::bson_shared) + else() + set(libbson_target mongo::bson_static) + endif() + + set(bsoncxx_pkg_dep "find_dependency(bson-${LIBBSON_REQUIRED_ABI_VERSION} REQUIRED)") else() - find_package(libbson-static-${LIBBSON_REQUIRED_ABI_VERSION} ${LIBBSON_REQUIRED_VERSION} REQUIRED) - message ("found libbson version ${BSON_STATIC_VERSION}") - set(libbson_target ${BSON_STATIC_LIBRARIES}) - set(libbson_include_directories ${BSON_STATIC_INCLUDE_DIRS}) - set(libbson_definitions ${BSON_STATIC_DEFINITIONS}) - set(bsoncxx_pkg_dep "find_dependency(libbson-static-${LIBBSON_REQUIRED_ABI_VERSION} REQUIRED)") + # Require package of old libbson name (with lib). + if(NOT BSONCXX_LINK_WITH_STATIC_MONGOC) + find_package(libbson-${LIBBSON_REQUIRED_ABI_VERSION} ${LIBBSON_REQUIRED_VERSION} REQUIRED) + message("found libbson version ${BSON_VERSION}") + set(libbson_target ${BSON_LIBRARIES}) + set(libbson_include_directories ${BSON_INCLUDE_DIRS}) + set(libbson_definitions ${BSON_DEFINITIONS}) + set(bsoncxx_pkg_dep "find_dependency(libbson-${LIBBSON_REQUIRED_ABI_VERSION} REQUIRED)") + else() + find_package(libbson-static-${LIBBSON_REQUIRED_ABI_VERSION} ${LIBBSON_REQUIRED_VERSION} REQUIRED) + message("found libbson version ${BSON_STATIC_VERSION}") + set(libbson_target ${BSON_STATIC_LIBRARIES}) + set(libbson_include_directories ${BSON_STATIC_INCLUDE_DIRS}) + set(libbson_definitions ${BSON_STATIC_DEFINITIONS}) + set(bsoncxx_pkg_dep "find_dependency(libbson-static-${LIBBSON_REQUIRED_ABI_VERSION} REQUIRED)") + endif() endif() - endif() endif() add_subdirectory(third_party) @@ -161,7 +163,6 @@ set(bsoncxx_sources # library does not get installed, but the tests link against it instead of the normal library. The # only difference between the libraries is that BSONCXX_TESTING is defined in the testing-only # library (this define enables special testing-only behavior). - include(BsoncxxUtil) if(BSONCXX_BUILD_SHARED) @@ -174,20 +175,23 @@ endif() if(BSONCXX_BUILD_SHARED) set(BSONCXX_LIBRARY_FOR_EXAMPLES "bsoncxx_shared" CACHE INTERNAL "") + if(ENABLE_TESTS) - bsoncxx_add_library(bsoncxx_testing "bsoncxx-testing" SHARED) + bsoncxx_add_library(bsoncxx_testing "bsoncxx-testing" SHARED) endif() else() set(BSONCXX_LIBRARY_FOR_EXAMPLES "bsoncxx_static" CACHE INTERNAL "") + if(ENABLE_TESTS) - bsoncxx_add_library(bsoncxx_testing "bsoncxx-testing" STATIC) + bsoncxx_add_library(bsoncxx_testing "bsoncxx-testing" STATIC) endif() endif() + if(ENABLE_TESTS) - target_compile_definitions(bsoncxx_testing PUBLIC BSONCXX_TESTING) + target_compile_definitions(bsoncxx_testing PUBLIC BSONCXX_TESTING) endif() -set (libdir "\${prefix}/${CMAKE_INSTALL_LIBDIR}") +set(libdir "\${prefix}/${CMAKE_INSTALL_LIBDIR}") if(BSONCXX_BUILD_SHARED) configure_file( @@ -238,6 +242,7 @@ set(PACKAGE_LIBRARIES bsoncxx) include(CMakePackageConfigHelpers) set(bsoncxx_target_list "") + if(BSONCXX_BUILD_SHARED) bsoncxx_install_deprecated_cmake(bsoncxx) list(APPEND bsoncxx_target_list bsoncxx_shared) @@ -247,53 +252,55 @@ if(BSONCXX_BUILD_STATIC) bsoncxx_install_deprecated_cmake(bsoncxx-static) list(APPEND bsoncxx_target_list bsoncxx_static) endif() + if(BSONCXX_POLY_USE_BOOST) set(bsoncxx_boost_pkg_dep "find_dependency(Boost 1.56.0 REQUIRED)") endif() + bsoncxx_install("${bsoncxx_target_list}" "${bsoncxx_pkg_dep}" "${bsoncxx_boost_pkg_dep}") if(ENABLE_TESTS) - add_subdirectory(test) + add_subdirectory(test) endif() -set_local_dist (src_bsoncxx_lib_v_noabi_DIST_local - CMakeLists.txt - lib/bsoncxx/v_noabi/bsoncxx/array/element.cpp - lib/bsoncxx/v_noabi/bsoncxx/array/value.cpp - lib/bsoncxx/v_noabi/bsoncxx/array/view.cpp - lib/bsoncxx/v_noabi/bsoncxx/builder/core.cpp - cmake/bsoncxx-config.cmake.in - cmake/libbsoncxx-config.cmake.in - cmake/libbsoncxx-static-config.cmake.in - cmake/libbsoncxx-static.pc.in - cmake/libbsoncxx.pc.in - lib/bsoncxx/v_noabi/bsoncxx/decimal128.cpp - lib/bsoncxx/v_noabi/bsoncxx/document/element.cpp - lib/bsoncxx/v_noabi/bsoncxx/document/value.cpp - lib/bsoncxx/v_noabi/bsoncxx/document/view.cpp - lib/bsoncxx/v_noabi/bsoncxx/exception/error_code.cpp - lib/bsoncxx/v_noabi/bsoncxx/json.cpp - lib/bsoncxx/v_noabi/bsoncxx/oid.cpp - lib/bsoncxx/v_noabi/bsoncxx/private/b64_ntop.hh - lib/bsoncxx/v_noabi/bsoncxx/private/helpers.hh - lib/bsoncxx/v_noabi/bsoncxx/private/itoa.cpp - lib/bsoncxx/v_noabi/bsoncxx/private/itoa.hh - lib/bsoncxx/v_noabi/bsoncxx/private/libbson.hh - lib/bsoncxx/v_noabi/bsoncxx/private/stack.hh - lib/bsoncxx/v_noabi/bsoncxx/private/suppress_deprecation_warnings.hh - lib/bsoncxx/v_noabi/bsoncxx/string/view_or_value.cpp - lib/bsoncxx/v_noabi/bsoncxx/test_util/catch.hh - lib/bsoncxx/v_noabi/bsoncxx/test_util/export_for_testing.hh - lib/bsoncxx/v_noabi/bsoncxx/test_util/to_string.hh - lib/bsoncxx/v_noabi/bsoncxx/types.cpp - lib/bsoncxx/v_noabi/bsoncxx/types/private/convert.hh - lib/bsoncxx/v_noabi/bsoncxx/types/bson_value/private/value.hh - lib/bsoncxx/v_noabi/bsoncxx/types/bson_value/value.cpp - lib/bsoncxx/v_noabi/bsoncxx/types/bson_value/view.cpp - lib/bsoncxx/v_noabi/bsoncxx/validate.cpp +set_local_dist(src_bsoncxx_lib_v_noabi_DIST_local + CMakeLists.txt + lib/bsoncxx/v_noabi/bsoncxx/array/element.cpp + lib/bsoncxx/v_noabi/bsoncxx/array/value.cpp + lib/bsoncxx/v_noabi/bsoncxx/array/view.cpp + lib/bsoncxx/v_noabi/bsoncxx/builder/core.cpp + cmake/bsoncxx-config.cmake.in + cmake/libbsoncxx-config.cmake.in + cmake/libbsoncxx-static-config.cmake.in + cmake/libbsoncxx-static.pc.in + cmake/libbsoncxx.pc.in + lib/bsoncxx/v_noabi/bsoncxx/decimal128.cpp + lib/bsoncxx/v_noabi/bsoncxx/document/element.cpp + lib/bsoncxx/v_noabi/bsoncxx/document/value.cpp + lib/bsoncxx/v_noabi/bsoncxx/document/view.cpp + lib/bsoncxx/v_noabi/bsoncxx/exception/error_code.cpp + lib/bsoncxx/v_noabi/bsoncxx/json.cpp + lib/bsoncxx/v_noabi/bsoncxx/oid.cpp + lib/bsoncxx/v_noabi/bsoncxx/private/b64_ntop.hh + lib/bsoncxx/v_noabi/bsoncxx/private/helpers.hh + lib/bsoncxx/v_noabi/bsoncxx/private/itoa.cpp + lib/bsoncxx/v_noabi/bsoncxx/private/itoa.hh + lib/bsoncxx/v_noabi/bsoncxx/private/libbson.hh + lib/bsoncxx/v_noabi/bsoncxx/private/stack.hh + lib/bsoncxx/v_noabi/bsoncxx/private/suppress_deprecation_warnings.hh + lib/bsoncxx/v_noabi/bsoncxx/string/view_or_value.cpp + lib/bsoncxx/v_noabi/bsoncxx/test_util/catch.hh + lib/bsoncxx/v_noabi/bsoncxx/test_util/export_for_testing.hh + lib/bsoncxx/v_noabi/bsoncxx/test_util/to_string.hh + lib/bsoncxx/v_noabi/bsoncxx/types.cpp + lib/bsoncxx/v_noabi/bsoncxx/types/private/convert.hh + lib/bsoncxx/v_noabi/bsoncxx/types/bson_value/private/value.hh + lib/bsoncxx/v_noabi/bsoncxx/types/bson_value/value.cpp + lib/bsoncxx/v_noabi/bsoncxx/types/bson_value/view.cpp + lib/bsoncxx/v_noabi/bsoncxx/validate.cpp ) -set_local_dist (src_bsoncxx_include_v_noabi_DIST_local +set_local_dist(src_bsoncxx_include_v_noabi_DIST_local include/bsoncxx/v_noabi/bsoncxx/array/element.hpp include/bsoncxx/v_noabi/bsoncxx/array/value.hpp include/bsoncxx/v_noabi/bsoncxx/array/view_or_value.hpp @@ -346,11 +353,11 @@ set_local_dist (src_bsoncxx_include_v_noabi_DIST_local include/bsoncxx/v_noabi/bsoncxx/view_or_value.hpp ) -set (src_bsoncxx_DIST - ${src_bsoncxx_lib_v_noabi_DIST_local} - ${src_bsoncxx_include_v_noabi_DIST_local} - ${src_bsoncxx_config_DIST} - ${src_bsoncxx_third_party_DIST} - ${src_bsoncxx_test_DIST} - PARENT_SCOPE +set(src_bsoncxx_DIST + ${src_bsoncxx_lib_v_noabi_DIST_local} + ${src_bsoncxx_include_v_noabi_DIST_local} + ${src_bsoncxx_config_DIST} + ${src_bsoncxx_third_party_DIST} + ${src_bsoncxx_test_DIST} + PARENT_SCOPE ) diff --git a/src/bsoncxx/lib/bsoncxx/v_noabi/bsoncxx/config/CMakeLists.txt b/src/bsoncxx/lib/bsoncxx/v_noabi/bsoncxx/config/CMakeLists.txt index fa76c1c0bb..8756118de5 100644 --- a/src/bsoncxx/lib/bsoncxx/v_noabi/bsoncxx/config/CMakeLists.txt +++ b/src/bsoncxx/lib/bsoncxx/v_noabi/bsoncxx/config/CMakeLists.txt @@ -34,11 +34,11 @@ install(FILES COMPONENT dev ) -set_dist_list (src_bsoncxx_config_DIST - CMakeLists.txt - config.hpp.in - private/config.hh.in - private/postlude.hh - private/prelude.hh - version.hpp.in +set_dist_list(src_bsoncxx_config_DIST + CMakeLists.txt + config.hpp.in + private/config.hh.in + private/postlude.hh + private/prelude.hh + version.hpp.in ) diff --git a/src/bsoncxx/test/CMakeLists.txt b/src/bsoncxx/test/CMakeLists.txt index 35bc52b3b8..871eaf2162 100644 --- a/src/bsoncxx/test/CMakeLists.txt +++ b/src/bsoncxx/test/CMakeLists.txt @@ -13,13 +13,13 @@ # limitations under the License. if(NOT BUILD_TESTING) - set_property(DIRECTORY PROPERTY EXCLUDE_FROM_ALL TRUE) + set_property(DIRECTORY PROPERTY EXCLUDE_FROM_ALL TRUE) endif() # Allow `#include ` include_directories(${THIRD_PARTY_SOURCE_DIR}/..) -file (GLOB src_bsoncxx_test_DIST_cpps RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp) +file(GLOB src_bsoncxx_test_DIST_cpps RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp) add_executable(test_bson ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp @@ -32,7 +32,7 @@ target_compile_definitions(test_bson PRIVATE ${libbson_definitions}) add_test(bson test_bson) -set_dist_list (src_bsoncxx_test_DIST - CMakeLists.txt - ${src_bsoncxx_test_DIST_cpps} +set_dist_list(src_bsoncxx_test_DIST + CMakeLists.txt + ${src_bsoncxx_test_DIST_cpps} ) diff --git a/src/bsoncxx/third_party/CMakeLists.txt b/src/bsoncxx/third_party/CMakeLists.txt index 61856adb74..f9639a2fd6 100644 --- a/src/bsoncxx/third_party/CMakeLists.txt +++ b/src/bsoncxx/third_party/CMakeLists.txt @@ -14,12 +14,11 @@ include(FetchContent) -if (BSONCXX_POLY_USE_MNMLSTC AND NOT BSONCXX_POLY_USE_SYSTEM_MNMLSTC) - - set (core-src "${CMAKE_CURRENT_BINARY_DIR}/_deps/core-src") - set (core-subbuild "${CMAKE_CURRENT_BINARY_DIR}/_deps/core-subbuild") - set (core-build "${CMAKE_CURRENT_BINARY_DIR}/_deps/core-build") - set (core-install "${CMAKE_CURRENT_BINARY_DIR}/_deps/core-install") +if(BSONCXX_POLY_USE_MNMLSTC AND NOT BSONCXX_POLY_USE_SYSTEM_MNMLSTC) + set(core-src "${CMAKE_CURRENT_BINARY_DIR}/_deps/core-src") + set(core-subbuild "${CMAKE_CURRENT_BINARY_DIR}/_deps/core-subbuild") + set(core-build "${CMAKE_CURRENT_BINARY_DIR}/_deps/core-build") + set(core-install "${CMAKE_CURRENT_BINARY_DIR}/_deps/core-install") FetchContent_Declare( EP_mnmlstc_core @@ -36,77 +35,82 @@ if (BSONCXX_POLY_USE_MNMLSTC AND NOT BSONCXX_POLY_USE_SYSTEM_MNMLSTC) FETCHCONTENT_UPDATES_DISCONNECTED ON ) - FetchContent_GetProperties (EP_mnmlstc_core) - - find_package (core NO_DEFAULT_PATH PATHS "${core-install}" QUIET) - - if (core_FOUND AND "$CACHE{INTERNAL_MONGOC_MNMLSTC_CORE_FOUND}") - # The mnmlstc/core library is already populated and up-to-date. - else () - if (NOT ep_mnmlstc_core_POPULATED) - message (STATUS "Downloading mnmlstc/core...") - FetchContent_Populate (EP_mnmlstc_core) - message (STATUS "Downloading mnmlstc/core... done.") - endif () - - message (STATUS "Configuring mnmlstc/core...") - execute_process ( - COMMAND - "${CMAKE_COMMAND}" - "-S" "${core-src}" - "-B" "${core-build}" - "-DCMAKE_INSTALL_PREFIX=${core-install}" - "-DBUILD_TESTING=OFF" - "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}" - "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}" - RESULT_VARIABLE retval + FetchContent_GetProperties(EP_mnmlstc_core) + + find_package(core NO_DEFAULT_PATH PATHS "${core-install}" QUIET) + + if(core_FOUND AND "$CACHE{INTERNAL_MONGOC_MNMLSTC_CORE_FOUND}") + # The mnmlstc/core library is already populated and up-to-date. + else() + if(NOT ep_mnmlstc_core_POPULATED) + message(STATUS "Downloading mnmlstc/core...") + FetchContent_Populate(EP_mnmlstc_core) + message(STATUS "Downloading mnmlstc/core... done.") + endif() + + message(STATUS "Configuring mnmlstc/core...") + execute_process( + COMMAND + "${CMAKE_COMMAND}" + "-S" "${core-src}" + "-B" "${core-build}" + "-DCMAKE_INSTALL_PREFIX=${core-install}" + "-DBUILD_TESTING=OFF" + "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}" + "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}" + RESULT_VARIABLE retval ) - if (NOT "${retval}" STREQUAL "0") - message (FATAL_ERROR "execute_process() fatal error: ${retval}") - endif () - message (STATUS "Configuring mnmlstc/core... done.") - - message (STATUS "Building mnmlstc/core...") - execute_process ( - COMMAND - "${CMAKE_COMMAND}" - --build "${core-build}" - --config "${CMAKE_BUILD_TYPE}" - RESULT_VARIABLE retval + + if(NOT "${retval}" STREQUAL "0") + message(FATAL_ERROR "execute_process() fatal error: ${retval}") + endif() + + message(STATUS "Configuring mnmlstc/core... done.") + + message(STATUS "Building mnmlstc/core...") + execute_process( + COMMAND + "${CMAKE_COMMAND}" + --build "${core-build}" + --config "${CMAKE_BUILD_TYPE}" + RESULT_VARIABLE retval ) - if (NOT "${retval}" STREQUAL "0") - message (FATAL_ERROR "execute_process() fatal error: ${retval}") - endif () - message (STATUS "Building mnmlstc/core... done.") - - message (STATUS "Installing mnmlstc/core...") - execute_process ( - COMMAND - "${CMAKE_COMMAND}" - --install "${core-build}" - --config "${CMAKE_BUILD_TYPE}" - RESULT_VARIABLE retval + + if(NOT "${retval}" STREQUAL "0") + message(FATAL_ERROR "execute_process() fatal error: ${retval}") + endif() + + message(STATUS "Building mnmlstc/core... done.") + + message(STATUS "Installing mnmlstc/core...") + execute_process( + COMMAND + "${CMAKE_COMMAND}" + --install "${core-build}" + --config "${CMAKE_BUILD_TYPE}" + RESULT_VARIABLE retval ) - if (NOT "${retval}" STREQUAL "0") - message (FATAL_ERROR "execute_process() fatal error: ${retval}") - endif () - message (STATUS "Installing mnmlstc/core... done.") - find_package (core REQUIRED NO_DEFAULT_PATH PATHS "${core-install}") + if(NOT "${retval}" STREQUAL "0") + message(FATAL_ERROR "execute_process() fatal error: ${retval}") + endif() + + message(STATUS "Installing mnmlstc/core... done.") + + find_package(core REQUIRED NO_DEFAULT_PATH PATHS "${core-install}") # Ensure the mnmlstc/core CMake configuration is also (re)configured if the cache is fresh. - set (INTERNAL_MONGOC_MNMLSTC_CORE_FOUND TRUE CACHE INTERNAL "") - endif () + set(INTERNAL_MONGOC_MNMLSTC_CORE_FOUND TRUE CACHE INTERNAL "") + endif() - set (CORE_INCLUDE_DIR "${CORE_INCLUDE_DIR}" PARENT_SCOPE) + set(CORE_INCLUDE_DIR "${CORE_INCLUDE_DIR}" PARENT_SCOPE) - install ( + install( DIRECTORY "${core-install}/include/" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/bsoncxx/v_noabi/bsoncxx/third_party/mnmlstc" ) - endif() -set_dist_list (src_bsoncxx_third_party_DIST - CMakeLists.txt +set_dist_list(src_bsoncxx_third_party_DIST + CMakeLists.txt ) diff --git a/src/mongocxx/CMakeLists.txt b/src/mongocxx/CMakeLists.txt index 8d1c9a5c37..f0eaedc61e 100644 --- a/src/mongocxx/CMakeLists.txt +++ b/src/mongocxx/CMakeLists.txt @@ -14,11 +14,11 @@ project(MONGOCXX) -ParseVersion (${BUILD_VERSION} MONGOCXX) +ParseVersion(${BUILD_VERSION} MONGOCXX) set(MONGOCXX_VERSION_NO_EXTRA ${MONGOCXX_VERSION_MAJOR}.${MONGOCXX_VERSION_MINOR}.${MONGOCXX_VERSION_PATCH}) set(MONGOCXX_VERSION ${MONGOCXX_VERSION_NO_EXTRA}${MONGOCXX_VERSION_EXTRA}) -message ("mongocxx version: ${MONGOCXX_VERSION}") +message("mongocxx version: ${MONGOCXX_VERSION}") option(MONGOCXX_ENABLE_SSL "Enable SSL - if the underlying C driver offers it" ON) option(MONGOCXX_ENABLE_SLOW_TESTS "Run slow tests when invoking the the test target" OFF) @@ -28,45 +28,47 @@ set(MONGOCXX_OUTPUT_BASENAME "mongocxx" CACHE STRING "Output mongocxx library ba set(mongocxx_pkg_dep "") if(TARGET mongoc_shared OR TARGET mongoc_static) - # If these targets exist, then libmongoc has already been included as a project - # sub-directory - message ("found libmongoc targets declared in current build scope; version not checked") + # If these targets exist, then libmongoc has already been included as a project + # sub-directory + message("found libmongoc targets declared in current build scope; version not checked") - if(NOT MONGOCXX_LINK_WITH_STATIC_MONGOC) - set(libmongoc_target mongoc_shared) - else() - set(libmongoc_target mongoc_static) - endif() - - set(mongocxx_pkg_dep "find_dependency(mongoc-${LIBMONGOC_REQUIRED_ABI_VERSION} REQUIRED)") -else() - # Attempt to find libmongoc by new package name (without lib). - find_package(mongoc-${LIBMONGOC_REQUIRED_ABI_VERSION} ${LIBMONGOC_REQUIRED_VERSION} QUIET) - - if(mongoc-${LIBMONGOC_REQUIRED_ABI_VERSION}_FOUND) - message ("found libmongoc version ${mongoc-${LIBMONGOC_REQUIRED_ABI_VERSION}_VERSION}") if(NOT MONGOCXX_LINK_WITH_STATIC_MONGOC) - set(libmongoc_target mongo::mongoc_shared) + set(libmongoc_target mongoc_shared) else() - set(libmongoc_target mongo::mongoc_static) + set(libmongoc_target mongoc_static) endif() + set(mongocxx_pkg_dep "find_dependency(mongoc-${LIBMONGOC_REQUIRED_ABI_VERSION} REQUIRED)") - else() - # Require package of old libmongoc name (with lib). - if(NOT MONGOCXX_LINK_WITH_STATIC_MONGOC) - find_package(libmongoc-${LIBMONGOC_REQUIRED_ABI_VERSION} ${LIBMONGOC_REQUIRED_VERSION} REQUIRED) - message ("found libmongoc version ${MONGOC_VERSION}") - set(libmongoc_target ${MONGOC_LIBRARIES}) - set(libmongoc_definitions ${MONGOC_DEFINITIONS}) - set(mongocxx_pkg_dep "find_dependency(libmongoc-${LIBMONGOC_REQUIRED_ABI_VERSION} REQUIRED)") +else() + # Attempt to find libmongoc by new package name (without lib). + find_package(mongoc-${LIBMONGOC_REQUIRED_ABI_VERSION} ${LIBMONGOC_REQUIRED_VERSION} QUIET) + + if(mongoc-${LIBMONGOC_REQUIRED_ABI_VERSION}_FOUND) + message("found libmongoc version ${mongoc-${LIBMONGOC_REQUIRED_ABI_VERSION}_VERSION}") + + if(NOT MONGOCXX_LINK_WITH_STATIC_MONGOC) + set(libmongoc_target mongo::mongoc_shared) + else() + set(libmongoc_target mongo::mongoc_static) + endif() + + set(mongocxx_pkg_dep "find_dependency(mongoc-${LIBMONGOC_REQUIRED_ABI_VERSION} REQUIRED)") else() - find_package(libmongoc-static-${LIBMONGOC_REQUIRED_ABI_VERSION} ${LIBMONGOC_REQUIRED_VERSION} REQUIRED) - message ("found libmongoc version ${MONGOC_STATIC_VERSION}") - set(libmongoc_target ${MONGOC_STATIC_LIBRARIES}) - set(libmongoc_definitions ${MONGOC_STATIC_DEFINITIONS}) - set(mongocxx_pkg_dep "find_dependency(libmongoc-static-${LIBMONGOC_REQUIRED_ABI_VERSION} REQUIRED)") + # Require package of old libmongoc name (with lib). + if(NOT MONGOCXX_LINK_WITH_STATIC_MONGOC) + find_package(libmongoc-${LIBMONGOC_REQUIRED_ABI_VERSION} ${LIBMONGOC_REQUIRED_VERSION} REQUIRED) + message("found libmongoc version ${MONGOC_VERSION}") + set(libmongoc_target ${MONGOC_LIBRARIES}) + set(libmongoc_definitions ${MONGOC_DEFINITIONS}) + set(mongocxx_pkg_dep "find_dependency(libmongoc-${LIBMONGOC_REQUIRED_ABI_VERSION} REQUIRED)") + else() + find_package(libmongoc-static-${LIBMONGOC_REQUIRED_ABI_VERSION} ${LIBMONGOC_REQUIRED_VERSION} REQUIRED) + message("found libmongoc version ${MONGOC_STATIC_VERSION}") + set(libmongoc_target ${MONGOC_STATIC_LIBRARIES}) + set(libmongoc_definitions ${MONGOC_STATIC_DEFINITIONS}) + set(mongocxx_pkg_dep "find_dependency(libmongoc-static-${LIBMONGOC_REQUIRED_ABI_VERSION} REQUIRED)") + endif() endif() - endif() endif() add_subdirectory(lib/mongocxx/v_noabi/mongocxx/config) @@ -171,7 +173,6 @@ set(mongocxx_sources # library does not get installed, but the tests link against it instead of the normal library. The # only difference between the libraries is that MONGOCXX_TESTING is defined in the testing-only # library (this define enables special testing-only behavior). - include(MongocxxUtil) if(MONGOCXX_BUILD_SHARED) @@ -186,23 +187,26 @@ endif() if(MONGOCXX_BUILD_SHARED) set(MONGOCXX_LIBRARY_FOR_EXAMPLES "mongocxx_shared" CACHE INTERNAL "") + if(ENABLE_TESTS) - mongocxx_add_library(mongocxx_mocked "mongocxx-mocked" SHARED) + mongocxx_add_library(mongocxx_mocked "mongocxx-mocked" SHARED) endif() else() set(MONGOCXX_LIBRARY_FOR_EXAMPLES "mongocxx_static" CACHE INTERNAL "") + if(ENABLE_TESTS) - mongocxx_add_library(mongocxx_mocked "mongocxx-mocked" STATIC) + mongocxx_add_library(mongocxx_mocked "mongocxx-mocked" STATIC) endif() endif() + if(ENABLE_TESTS) - target_link_libraries(mongocxx_mocked PUBLIC bsoncxx_testing) - target_compile_definitions(mongocxx_mocked PUBLIC MONGOCXX_TESTING) - if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - target_compile_options(mongocxx_mocked PRIVATE /bigobj) - endif() -endif() + target_link_libraries(mongocxx_mocked PUBLIC bsoncxx_testing) + target_compile_definitions(mongocxx_mocked PUBLIC MONGOCXX_TESTING) + if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + target_compile_options(mongocxx_mocked PRIVATE /bigobj) + endif() +endif() install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} @@ -221,7 +225,7 @@ set(PACKAGE_LIBRARIES mongocxx) include(CMakePackageConfigHelpers) -set (libdir "\${prefix}/${CMAKE_INSTALL_LIBDIR}") +set(libdir "\${prefix}/${CMAKE_INSTALL_LIBDIR}") if(MONGOCXX_BUILD_SHARED) configure_file( @@ -252,6 +256,7 @@ if(MONGOCXX_BUILD_STATIC) endif() set(mongocxx_target_list "") + if(MONGOCXX_BUILD_SHARED) mongocxx_install_deprecated_cmake(mongocxx) list(APPEND mongocxx_target_list mongocxx_shared) @@ -261,150 +266,151 @@ if(MONGOCXX_BUILD_STATIC) mongocxx_install_deprecated_cmake(mongocxx-static) list(APPEND mongocxx_target_list mongocxx_static) endif() + mongocxx_install("${mongocxx_target_list}" "${mongocxx_pkg_dep}") if(ENABLE_TESTS) - add_subdirectory(test) + add_subdirectory(test) endif() -set_local_dist (src_mongocxx_lib_v_noabi_DIST_local - CMakeLists.txt - lib/mongocxx/v_noabi/mongocxx/bulk_write.cpp - lib/mongocxx/v_noabi/mongocxx/change_stream.cpp - lib/mongocxx/v_noabi/mongocxx/client.cpp - lib/mongocxx/v_noabi/mongocxx/client_encryption.cpp - lib/mongocxx/v_noabi/mongocxx/client_session.cpp - cmake/mongocxx-config.cmake.in - cmake/libmongocxx-config.cmake.in - cmake/libmongocxx-static-config.cmake.in - cmake/libmongocxx-static.pc.in - cmake/libmongocxx.pc.in - lib/mongocxx/v_noabi/mongocxx/collection.cpp - lib/mongocxx/v_noabi/mongocxx/cursor.cpp - lib/mongocxx/v_noabi/mongocxx/database.cpp - lib/mongocxx/v_noabi/mongocxx/events/command_failed_event.cpp - lib/mongocxx/v_noabi/mongocxx/events/command_started_event.cpp - lib/mongocxx/v_noabi/mongocxx/events/command_succeeded_event.cpp - lib/mongocxx/v_noabi/mongocxx/events/heartbeat_failed_event.cpp - lib/mongocxx/v_noabi/mongocxx/events/heartbeat_started_event.cpp - lib/mongocxx/v_noabi/mongocxx/events/heartbeat_succeeded_event.cpp - lib/mongocxx/v_noabi/mongocxx/events/server_changed_event.cpp - lib/mongocxx/v_noabi/mongocxx/events/server_closed_event.cpp - lib/mongocxx/v_noabi/mongocxx/events/server_description.cpp - lib/mongocxx/v_noabi/mongocxx/events/server_opening_event.cpp - lib/mongocxx/v_noabi/mongocxx/events/topology_changed_event.cpp - lib/mongocxx/v_noabi/mongocxx/events/topology_closed_event.cpp - lib/mongocxx/v_noabi/mongocxx/events/topology_description.cpp - lib/mongocxx/v_noabi/mongocxx/events/topology_opening_event.cpp - lib/mongocxx/v_noabi/mongocxx/exception/error_code.cpp - lib/mongocxx/v_noabi/mongocxx/exception/operation_exception.cpp - lib/mongocxx/v_noabi/mongocxx/exception/private/mongoc_error.hh - lib/mongocxx/v_noabi/mongocxx/exception/server_error_code.cpp - lib/mongocxx/v_noabi/mongocxx/gridfs/bucket.cpp - lib/mongocxx/v_noabi/mongocxx/gridfs/downloader.cpp - lib/mongocxx/v_noabi/mongocxx/gridfs/private/bucket.hh - lib/mongocxx/v_noabi/mongocxx/gridfs/private/downloader.hh - lib/mongocxx/v_noabi/mongocxx/gridfs/private/uploader.hh - lib/mongocxx/v_noabi/mongocxx/gridfs/uploader.cpp - lib/mongocxx/v_noabi/mongocxx/hint.cpp - lib/mongocxx/v_noabi/mongocxx/index_model.cpp - lib/mongocxx/v_noabi/mongocxx/index_view.cpp - lib/mongocxx/v_noabi/mongocxx/instance.cpp - lib/mongocxx/v_noabi/mongocxx/logger.cpp - lib/mongocxx/v_noabi/mongocxx/model/delete_many.cpp - lib/mongocxx/v_noabi/mongocxx/model/delete_one.cpp - lib/mongocxx/v_noabi/mongocxx/model/insert_one.cpp - lib/mongocxx/v_noabi/mongocxx/model/replace_one.cpp - lib/mongocxx/v_noabi/mongocxx/model/update_many.cpp - lib/mongocxx/v_noabi/mongocxx/model/update_one.cpp - lib/mongocxx/v_noabi/mongocxx/model/write.cpp - lib/mongocxx/v_noabi/mongocxx/options/aggregate.cpp - lib/mongocxx/v_noabi/mongocxx/options/apm.cpp - lib/mongocxx/v_noabi/mongocxx/options/auto_encryption.cpp - lib/mongocxx/v_noabi/mongocxx/options/bulk_write.cpp - lib/mongocxx/v_noabi/mongocxx/options/change_stream.cpp - lib/mongocxx/v_noabi/mongocxx/options/client.cpp - lib/mongocxx/v_noabi/mongocxx/options/client_encryption.cpp - lib/mongocxx/v_noabi/mongocxx/options/client_session.cpp - lib/mongocxx/v_noabi/mongocxx/options/count.cpp - lib/mongocxx/v_noabi/mongocxx/options/create_collection.cpp - lib/mongocxx/v_noabi/mongocxx/options/data_key.cpp - lib/mongocxx/v_noabi/mongocxx/options/delete.cpp - lib/mongocxx/v_noabi/mongocxx/options/distinct.cpp - lib/mongocxx/v_noabi/mongocxx/options/encrypt.cpp - lib/mongocxx/v_noabi/mongocxx/options/estimated_document_count.cpp - lib/mongocxx/v_noabi/mongocxx/options/find.cpp - lib/mongocxx/v_noabi/mongocxx/options/find_one_and_delete.cpp - lib/mongocxx/v_noabi/mongocxx/options/find_one_and_replace.cpp - lib/mongocxx/v_noabi/mongocxx/options/find_one_and_update.cpp - lib/mongocxx/v_noabi/mongocxx/options/gridfs/bucket.cpp - lib/mongocxx/v_noabi/mongocxx/options/gridfs/upload.cpp - lib/mongocxx/v_noabi/mongocxx/options/index.cpp - lib/mongocxx/v_noabi/mongocxx/options/index_view.cpp - lib/mongocxx/v_noabi/mongocxx/options/insert.cpp - lib/mongocxx/v_noabi/mongocxx/options/pool.cpp - lib/mongocxx/v_noabi/mongocxx/options/private/apm.hh - lib/mongocxx/v_noabi/mongocxx/options/private/server_api.hh - lib/mongocxx/v_noabi/mongocxx/options/private/ssl.hh - lib/mongocxx/v_noabi/mongocxx/options/private/transaction.hh - lib/mongocxx/v_noabi/mongocxx/options/range.cpp - lib/mongocxx/v_noabi/mongocxx/options/replace.cpp - lib/mongocxx/v_noabi/mongocxx/options/rewrap_many_datakey.cpp - lib/mongocxx/v_noabi/mongocxx/options/server_api.cpp - lib/mongocxx/v_noabi/mongocxx/options/tls.cpp - lib/mongocxx/v_noabi/mongocxx/options/transaction.cpp - lib/mongocxx/v_noabi/mongocxx/options/update.cpp - lib/mongocxx/v_noabi/mongocxx/pipeline.cpp - lib/mongocxx/v_noabi/mongocxx/pool.cpp - lib/mongocxx/v_noabi/mongocxx/private/append_aggregate_options.hh - lib/mongocxx/v_noabi/mongocxx/private/bulk_write.hh - lib/mongocxx/v_noabi/mongocxx/private/change_stream.hh - lib/mongocxx/v_noabi/mongocxx/private/client.hh - lib/mongocxx/v_noabi/mongocxx/private/client_encryption.hh - lib/mongocxx/v_noabi/mongocxx/private/client_session.hh - lib/mongocxx/v_noabi/mongocxx/private/collection.hh - lib/mongocxx/v_noabi/mongocxx/private/conversions.cpp - lib/mongocxx/v_noabi/mongocxx/private/conversions.hh - lib/mongocxx/v_noabi/mongocxx/private/cursor.hh - lib/mongocxx/v_noabi/mongocxx/private/database.hh - lib/mongocxx/v_noabi/mongocxx/private/index_view.hh - lib/mongocxx/v_noabi/mongocxx/private/libbson.cpp - lib/mongocxx/v_noabi/mongocxx/private/libbson.hh - lib/mongocxx/v_noabi/mongocxx/private/libmongoc.cpp - lib/mongocxx/v_noabi/mongocxx/private/libmongoc.hh - lib/mongocxx/v_noabi/mongocxx/private/libmongoc_symbols.hh - lib/mongocxx/v_noabi/mongocxx/private/numeric_casting.cpp - lib/mongocxx/v_noabi/mongocxx/private/numeric_casting.hh - lib/mongocxx/v_noabi/mongocxx/private/pipeline.hh - lib/mongocxx/v_noabi/mongocxx/private/pool.hh - lib/mongocxx/v_noabi/mongocxx/private/read_concern.hh - lib/mongocxx/v_noabi/mongocxx/private/read_preference.hh - lib/mongocxx/v_noabi/mongocxx/private/search_index_model.hh - lib/mongocxx/v_noabi/mongocxx/private/search_index_view.hh - lib/mongocxx/v_noabi/mongocxx/private/uri.hh - lib/mongocxx/v_noabi/mongocxx/private/write_concern.hh - lib/mongocxx/v_noabi/mongocxx/read_concern.cpp - lib/mongocxx/v_noabi/mongocxx/read_preference.cpp - lib/mongocxx/v_noabi/mongocxx/result/bulk_write.cpp - lib/mongocxx/v_noabi/mongocxx/result/delete.cpp - lib/mongocxx/v_noabi/mongocxx/result/gridfs/upload.cpp - lib/mongocxx/v_noabi/mongocxx/result/insert_many.cpp - lib/mongocxx/v_noabi/mongocxx/result/insert_one.cpp - lib/mongocxx/v_noabi/mongocxx/result/replace_one.cpp - lib/mongocxx/v_noabi/mongocxx/result/rewrap_many_datakey.cpp - lib/mongocxx/v_noabi/mongocxx/result/update.cpp - lib/mongocxx/v_noabi/mongocxx/search_index_model.cpp - lib/mongocxx/v_noabi/mongocxx/search_index_view.cpp - lib/mongocxx/v_noabi/mongocxx/test_util/client_helpers.cpp - lib/mongocxx/v_noabi/mongocxx/test_util/client_helpers.hh - lib/mongocxx/v_noabi/mongocxx/test_util/export_for_testing.hh - lib/mongocxx/v_noabi/mongocxx/test_util/mock.hh - lib/mongocxx/v_noabi/mongocxx/uri.cpp - lib/mongocxx/v_noabi/mongocxx/validation_criteria.cpp - lib/mongocxx/v_noabi/mongocxx/write_concern.cpp +set_local_dist(src_mongocxx_lib_v_noabi_DIST_local + CMakeLists.txt + lib/mongocxx/v_noabi/mongocxx/bulk_write.cpp + lib/mongocxx/v_noabi/mongocxx/change_stream.cpp + lib/mongocxx/v_noabi/mongocxx/client.cpp + lib/mongocxx/v_noabi/mongocxx/client_encryption.cpp + lib/mongocxx/v_noabi/mongocxx/client_session.cpp + cmake/mongocxx-config.cmake.in + cmake/libmongocxx-config.cmake.in + cmake/libmongocxx-static-config.cmake.in + cmake/libmongocxx-static.pc.in + cmake/libmongocxx.pc.in + lib/mongocxx/v_noabi/mongocxx/collection.cpp + lib/mongocxx/v_noabi/mongocxx/cursor.cpp + lib/mongocxx/v_noabi/mongocxx/database.cpp + lib/mongocxx/v_noabi/mongocxx/events/command_failed_event.cpp + lib/mongocxx/v_noabi/mongocxx/events/command_started_event.cpp + lib/mongocxx/v_noabi/mongocxx/events/command_succeeded_event.cpp + lib/mongocxx/v_noabi/mongocxx/events/heartbeat_failed_event.cpp + lib/mongocxx/v_noabi/mongocxx/events/heartbeat_started_event.cpp + lib/mongocxx/v_noabi/mongocxx/events/heartbeat_succeeded_event.cpp + lib/mongocxx/v_noabi/mongocxx/events/server_changed_event.cpp + lib/mongocxx/v_noabi/mongocxx/events/server_closed_event.cpp + lib/mongocxx/v_noabi/mongocxx/events/server_description.cpp + lib/mongocxx/v_noabi/mongocxx/events/server_opening_event.cpp + lib/mongocxx/v_noabi/mongocxx/events/topology_changed_event.cpp + lib/mongocxx/v_noabi/mongocxx/events/topology_closed_event.cpp + lib/mongocxx/v_noabi/mongocxx/events/topology_description.cpp + lib/mongocxx/v_noabi/mongocxx/events/topology_opening_event.cpp + lib/mongocxx/v_noabi/mongocxx/exception/error_code.cpp + lib/mongocxx/v_noabi/mongocxx/exception/operation_exception.cpp + lib/mongocxx/v_noabi/mongocxx/exception/private/mongoc_error.hh + lib/mongocxx/v_noabi/mongocxx/exception/server_error_code.cpp + lib/mongocxx/v_noabi/mongocxx/gridfs/bucket.cpp + lib/mongocxx/v_noabi/mongocxx/gridfs/downloader.cpp + lib/mongocxx/v_noabi/mongocxx/gridfs/private/bucket.hh + lib/mongocxx/v_noabi/mongocxx/gridfs/private/downloader.hh + lib/mongocxx/v_noabi/mongocxx/gridfs/private/uploader.hh + lib/mongocxx/v_noabi/mongocxx/gridfs/uploader.cpp + lib/mongocxx/v_noabi/mongocxx/hint.cpp + lib/mongocxx/v_noabi/mongocxx/index_model.cpp + lib/mongocxx/v_noabi/mongocxx/index_view.cpp + lib/mongocxx/v_noabi/mongocxx/instance.cpp + lib/mongocxx/v_noabi/mongocxx/logger.cpp + lib/mongocxx/v_noabi/mongocxx/model/delete_many.cpp + lib/mongocxx/v_noabi/mongocxx/model/delete_one.cpp + lib/mongocxx/v_noabi/mongocxx/model/insert_one.cpp + lib/mongocxx/v_noabi/mongocxx/model/replace_one.cpp + lib/mongocxx/v_noabi/mongocxx/model/update_many.cpp + lib/mongocxx/v_noabi/mongocxx/model/update_one.cpp + lib/mongocxx/v_noabi/mongocxx/model/write.cpp + lib/mongocxx/v_noabi/mongocxx/options/aggregate.cpp + lib/mongocxx/v_noabi/mongocxx/options/apm.cpp + lib/mongocxx/v_noabi/mongocxx/options/auto_encryption.cpp + lib/mongocxx/v_noabi/mongocxx/options/bulk_write.cpp + lib/mongocxx/v_noabi/mongocxx/options/change_stream.cpp + lib/mongocxx/v_noabi/mongocxx/options/client.cpp + lib/mongocxx/v_noabi/mongocxx/options/client_encryption.cpp + lib/mongocxx/v_noabi/mongocxx/options/client_session.cpp + lib/mongocxx/v_noabi/mongocxx/options/count.cpp + lib/mongocxx/v_noabi/mongocxx/options/create_collection.cpp + lib/mongocxx/v_noabi/mongocxx/options/data_key.cpp + lib/mongocxx/v_noabi/mongocxx/options/delete.cpp + lib/mongocxx/v_noabi/mongocxx/options/distinct.cpp + lib/mongocxx/v_noabi/mongocxx/options/encrypt.cpp + lib/mongocxx/v_noabi/mongocxx/options/estimated_document_count.cpp + lib/mongocxx/v_noabi/mongocxx/options/find.cpp + lib/mongocxx/v_noabi/mongocxx/options/find_one_and_delete.cpp + lib/mongocxx/v_noabi/mongocxx/options/find_one_and_replace.cpp + lib/mongocxx/v_noabi/mongocxx/options/find_one_and_update.cpp + lib/mongocxx/v_noabi/mongocxx/options/gridfs/bucket.cpp + lib/mongocxx/v_noabi/mongocxx/options/gridfs/upload.cpp + lib/mongocxx/v_noabi/mongocxx/options/index.cpp + lib/mongocxx/v_noabi/mongocxx/options/index_view.cpp + lib/mongocxx/v_noabi/mongocxx/options/insert.cpp + lib/mongocxx/v_noabi/mongocxx/options/pool.cpp + lib/mongocxx/v_noabi/mongocxx/options/private/apm.hh + lib/mongocxx/v_noabi/mongocxx/options/private/server_api.hh + lib/mongocxx/v_noabi/mongocxx/options/private/ssl.hh + lib/mongocxx/v_noabi/mongocxx/options/private/transaction.hh + lib/mongocxx/v_noabi/mongocxx/options/range.cpp + lib/mongocxx/v_noabi/mongocxx/options/replace.cpp + lib/mongocxx/v_noabi/mongocxx/options/rewrap_many_datakey.cpp + lib/mongocxx/v_noabi/mongocxx/options/server_api.cpp + lib/mongocxx/v_noabi/mongocxx/options/tls.cpp + lib/mongocxx/v_noabi/mongocxx/options/transaction.cpp + lib/mongocxx/v_noabi/mongocxx/options/update.cpp + lib/mongocxx/v_noabi/mongocxx/pipeline.cpp + lib/mongocxx/v_noabi/mongocxx/pool.cpp + lib/mongocxx/v_noabi/mongocxx/private/append_aggregate_options.hh + lib/mongocxx/v_noabi/mongocxx/private/bulk_write.hh + lib/mongocxx/v_noabi/mongocxx/private/change_stream.hh + lib/mongocxx/v_noabi/mongocxx/private/client.hh + lib/mongocxx/v_noabi/mongocxx/private/client_encryption.hh + lib/mongocxx/v_noabi/mongocxx/private/client_session.hh + lib/mongocxx/v_noabi/mongocxx/private/collection.hh + lib/mongocxx/v_noabi/mongocxx/private/conversions.cpp + lib/mongocxx/v_noabi/mongocxx/private/conversions.hh + lib/mongocxx/v_noabi/mongocxx/private/cursor.hh + lib/mongocxx/v_noabi/mongocxx/private/database.hh + lib/mongocxx/v_noabi/mongocxx/private/index_view.hh + lib/mongocxx/v_noabi/mongocxx/private/libbson.cpp + lib/mongocxx/v_noabi/mongocxx/private/libbson.hh + lib/mongocxx/v_noabi/mongocxx/private/libmongoc.cpp + lib/mongocxx/v_noabi/mongocxx/private/libmongoc.hh + lib/mongocxx/v_noabi/mongocxx/private/libmongoc_symbols.hh + lib/mongocxx/v_noabi/mongocxx/private/numeric_casting.cpp + lib/mongocxx/v_noabi/mongocxx/private/numeric_casting.hh + lib/mongocxx/v_noabi/mongocxx/private/pipeline.hh + lib/mongocxx/v_noabi/mongocxx/private/pool.hh + lib/mongocxx/v_noabi/mongocxx/private/read_concern.hh + lib/mongocxx/v_noabi/mongocxx/private/read_preference.hh + lib/mongocxx/v_noabi/mongocxx/private/search_index_model.hh + lib/mongocxx/v_noabi/mongocxx/private/search_index_view.hh + lib/mongocxx/v_noabi/mongocxx/private/uri.hh + lib/mongocxx/v_noabi/mongocxx/private/write_concern.hh + lib/mongocxx/v_noabi/mongocxx/read_concern.cpp + lib/mongocxx/v_noabi/mongocxx/read_preference.cpp + lib/mongocxx/v_noabi/mongocxx/result/bulk_write.cpp + lib/mongocxx/v_noabi/mongocxx/result/delete.cpp + lib/mongocxx/v_noabi/mongocxx/result/gridfs/upload.cpp + lib/mongocxx/v_noabi/mongocxx/result/insert_many.cpp + lib/mongocxx/v_noabi/mongocxx/result/insert_one.cpp + lib/mongocxx/v_noabi/mongocxx/result/replace_one.cpp + lib/mongocxx/v_noabi/mongocxx/result/rewrap_many_datakey.cpp + lib/mongocxx/v_noabi/mongocxx/result/update.cpp + lib/mongocxx/v_noabi/mongocxx/search_index_model.cpp + lib/mongocxx/v_noabi/mongocxx/search_index_view.cpp + lib/mongocxx/v_noabi/mongocxx/test_util/client_helpers.cpp + lib/mongocxx/v_noabi/mongocxx/test_util/client_helpers.hh + lib/mongocxx/v_noabi/mongocxx/test_util/export_for_testing.hh + lib/mongocxx/v_noabi/mongocxx/test_util/mock.hh + lib/mongocxx/v_noabi/mongocxx/uri.cpp + lib/mongocxx/v_noabi/mongocxx/validation_criteria.cpp + lib/mongocxx/v_noabi/mongocxx/write_concern.cpp ) -set_local_dist (src_mongocxx_include_v_noabi_DIST_local +set_local_dist(src_mongocxx_include_v_noabi_DIST_local include/mongocxx/v_noabi/mongocxx/bulk_write.hpp include/mongocxx/v_noabi/mongocxx/change_stream.hpp include/mongocxx/v_noabi/mongocxx/client_encryption.hpp @@ -510,10 +516,10 @@ set_local_dist (src_mongocxx_include_v_noabi_DIST_local include/mongocxx/v_noabi/mongocxx/write_type.hpp ) -set (src_mongocxx_DIST - ${src_mongocxx_lib_v_noabi_DIST_local} - ${src_mongocxx_include_v_noabi_DIST_local} - ${src_mongocxx_config_DIST} - ${src_mongocxx_test_DIST} - PARENT_SCOPE +set(src_mongocxx_DIST + ${src_mongocxx_lib_v_noabi_DIST_local} + ${src_mongocxx_include_v_noabi_DIST_local} + ${src_mongocxx_config_DIST} + ${src_mongocxx_test_DIST} + PARENT_SCOPE ) diff --git a/src/mongocxx/lib/mongocxx/v_noabi/mongocxx/config/CMakeLists.txt b/src/mongocxx/lib/mongocxx/v_noabi/mongocxx/config/CMakeLists.txt index 1faff7fe46..df93e7b257 100644 --- a/src/mongocxx/lib/mongocxx/v_noabi/mongocxx/config/CMakeLists.txt +++ b/src/mongocxx/lib/mongocxx/v_noabi/mongocxx/config/CMakeLists.txt @@ -22,17 +22,17 @@ configure_file( ${CMAKE_CURRENT_BINARY_DIR}/config.hpp ) -if (DEFINED CMAKE_CXX_COMPILER_ID) - set (MONGOCXX_COMPILER_ID "${CMAKE_CXX_COMPILER_ID}") -else () - set (MONGOCXX_COMPILER_ID "Unknown") -endif () +if(DEFINED CMAKE_CXX_COMPILER_ID) + set(MONGOCXX_COMPILER_ID "${CMAKE_CXX_COMPILER_ID}") +else() + set(MONGOCXX_COMPILER_ID "Unknown") +endif() -if (DEFINED CMAKE_CXX_COMPILER_VERSION) - set (MONGOCXX_COMPILER_VERSION "${CMAKE_CXX_COMPILER_VERSION}") -else () - set (MONGOCXX_COMPILER_VERSION "Unknown") -endif () +if(DEFINED CMAKE_CXX_COMPILER_VERSION) + set(MONGOCXX_COMPILER_VERSION "${CMAKE_CXX_COMPILER_VERSION}") +else() + set(MONGOCXX_COMPILER_VERSION "Unknown") +endif() configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/private/config.hh.in @@ -46,11 +46,11 @@ install(FILES COMPONENT dev ) -set_dist_list (src_mongocxx_config_DIST - CMakeLists.txt - config.hpp.in - private/config.hh.in - private/postlude.hh - private/prelude.hh - version.hpp.in +set_dist_list(src_mongocxx_config_DIST + CMakeLists.txt + config.hpp.in + private/config.hh.in + private/postlude.hh + private/prelude.hh + version.hpp.in ) diff --git a/src/mongocxx/test/CMakeLists.txt b/src/mongocxx/test/CMakeLists.txt index 1a70f56eb9..01ec1226b6 100644 --- a/src/mongocxx/test/CMakeLists.txt +++ b/src/mongocxx/test/CMakeLists.txt @@ -13,7 +13,7 @@ # limitations under the License. if(NOT BUILD_TESTING) - set_property(DIRECTORY PROPERTY EXCLUDE_FROM_ALL TRUE) + set_property(DIRECTORY PROPERTY EXCLUDE_FROM_ALL TRUE) endif() # Allow `#include ` @@ -106,13 +106,13 @@ find_package(Threads REQUIRED) target_link_libraries(test_driver Threads::Threads) add_executable(test_logging - ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp - logging.cpp + ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp + logging.cpp ) add_executable(test_instance - ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp - instance.cpp + ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp + instance.cpp ) add_executable(test_crud_specs @@ -130,10 +130,10 @@ add_executable(test_gridfs_specs ) add_executable(test_client_side_encryption_specs - ${client_helpers_cpp} - ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp - spec/client_side_encryption.cpp - ${spec_test_common} + ${client_helpers_cpp} + ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp + spec/client_side_encryption.cpp + ${spec_test_common} ) add_executable(test_command_monitoring_specs @@ -184,7 +184,7 @@ add_executable(test_versioned_api ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp versioned_api.cpp ${spec_test_common} - ) +) target_link_libraries(test_driver mongocxx_mocked ${libmongoc_target}) target_link_libraries(test_logging mongocxx_mocked ${libmongoc_target}) @@ -218,9 +218,10 @@ target_compile_definitions(test_driver PRIVATE ${libmongoc_definitions}) target_compile_definitions(test_logging PRIVATE ${libmongoc_definitions}) target_compile_definitions(test_instance PRIVATE ${libmongoc_definitions}) -if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") +if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") target_compile_options(test_driver PRIVATE /bigobj) endif() + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") target_compile_options(test_driver PRIVATE -Wno-maybe-uninitialized) target_compile_options(test_retryable_reads_specs PRIVATE -Wno-maybe-uninitialized) @@ -241,8 +242,7 @@ add_test(versioned_api test_versioned_api) # Adding this as a test will run it as part of the RUN_TESTS command in MSVC. # Do not add, since we only test mongohouse on Linux. -#add_test(mongohouse_specs test_mongohouse_specs) - +# add_test(mongohouse_specs test_mongohouse_specs) set_tests_properties(crud_specs PROPERTIES ENVIRONMENT "CRUD_LEGACY_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/crud/legacy") @@ -255,123 +255,123 @@ set_tests_properties(client_side_encryption_specs PROPERTIES set_tests_properties(driver PROPERTIES ENVIRONMENT "CLIENT_SIDE_ENCRYPTION_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/client_side_encryption") set_property(TEST driver - APPEND PROPERTY ENVIRONMENT "URI_OPTIONS_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/uri-options") + APPEND PROPERTY ENVIRONMENT "URI_OPTIONS_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/uri-options") set_tests_properties(command_monitoring_specs PROPERTIES ENVIRONMENT "COMMAND_MONITORING_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/command-monitoring") set_tests_properties(transactions_specs PROPERTIES - ENVIRONMENT "TRANSACTIONS_LEGACY_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/transactions/legacy") + ENVIRONMENT "TRANSACTIONS_LEGACY_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/transactions/legacy") set_property(TEST transactions_specs - APPEND PROPERTY ENVIRONMENT "WITH_TRANSACTION_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/with_transaction") + APPEND PROPERTY ENVIRONMENT "WITH_TRANSACTION_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/with_transaction") set_tests_properties(retryable_reads_spec PROPERTIES - ENVIRONMENT "RETRYABLE_READS_LEGACY_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/retryable-reads/legacy") + ENVIRONMENT "RETRYABLE_READS_LEGACY_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/retryable-reads/legacy") set_tests_properties(read_write_concern_specs PROPERTIES - ENVIRONMENT "READ_WRITE_CONCERN_OPERATION_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/read-write-concern/operation") + ENVIRONMENT "READ_WRITE_CONCERN_OPERATION_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/read-write-concern/operation") set_property(TEST unified_format_spec APPEND PROPERTY ENVIRONMENT - "CHANGE_STREAMS_UNIFIED_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/change-streams/unified" - "CLIENT_SIDE_ENCRYPTION_UNIFIED_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/client_side_encryption/unified" - "COLLECTION_MANAGEMENT_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/collection-management" - "CRUD_UNIFIED_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/crud/unified" - "SESSION_UNIFIED_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/sessions/unified/" - "RETRYABLE_READS_UNIFIED_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/retryable-reads/unified/" - "RETRYABLE_WRITES_UNIFIED_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/retryable-writes/unified/" - "TRANSACTIONS_UNIFIED_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/transactions/unified" - "UNIFIED_FORMAT_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/unified-format" - "VERSIONED_API_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/versioned-api" - "INDEX_MANAGEMENT_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/index-management" + "CHANGE_STREAMS_UNIFIED_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/change-streams/unified" + "CLIENT_SIDE_ENCRYPTION_UNIFIED_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/client_side_encryption/unified" + "COLLECTION_MANAGEMENT_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/collection-management" + "CRUD_UNIFIED_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/crud/unified" + "SESSION_UNIFIED_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/sessions/unified/" + "RETRYABLE_READS_UNIFIED_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/retryable-reads/unified/" + "RETRYABLE_WRITES_UNIFIED_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/retryable-writes/unified/" + "TRANSACTIONS_UNIFIED_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/transactions/unified" + "UNIFIED_FORMAT_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/unified-format" + "VERSIONED_API_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/versioned-api" + "INDEX_MANAGEMENT_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/index-management" ) -if (MONGOCXX_ENABLE_SLOW_TESTS) - set_property(TEST driver - APPEND PROPERTY ENVIRONMENT "MONGOCXX_ENABLE_SLOW_TESTS=1") +if(MONGOCXX_ENABLE_SLOW_TESTS) + set_property(TEST driver + APPEND PROPERTY ENVIRONMENT "MONGOCXX_ENABLE_SLOW_TESTS=1") endif() -set_dist_list (src_mongocxx_test_DIST - CMakeLists.txt - bulk_write.cpp - change_streams.cpp - client.cpp - client_session.cpp - client_side_encryption.cpp - collection.cpp - collection_mocked.cpp - conversions.cpp - database.cpp - gridfs/bucket.cpp - gridfs/downloader.cpp - gridfs/uploader.cpp - hint.cpp - index_view.cpp - instance.cpp - logging.cpp - model/delete_many.cpp - model/delete_one.cpp - model/insert_one.cpp - model/replace_one.cpp - model/update_many.cpp - model/update_one.cpp - options/aggregate.cpp - options/bulk_write.cpp - options/client_session.cpp - options/count.cpp - options/create_collection.cpp - options/delete.cpp - options/distinct.cpp - options/find.cpp - options/find_one_and_delete.cpp - options/find_one_and_replace.cpp - options/find_one_and_update.cpp - options/gridfs/bucket.cpp - options/gridfs/upload.cpp - options/index.cpp - options/insert.cpp - options/pool.cpp - options/replace.cpp - options/update.cpp - pool.cpp - private/numeric_casting.cpp - private/scoped_bson_t.cpp - private/write_concern.cpp - read_concern.cpp - read_preference.cpp - result/bulk_write.cpp - result/delete.cpp - result/gridfs/upload.cpp - result/insert_one.cpp - result/replace_one.cpp - result/update.cpp - search_index_view.cpp - sdam-monitoring.cpp - spec/client_side_encryption.cpp - spec/command_monitoring.cpp - spec/crud.cpp - spec/gridfs.cpp - spec/initial_dns_seedlist_discovery.cpp - spec/mongohouse.cpp - spec/monitoring.cpp - spec/monitoring.hh - spec/operation.cpp - spec/operation.hh - spec/read_write_concern.cpp - spec/retryable-reads.cpp - spec/transactions.cpp - spec/unified_tests/assert.cpp - spec/unified_tests/assert.hh - spec/unified_tests/entity.cpp - spec/unified_tests/entity.hh - spec/unified_tests/operations.cpp - spec/unified_tests/operations.hh - spec/unified_tests/runner.cpp - spec/util.cpp - spec/util.hh - spec/uri_options.cpp - transactions.cpp - uri.cpp - validation_criteria.cpp - versioned_api.cpp - write_concern.cpp +set_dist_list(src_mongocxx_test_DIST + CMakeLists.txt + bulk_write.cpp + change_streams.cpp + client.cpp + client_session.cpp + client_side_encryption.cpp + collection.cpp + collection_mocked.cpp + conversions.cpp + database.cpp + gridfs/bucket.cpp + gridfs/downloader.cpp + gridfs/uploader.cpp + hint.cpp + index_view.cpp + instance.cpp + logging.cpp + model/delete_many.cpp + model/delete_one.cpp + model/insert_one.cpp + model/replace_one.cpp + model/update_many.cpp + model/update_one.cpp + options/aggregate.cpp + options/bulk_write.cpp + options/client_session.cpp + options/count.cpp + options/create_collection.cpp + options/delete.cpp + options/distinct.cpp + options/find.cpp + options/find_one_and_delete.cpp + options/find_one_and_replace.cpp + options/find_one_and_update.cpp + options/gridfs/bucket.cpp + options/gridfs/upload.cpp + options/index.cpp + options/insert.cpp + options/pool.cpp + options/replace.cpp + options/update.cpp + pool.cpp + private/numeric_casting.cpp + private/scoped_bson_t.cpp + private/write_concern.cpp + read_concern.cpp + read_preference.cpp + result/bulk_write.cpp + result/delete.cpp + result/gridfs/upload.cpp + result/insert_one.cpp + result/replace_one.cpp + result/update.cpp + search_index_view.cpp + sdam-monitoring.cpp + spec/client_side_encryption.cpp + spec/command_monitoring.cpp + spec/crud.cpp + spec/gridfs.cpp + spec/initial_dns_seedlist_discovery.cpp + spec/mongohouse.cpp + spec/monitoring.cpp + spec/monitoring.hh + spec/operation.cpp + spec/operation.hh + spec/read_write_concern.cpp + spec/retryable-reads.cpp + spec/transactions.cpp + spec/unified_tests/assert.cpp + spec/unified_tests/assert.hh + spec/unified_tests/entity.cpp + spec/unified_tests/entity.hh + spec/unified_tests/operations.cpp + spec/unified_tests/operations.hh + spec/unified_tests/runner.cpp + spec/util.cpp + spec/util.hh + spec/uri_options.cpp + transactions.cpp + uri.cpp + validation_criteria.cpp + versioned_api.cpp + write_concern.cpp ) From 8bc669a6b6d671f8ef6681cae08d7f887a6e4b9a Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Fri, 22 Sep 2023 12:21:24 -0500 Subject: [PATCH 04/11] Move package config commands into cmake/CMakeLists.txt --- cmake/BsoncxxUtil.cmake | 61 --------- cmake/MongocxxUtil.cmake | 61 --------- src/bsoncxx/CMakeLists.txt | 114 +++++------------ src/bsoncxx/cmake/CMakeLists.txt | 134 ++++++++++++++++++++ src/bsoncxx/cmake/libbsoncxx-static.pc.in | 4 +- src/bsoncxx/cmake/libbsoncxx.pc.in | 4 +- src/mongocxx/CMakeLists.txt | 83 ++++-------- src/mongocxx/cmake/CMakeLists.txt | 113 +++++++++++++++++ src/mongocxx/cmake/libmongocxx-static.pc.in | 4 +- src/mongocxx/cmake/libmongocxx.pc.in | 4 +- 10 files changed, 308 insertions(+), 274 deletions(-) create mode 100644 src/bsoncxx/cmake/CMakeLists.txt create mode 100644 src/mongocxx/cmake/CMakeLists.txt diff --git a/cmake/BsoncxxUtil.cmake b/cmake/BsoncxxUtil.cmake index 0335274e97..6e1de371d5 100644 --- a/cmake/BsoncxxUtil.cmake +++ b/cmake/BsoncxxUtil.cmake @@ -59,64 +59,3 @@ function(bsoncxx_add_library TARGET OUTPUT_NAME LINK_TYPE) STATIC_DEFINE BSONCXX_STATIC ) endfunction(bsoncxx_add_library) - -# Install the specified forms of the bsoncxx library (i.e., shared and/or static) -# with associated CMake config files -function(bsoncxx_install BSONCXX_TARGET_LIST BSONCXX_PKG_DEP BSONCXX_BOOST_PKG_DEP) - install(TARGETS - ${BSONCXX_TARGET_LIST} - EXPORT bsoncxx_targets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT runtime - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT runtime - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT dev - INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/bsoncxx/v_noabi - ) - - write_basic_package_version_file( - "${CMAKE_CURRENT_BINARY_DIR}/bsoncxx-config-version.cmake" - VERSION ${BSONCXX_VERSION} - COMPATIBILITY SameMajorVersion - ) - - configure_file(cmake/bsoncxx-config.cmake.in - "${CMAKE_CURRENT_BINARY_DIR}/bsoncxx-config.cmake" - @ONLY - ) - - install(EXPORT bsoncxx_targets - NAMESPACE mongo:: - FILE bsoncxx_targets.cmake - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/bsoncxx-${BSONCXX_VERSION} - ) - - install( - FILES - "${CMAKE_CURRENT_BINARY_DIR}/bsoncxx-config-version.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/bsoncxx-config.cmake" - DESTINATION - ${CMAKE_INSTALL_LIBDIR}/cmake/bsoncxx-${BSONCXX_VERSION} - COMPONENT - Devel - ) -endfunction(bsoncxx_install) - -function(bsoncxx_install_deprecated_cmake NAME) - set(PKG "lib${NAME}") - - configure_package_config_file( - cmake/${PKG}-config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/${PKG}-config.cmake - INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PKG}-${BSONCXX_VERSION} - PATH_VARS PACKAGE_INCLUDE_INSTALL_DIRS PACKAGE_LIBRARY_INSTALL_DIRS - ) - - write_basic_package_version_file( - ${CMAKE_CURRENT_BINARY_DIR}/${PKG}-config-version.cmake - VERSION ${BSONCXX_VERSION} - COMPATIBILITY SameMajorVersion - ) - - install( - FILES ${CMAKE_CURRENT_BINARY_DIR}/${PKG}-config.cmake ${CMAKE_CURRENT_BINARY_DIR}/${PKG}-config-version.cmake - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PKG}-${BSONCXX_VERSION} - ) -endfunction(bsoncxx_install_deprecated_cmake) diff --git a/cmake/MongocxxUtil.cmake b/cmake/MongocxxUtil.cmake index 399a35ca00..daf240b84b 100644 --- a/cmake/MongocxxUtil.cmake +++ b/cmake/MongocxxUtil.cmake @@ -47,64 +47,3 @@ function(mongocxx_add_library TARGET OUTPUT_NAME LINK_TYPE) STATIC_DEFINE MONGOCXX_STATIC ) endfunction(mongocxx_add_library) - -# Install the specified forms of the mongocxx library (i.e., shared and/or static) -# with associated CMake config files -function(mongocxx_install MONGOCXX_TARGET_LIST MONGOCXX_PKG_DEP) - install(TARGETS - ${MONGOCXX_TARGET_LIST} - EXPORT mongocxx_targets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT runtime - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT runtime - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT dev - INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/mongocxx/v_noabi - ) - - write_basic_package_version_file( - "${CMAKE_CURRENT_BINARY_DIR}/mongocxx-config-version.cmake" - VERSION ${MONGOCXX_VERSION} - COMPATIBILITY SameMajorVersion - ) - - configure_file(cmake/mongocxx-config.cmake.in - "${CMAKE_CURRENT_BINARY_DIR}/mongocxx-config.cmake" - @ONLY - ) - - install(EXPORT mongocxx_targets - NAMESPACE mongo:: - FILE mongocxx_targets.cmake - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/mongocxx-${MONGOCXX_VERSION} - ) - - install( - FILES - "${CMAKE_CURRENT_BINARY_DIR}/mongocxx-config-version.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/mongocxx-config.cmake" - DESTINATION - ${CMAKE_INSTALL_LIBDIR}/cmake/mongocxx-${MONGOCXX_VERSION} - COMPONENT - Devel - ) -endfunction(mongocxx_install) - -function(mongocxx_install_deprecated_cmake NAME) - set(PKG "lib${NAME}") - - configure_package_config_file( - cmake/${PKG}-config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/${PKG}-config.cmake - INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PKG}-${MONGOCXX_VERSION} - PATH_VARS PACKAGE_INCLUDE_INSTALL_DIRS PACKAGE_LIBRARY_INSTALL_DIRS - ) - - write_basic_package_version_file( - ${CMAKE_CURRENT_BINARY_DIR}/${PKG}-config-version.cmake - VERSION ${MONGOCXX_VERSION} - COMPATIBILITY SameMajorVersion - ) - - install( - FILES ${CMAKE_CURRENT_BINARY_DIR}/${PKG}-config.cmake ${CMAKE_CURRENT_BINARY_DIR}/${PKG}-config-version.cmake - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PKG}-${MONGOCXX_VERSION} - ) -endfunction(mongocxx_install_deprecated_cmake) diff --git a/src/bsoncxx/CMakeLists.txt b/src/bsoncxx/CMakeLists.txt index 8698080449..08e4aa2e65 100644 --- a/src/bsoncxx/CMakeLists.txt +++ b/src/bsoncxx/CMakeLists.txt @@ -68,27 +68,13 @@ if(BSONCXX_POLY_USE_STD_EXPERIMENTAL AND CMAKE_CXX_STANDARD LESS 14) message(FATAL_ERROR "Can only use BSONCXX_POLY_USE_STD_EXPERIMENTAL if CMAKE_CXX_STANDARD is 14 or higher") endif() -set(BSONCXX_POLY_MNMLSTC_DEPRECATED_INCLUDE_DIRS "") -set(BSONCXX_POLY_MNMLSTC_PKGCONFIG_INCLUDE_DIRS "") -set(BSONCXX_POLY_MNMLSTC_PKGCONFIG_STATIC_INCLUDE_DIRS "") - -if(BSONCXX_POLY_USE_MNMLSTC AND NOT BSONCXX_POLY_USE_SYSTEM_MNMLSTC) - # For deprecated CMake package config files. - set(BSONCXX_POLY_MNMLSTC_DEPRECATED_INCLUDE_DIRS - "${CMAKE_INSTALL_INCLUDEDIR}/bsoncxx/v_noabi/bsoncxx/third_party/mnmlstc" - ) +set(BSONCXX_BOOST_PKG_DEP "") # Required by bsoncxx-config.cmake.in. - # For pkg-config files. Trailing space to separate cflags. - set(BSONCXX_POLY_MNMLSTC_PKGCONFIG_INCLUDE_DIRS - [[-I${includedir}/bsoncxx/v_noabi/bsoncxx/third_party/mnmlstc ]] - ) - set(BSONCXX_POLY_MNMLSTC_PKGCONFIG_STATIC_INCLUDE_DIRS - [[-I${includedir}/bsoncxx/v_noabi/bsoncxx/third_party/mnmlstc ]] - ) +if(BSONCXX_POLY_USE_BOOST) + set(BSONCXX_BOOST_PKG_DEP "find_dependency(Boost 1.56.0 REQUIRED)") endif() -set(bsoncxx_pkg_dep "") -set(bsoncxx_boost_pkg_dep "") +set(BSONCXX_PKG_DEP "") # Required by bsoncxx-config.cmake.in. if(TARGET bson_shared OR TARGET bson_static) # If these targets exist, then libbson has already been included as a project @@ -101,7 +87,7 @@ if(TARGET bson_shared OR TARGET bson_static) set(libbson_target bson_static) endif() - set(bsoncxx_pkg_dep "find_dependency(bson-${LIBBSON_REQUIRED_ABI_VERSION} REQUIRED)") + set(BSONCXX_PKG_DEP "find_dependency(bson-${LIBBSON_REQUIRED_ABI_VERSION} REQUIRED)") else() # Attempt to find libbson by new package name (without lib). find_package(bson-${LIBBSON_REQUIRED_ABI_VERSION} ${LIBBSON_REQUIRED_VERSION} QUIET) @@ -115,7 +101,7 @@ else() set(libbson_target mongo::bson_static) endif() - set(bsoncxx_pkg_dep "find_dependency(bson-${LIBBSON_REQUIRED_ABI_VERSION} REQUIRED)") + set(BSONCXX_PKG_DEP "find_dependency(bson-${LIBBSON_REQUIRED_ABI_VERSION} REQUIRED)") else() # Require package of old libbson name (with lib). if(NOT BSONCXX_LINK_WITH_STATIC_MONGOC) @@ -124,18 +110,19 @@ else() set(libbson_target ${BSON_LIBRARIES}) set(libbson_include_directories ${BSON_INCLUDE_DIRS}) set(libbson_definitions ${BSON_DEFINITIONS}) - set(bsoncxx_pkg_dep "find_dependency(libbson-${LIBBSON_REQUIRED_ABI_VERSION} REQUIRED)") + set(BSONCXX_PKG_DEP "find_dependency(libbson-${LIBBSON_REQUIRED_ABI_VERSION} REQUIRED)") else() find_package(libbson-static-${LIBBSON_REQUIRED_ABI_VERSION} ${LIBBSON_REQUIRED_VERSION} REQUIRED) message("found libbson version ${BSON_STATIC_VERSION}") set(libbson_target ${BSON_STATIC_LIBRARIES}) set(libbson_include_directories ${BSON_STATIC_INCLUDE_DIRS}) set(libbson_definitions ${BSON_STATIC_DEFINITIONS}) - set(bsoncxx_pkg_dep "find_dependency(libbson-static-${LIBBSON_REQUIRED_ABI_VERSION} REQUIRED)") + set(BSONCXX_PKG_DEP "find_dependency(libbson-static-${LIBBSON_REQUIRED_ABI_VERSION} REQUIRED)") endif() endif() endif() +add_subdirectory(cmake) add_subdirectory(third_party) add_subdirectory(lib/bsoncxx/v_noabi/bsoncxx/config) @@ -159,18 +146,18 @@ set(bsoncxx_sources lib/bsoncxx/v_noabi/bsoncxx/validate.cpp ) -# We define both the normal libraries and the testing-only library. The testing-only -# library does not get installed, but the tests link against it instead of the normal library. The -# only difference between the libraries is that BSONCXX_TESTING is defined in the testing-only -# library (this define enables special testing-only behavior). include(BsoncxxUtil) +set(bsoncxx_target_list "") + if(BSONCXX_BUILD_SHARED) bsoncxx_add_library(bsoncxx_shared "${BSONCXX_OUTPUT_BASENAME}" SHARED) + list(APPEND bsoncxx_target_list bsoncxx_shared) endif() if(BSONCXX_BUILD_STATIC) bsoncxx_add_library(bsoncxx_static "${BSONCXX_OUTPUT_BASENAME}-static" STATIC) + list(APPEND bsoncxx_target_list bsoncxx_static) endif() if(BSONCXX_BUILD_SHARED) @@ -191,36 +178,6 @@ if(ENABLE_TESTS) target_compile_definitions(bsoncxx_testing PUBLIC BSONCXX_TESTING) endif() -set(libdir "\${prefix}/${CMAKE_INSTALL_LIBDIR}") - -if(BSONCXX_BUILD_SHARED) - configure_file( - cmake/libbsoncxx.pc.in - cmake/libbsoncxx.pc - @ONLY - ) - - install(FILES - ${CMAKE_CURRENT_BINARY_DIR}/cmake/libbsoncxx.pc - DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig - COMPONENT dev - ) -endif() - -if(BSONCXX_BUILD_STATIC) - configure_file( - cmake/libbsoncxx-static.pc.in - cmake/libbsoncxx-static.pc - @ONLY - ) - - install(FILES - ${CMAKE_CURRENT_BINARY_DIR}/cmake/libbsoncxx-static.pc - DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig - COMPONENT dev - ) -endif() - install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT dev @@ -232,33 +189,24 @@ install(FILES COMPONENT dev ) -set(PACKAGE_INCLUDE_INSTALL_DIRS - ${CMAKE_INSTALL_INCLUDEDIR}/bsoncxx/v_noabi - ${BSONCXX_POLY_MNMLSTC_DEPRECATED_INCLUDE_DIRS} -) -set(PACKAGE_LIBRARY_INSTALL_DIRS ${CMAKE_INSTALL_LIBDIR}) -set(PACKAGE_LIBRARIES bsoncxx) - -include(CMakePackageConfigHelpers) - -set(bsoncxx_target_list "") - -if(BSONCXX_BUILD_SHARED) - bsoncxx_install_deprecated_cmake(bsoncxx) - list(APPEND bsoncxx_target_list bsoncxx_shared) -endif() - -if(BSONCXX_BUILD_STATIC) - bsoncxx_install_deprecated_cmake(bsoncxx-static) - list(APPEND bsoncxx_target_list bsoncxx_static) -endif() +# Generate and install the modern CMake install package targets file. +if(1) + install(TARGETS + ${bsoncxx_target_list} + EXPORT bsoncxx_targets + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT runtime + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT runtime + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT dev + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/bsoncxx/v_noabi + ) -if(BSONCXX_POLY_USE_BOOST) - set(bsoncxx_boost_pkg_dep "find_dependency(Boost 1.56.0 REQUIRED)") + install(EXPORT bsoncxx_targets + NAMESPACE mongo:: + FILE bsoncxx_targets.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/bsoncxx-${BSONCXX_VERSION} + ) endif() -bsoncxx_install("${bsoncxx_target_list}" "${bsoncxx_pkg_dep}" "${bsoncxx_boost_pkg_dep}") - if(ENABLE_TESTS) add_subdirectory(test) endif() @@ -269,11 +217,6 @@ set_local_dist(src_bsoncxx_lib_v_noabi_DIST_local lib/bsoncxx/v_noabi/bsoncxx/array/value.cpp lib/bsoncxx/v_noabi/bsoncxx/array/view.cpp lib/bsoncxx/v_noabi/bsoncxx/builder/core.cpp - cmake/bsoncxx-config.cmake.in - cmake/libbsoncxx-config.cmake.in - cmake/libbsoncxx-static-config.cmake.in - cmake/libbsoncxx-static.pc.in - cmake/libbsoncxx.pc.in lib/bsoncxx/v_noabi/bsoncxx/decimal128.cpp lib/bsoncxx/v_noabi/bsoncxx/document/element.cpp lib/bsoncxx/v_noabi/bsoncxx/document/value.cpp @@ -354,6 +297,7 @@ set_local_dist(src_bsoncxx_include_v_noabi_DIST_local ) set(src_bsoncxx_DIST + ${src_bsoncxx_cmake_DIST} ${src_bsoncxx_lib_v_noabi_DIST_local} ${src_bsoncxx_include_v_noabi_DIST_local} ${src_bsoncxx_config_DIST} diff --git a/src/bsoncxx/cmake/CMakeLists.txt b/src/bsoncxx/cmake/CMakeLists.txt new file mode 100644 index 0000000000..a851afd185 --- /dev/null +++ b/src/bsoncxx/cmake/CMakeLists.txt @@ -0,0 +1,134 @@ +# Copyright 2023 MongoDB Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include(CMakePackageConfigHelpers) + +# Required by legacy CMake package config files. +set(BSONCXX_POLY_MNMLSTC_DEPRECATED_INCLUDE_DIRS "") + +# Required by pkg-config package config files. +set(BSONCXX_POLY_MNMLSTC_PKGCONFIG_INCLUDE_DIRS "") +set(BSONCXX_POLY_MNMLSTC_PKGCONFIG_STATIC_INCLUDE_DIRS "") + +if(BSONCXX_POLY_USE_MNMLSTC AND NOT BSONCXX_POLY_USE_SYSTEM_MNMLSTC) + set(BSONCXX_POLY_MNMLSTC_DEPRECATED_INCLUDE_DIRS + "${CMAKE_INSTALL_INCLUDEDIR}/bsoncxx/v_noabi/bsoncxx/third_party/mnmlstc" + ) + + set(BSONCXX_POLY_MNMLSTC_PKGCONFIG_INCLUDE_DIRS + [[-I${includedir}/bsoncxx/v_noabi/bsoncxx/third_party/mnmlstc ]] + ) + set(BSONCXX_POLY_MNMLSTC_PKGCONFIG_STATIC_INCLUDE_DIRS + [[-I${includedir}/bsoncxx/v_noabi/bsoncxx/third_party/mnmlstc ]] + ) +endif() + +# Generate and install modern CMake package config files. +if(1) + write_basic_package_version_file( + bsoncxx-config-version.cmake + VERSION ${BSONCXX_VERSION} + COMPATIBILITY SameMajorVersion + ) + + configure_file( + bsoncxx-config.cmake.in + bsoncxx-config.cmake + @ONLY + ) + + install( + FILES + ${CMAKE_CURRENT_BINARY_DIR}/bsoncxx-config-version.cmake + ${CMAKE_CURRENT_BINARY_DIR}/bsoncxx-config.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/bsoncxx-${BSONCXX_VERSION} + COMPONENT Devel + ) +endif() + +# Generate and install deprecated CMake package config files. +if(1) + set(PACKAGE_INCLUDE_INSTALL_DIRS + ${CMAKE_INSTALL_INCLUDEDIR}/bsoncxx/v_noabi + ${BSONCXX_POLY_MNMLSTC_DEPRECATED_INCLUDE_DIRS} + ) + set(PACKAGE_LIBRARY_INSTALL_DIRS ${CMAKE_INSTALL_LIBDIR}) + + function(bsoncxx_install_deprecated_cmake NAME) + set(PKG "lib${NAME}") + + configure_package_config_file( + ${PKG}-config.cmake.in + ${PKG}-config.cmake + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PKG}-${BSONCXX_VERSION} + PATH_VARS PACKAGE_INCLUDE_INSTALL_DIRS PACKAGE_LIBRARY_INSTALL_DIRS + ) + + write_basic_package_version_file( + ${PKG}-config-version.cmake + VERSION ${BSONCXX_VERSION} + COMPATIBILITY SameMajorVersion + ) + + install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/${PKG}-config.cmake + ${CMAKE_CURRENT_BINARY_DIR}/${PKG}-config-version.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PKG}-${BSONCXX_VERSION} + ) + endfunction(bsoncxx_install_deprecated_cmake) + + if(BSONCXX_BUILD_SHARED) + bsoncxx_install_deprecated_cmake(bsoncxx) + endif() + + if(BSONCXX_BUILD_STATIC) + bsoncxx_install_deprecated_cmake(bsoncxx-static) + endif() +endif() + +# Generate and install pkg-config package config files. +if(1) + function(bsoncxx_install_pkg_config NAME) + set(PKG "lib${NAME}") + + configure_file( + ${PKG}.pc.in + ${PKG}.pc + @ONLY + ) + + install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/${PKG}.pc + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig + COMPONENT dev + ) + endfunction() + + if(BSONCXX_BUILD_SHARED) + bsoncxx_install_pkg_config(bsoncxx) + endif() + + if(BSONCXX_BUILD_STATIC) + bsoncxx_install_pkg_config(bsoncxx-static) + endif() +endif() + +set_dist_list(src_bsoncxx_cmake_DIST + CMakeLists.txt + bsoncxx-config.cmake.in + libbsoncxx-config.cmake.in + libbsoncxx-static-config.cmake.in + libbsoncxx-static.pc.in + libbsoncxx.pc.in +) diff --git a/src/bsoncxx/cmake/libbsoncxx-static.pc.in b/src/bsoncxx/cmake/libbsoncxx-static.pc.in index 7b823509cb..7d676f68ad 100644 --- a/src/bsoncxx/cmake/libbsoncxx-static.pc.in +++ b/src/bsoncxx/cmake/libbsoncxx-static.pc.in @@ -13,8 +13,8 @@ # limitations under the License. prefix=@CMAKE_INSTALL_PREFIX@ -includedir=${prefix}/include -libdir=@libdir@ +includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ +libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ Name: libbsoncxx-static Description: The MongoDB C++11 BSON Library diff --git a/src/bsoncxx/cmake/libbsoncxx.pc.in b/src/bsoncxx/cmake/libbsoncxx.pc.in index d389030512..8d80566417 100644 --- a/src/bsoncxx/cmake/libbsoncxx.pc.in +++ b/src/bsoncxx/cmake/libbsoncxx.pc.in @@ -13,8 +13,8 @@ # limitations under the License. prefix=@CMAKE_INSTALL_PREFIX@ -includedir=${prefix}/include -libdir=@libdir@ +includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ +libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ Name: libbsoncxx Description: The MongoDB C++11 BSON Library diff --git a/src/mongocxx/CMakeLists.txt b/src/mongocxx/CMakeLists.txt index f0eaedc61e..7f98d4c7d5 100644 --- a/src/mongocxx/CMakeLists.txt +++ b/src/mongocxx/CMakeLists.txt @@ -25,7 +25,7 @@ option(MONGOCXX_ENABLE_SLOW_TESTS "Run slow tests when invoking the the test tar set(MONGOCXX_OUTPUT_BASENAME "mongocxx" CACHE STRING "Output mongocxx library base name") -set(mongocxx_pkg_dep "") +set(MONGOCXX_PKG_DEP "") # Required by bsoncxx-config.cmake.in. if(TARGET mongoc_shared OR TARGET mongoc_static) # If these targets exist, then libmongoc has already been included as a project @@ -38,7 +38,7 @@ if(TARGET mongoc_shared OR TARGET mongoc_static) set(libmongoc_target mongoc_static) endif() - set(mongocxx_pkg_dep "find_dependency(mongoc-${LIBMONGOC_REQUIRED_ABI_VERSION} REQUIRED)") + set(MONGOCXX_PKG_DEP "find_dependency(mongoc-${LIBMONGOC_REQUIRED_ABI_VERSION} REQUIRED)") else() # Attempt to find libmongoc by new package name (without lib). find_package(mongoc-${LIBMONGOC_REQUIRED_ABI_VERSION} ${LIBMONGOC_REQUIRED_VERSION} QUIET) @@ -52,7 +52,7 @@ else() set(libmongoc_target mongo::mongoc_static) endif() - set(mongocxx_pkg_dep "find_dependency(mongoc-${LIBMONGOC_REQUIRED_ABI_VERSION} REQUIRED)") + set(MONGOCXX_PKG_DEP "find_dependency(mongoc-${LIBMONGOC_REQUIRED_ABI_VERSION} REQUIRED)") else() # Require package of old libmongoc name (with lib). if(NOT MONGOCXX_LINK_WITH_STATIC_MONGOC) @@ -60,17 +60,18 @@ else() message("found libmongoc version ${MONGOC_VERSION}") set(libmongoc_target ${MONGOC_LIBRARIES}) set(libmongoc_definitions ${MONGOC_DEFINITIONS}) - set(mongocxx_pkg_dep "find_dependency(libmongoc-${LIBMONGOC_REQUIRED_ABI_VERSION} REQUIRED)") + set(MONGOCXX_PKG_DEP "find_dependency(libmongoc-${LIBMONGOC_REQUIRED_ABI_VERSION} REQUIRED)") else() find_package(libmongoc-static-${LIBMONGOC_REQUIRED_ABI_VERSION} ${LIBMONGOC_REQUIRED_VERSION} REQUIRED) message("found libmongoc version ${MONGOC_STATIC_VERSION}") set(libmongoc_target ${MONGOC_STATIC_LIBRARIES}) set(libmongoc_definitions ${MONGOC_STATIC_DEFINITIONS}) - set(mongocxx_pkg_dep "find_dependency(libmongoc-static-${LIBMONGOC_REQUIRED_ABI_VERSION} REQUIRED)") + set(MONGOCXX_PKG_DEP "find_dependency(libmongoc-static-${LIBMONGOC_REQUIRED_ABI_VERSION} REQUIRED)") endif() endif() endif() +add_subdirectory(cmake) add_subdirectory(lib/mongocxx/v_noabi/mongocxx/config) set(mongocxx_sources @@ -169,20 +170,20 @@ set(mongocxx_sources lib/mongocxx/v_noabi/mongocxx/write_concern.cpp ) -# We define both the normal libraries and the testing-only library. The testing-only -# library does not get installed, but the tests link against it instead of the normal library. The -# only difference between the libraries is that MONGOCXX_TESTING is defined in the testing-only -# library (this define enables special testing-only behavior). include(MongocxxUtil) +set(mongocxx_target_list "") + if(MONGOCXX_BUILD_SHARED) mongocxx_add_library(mongocxx_shared "${MONGOCXX_OUTPUT_BASENAME}" SHARED) target_link_libraries(mongocxx_shared PUBLIC bsoncxx_shared) + list(APPEND mongocxx_target_list mongocxx_shared) endif() if(MONGOCXX_BUILD_STATIC) mongocxx_add_library(mongocxx_static "${MONGOCXX_OUTPUT_BASENAME}-static" STATIC) target_link_libraries(mongocxx_static PUBLIC bsoncxx_static) + list(APPEND mongocxx_target_list mongocxx_static) endif() if(MONGOCXX_BUILD_SHARED) @@ -219,56 +220,24 @@ install(FILES COMPONENT dev ) -set(PACKAGE_INCLUDE_INSTALL_DIRS ${CMAKE_INSTALL_INCLUDEDIR}/mongocxx/v_noabi) -set(PACKAGE_LIBRARY_INSTALL_DIRS ${CMAKE_INSTALL_LIBDIR}) -set(PACKAGE_LIBRARIES mongocxx) - -include(CMakePackageConfigHelpers) - -set(libdir "\${prefix}/${CMAKE_INSTALL_LIBDIR}") - -if(MONGOCXX_BUILD_SHARED) - configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/cmake/libmongocxx.pc.in - ${CMAKE_CURRENT_BINARY_DIR}/cmake/libmongocxx.pc - @ONLY +# Generate and install the modern CMake package install targets file. +if(1) + install(TARGETS + ${mongocxx_target_list} + EXPORT mongocxx_targets + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT runtime + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT runtime + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT dev + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/mongocxx/v_noabi ) - install(FILES - "${CMAKE_CURRENT_BINARY_DIR}/cmake/libmongocxx.pc" - DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig - COMPONENT dev + install(EXPORT mongocxx_targets + NAMESPACE mongo:: + FILE mongocxx_targets.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/mongocxx-${MONGOCXX_VERSION} ) endif() -if(MONGOCXX_BUILD_STATIC) - configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/cmake/libmongocxx-static.pc.in - ${CMAKE_CURRENT_BINARY_DIR}/cmake/libmongocxx-static.pc - @ONLY - ) - - install(FILES - "${CMAKE_CURRENT_BINARY_DIR}/cmake/libmongocxx-static.pc" - DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig - COMPONENT dev - ) -endif() - -set(mongocxx_target_list "") - -if(MONGOCXX_BUILD_SHARED) - mongocxx_install_deprecated_cmake(mongocxx) - list(APPEND mongocxx_target_list mongocxx_shared) -endif() - -if(MONGOCXX_BUILD_STATIC) - mongocxx_install_deprecated_cmake(mongocxx-static) - list(APPEND mongocxx_target_list mongocxx_static) -endif() - -mongocxx_install("${mongocxx_target_list}" "${mongocxx_pkg_dep}") - if(ENABLE_TESTS) add_subdirectory(test) endif() @@ -280,11 +249,6 @@ set_local_dist(src_mongocxx_lib_v_noabi_DIST_local lib/mongocxx/v_noabi/mongocxx/client.cpp lib/mongocxx/v_noabi/mongocxx/client_encryption.cpp lib/mongocxx/v_noabi/mongocxx/client_session.cpp - cmake/mongocxx-config.cmake.in - cmake/libmongocxx-config.cmake.in - cmake/libmongocxx-static-config.cmake.in - cmake/libmongocxx-static.pc.in - cmake/libmongocxx.pc.in lib/mongocxx/v_noabi/mongocxx/collection.cpp lib/mongocxx/v_noabi/mongocxx/cursor.cpp lib/mongocxx/v_noabi/mongocxx/database.cpp @@ -517,6 +481,7 @@ set_local_dist(src_mongocxx_include_v_noabi_DIST_local ) set(src_mongocxx_DIST + ${src_mongocxx_cmake_DIST} ${src_mongocxx_lib_v_noabi_DIST_local} ${src_mongocxx_include_v_noabi_DIST_local} ${src_mongocxx_config_DIST} diff --git a/src/mongocxx/cmake/CMakeLists.txt b/src/mongocxx/cmake/CMakeLists.txt new file mode 100644 index 0000000000..2aa1d15770 --- /dev/null +++ b/src/mongocxx/cmake/CMakeLists.txt @@ -0,0 +1,113 @@ +# Copyright 2023 MongoDB Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include(CMakePackageConfigHelpers) + +# Generate and install modern CMake package config files. +if(1) + write_basic_package_version_file( + mongocxx-config-version.cmake + VERSION ${MONGOCXX_VERSION} + COMPATIBILITY SameMajorVersion + ) + + configure_file( + mongocxx-config.cmake.in + mongocxx-config.cmake + @ONLY + ) + + install( + FILES + ${CMAKE_CURRENT_BINARY_DIR}/mongocxx-config-version.cmake + ${CMAKE_CURRENT_BINARY_DIR}/mongocxx-config.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/mongocxx-${MONGOCXX_VERSION} + COMPONENT Devel + ) +endif() + +# Generate and install deprecated CMake package config files. +if(1) + set(PACKAGE_INCLUDE_INSTALL_DIRS + ${CMAKE_INSTALL_INCLUDEDIR}/mongocxx/v_noabi + ) + set(PACKAGE_LIBRARY_INSTALL_DIRS ${CMAKE_INSTALL_LIBDIR}) + + function(mongocxx_install_deprecated_cmake NAME) + set(PKG "lib${NAME}") + + configure_package_config_file( + ${PKG}-config.cmake.in + ${PKG}-config.cmake + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PKG}-${MONGOCXX_VERSION} + PATH_VARS PACKAGE_INCLUDE_INSTALL_DIRS PACKAGE_LIBRARY_INSTALL_DIRS + ) + + write_basic_package_version_file( + ${PKG}-config-version.cmake + VERSION ${MONGOCXX_VERSION} + COMPATIBILITY SameMajorVersion + ) + + install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/${PKG}-config.cmake + ${CMAKE_CURRENT_BINARY_DIR}/${PKG}-config-version.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PKG}-${MONGOCXX_VERSION} + ) + endfunction(mongocxx_install_deprecated_cmake) + + if(MONGOCXX_BUILD_SHARED) + mongocxx_install_deprecated_cmake(mongocxx) + endif() + + if(MONGOCXX_BUILD_STATIC) + mongocxx_install_deprecated_cmake(mongocxx-static) + endif() +endif() + +# Generate and install pkg-config package config files. +if(1) + function(mongocxx_install_pkg_config NAME) + set(PKG "lib${NAME}") + + configure_file( + ${PKG}.pc.in + ${PKG}.pc + @ONLY + ) + + install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/${PKG}.pc + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig + COMPONENT dev + ) + endfunction() + + if(MONGOCXX_BUILD_SHARED) + mongocxx_install_pkg_config(mongocxx) + endif() + + if(MONGOCXX_BUILD_STATIC) + mongocxx_install_pkg_config(mongocxx-static) + endif() +endif() + +set_dist_list(src_mongocxx_cmake_DIST + CMakeLists.txt + libmongocxx-config.cmake.in + libmongocxx-static-config.cmake.in + libmongocxx-static.pc.in + libmongocxx.pc.in + mongocxx-config.cmake.in +) diff --git a/src/mongocxx/cmake/libmongocxx-static.pc.in b/src/mongocxx/cmake/libmongocxx-static.pc.in index b602bfa8b1..562e867ab5 100644 --- a/src/mongocxx/cmake/libmongocxx-static.pc.in +++ b/src/mongocxx/cmake/libmongocxx-static.pc.in @@ -13,8 +13,8 @@ # limitations under the License. prefix=@CMAKE_INSTALL_PREFIX@ -includedir=${prefix}/include -libdir=@libdir@ +includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ +libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ Name: libmongocxx Description: The MongoDB C++11 Driver Library diff --git a/src/mongocxx/cmake/libmongocxx.pc.in b/src/mongocxx/cmake/libmongocxx.pc.in index 9461573f30..965fae77de 100644 --- a/src/mongocxx/cmake/libmongocxx.pc.in +++ b/src/mongocxx/cmake/libmongocxx.pc.in @@ -13,8 +13,8 @@ # limitations under the License. prefix=@CMAKE_INSTALL_PREFIX@ -includedir=${prefix}/include -libdir=@libdir@ +includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ +libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ Name: libmongocxx Description: The MongoDB C++11 Driver Library From 48d3a459fa9dd08429d97b23c5f15d26940da0ee Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Fri, 22 Sep 2023 13:05:00 -0500 Subject: [PATCH 05/11] Move header commands into include/CMakeLists.txt --- cmake/BsoncxxUtil.cmake | 8 -- cmake/MongocxxUtil.cmake | 8 -- src/bsoncxx/CMakeLists.txt | 92 ++++++------------ src/bsoncxx/include/CMakeLists.txt | 73 ++++++++++++++ src/mongocxx/CMakeLists.txt | 143 ++++++---------------------- src/mongocxx/include/CMakeLists.txt | 126 ++++++++++++++++++++++++ 6 files changed, 254 insertions(+), 196 deletions(-) create mode 100644 src/bsoncxx/include/CMakeLists.txt create mode 100644 src/mongocxx/include/CMakeLists.txt diff --git a/cmake/BsoncxxUtil.cmake b/cmake/BsoncxxUtil.cmake index 6e1de371d5..b7b2921ec2 100644 --- a/cmake/BsoncxxUtil.cmake +++ b/cmake/BsoncxxUtil.cmake @@ -50,12 +50,4 @@ function(bsoncxx_add_library TARGET OUTPUT_NAME LINK_TYPE) $ ) target_compile_definitions(${TARGET} PRIVATE ${libbson_definitions}) - - generate_export_header(${TARGET} - BASE_NAME BSONCXX - EXPORT_MACRO_NAME BSONCXX_API - NO_EXPORT_MACRO_NAME BSONCXX_PRIVATE - EXPORT_FILE_NAME ${PROJECT_BINARY_DIR}/lib/bsoncxx/v_noabi/bsoncxx/config/export.hpp - STATIC_DEFINE BSONCXX_STATIC - ) endfunction(bsoncxx_add_library) diff --git a/cmake/MongocxxUtil.cmake b/cmake/MongocxxUtil.cmake index daf240b84b..b61c29a1d3 100644 --- a/cmake/MongocxxUtil.cmake +++ b/cmake/MongocxxUtil.cmake @@ -38,12 +38,4 @@ function(mongocxx_add_library TARGET OUTPUT_NAME LINK_TYPE) $ ) target_compile_definitions(${TARGET} PRIVATE ${libmongoc_definitions}) - - generate_export_header(${TARGET} - BASE_NAME MONGOCXX - EXPORT_MACRO_NAME MONGOCXX_API - NO_EXPORT_MACRO_NAME MONGOCXX_PRIVATE - EXPORT_FILE_NAME ${PROJECT_BINARY_DIR}/lib/mongocxx/v_noabi/mongocxx/config/export.hpp - STATIC_DEFINE MONGOCXX_STATIC - ) endfunction(mongocxx_add_library) diff --git a/src/bsoncxx/CMakeLists.txt b/src/bsoncxx/CMakeLists.txt index 08e4aa2e65..2de2561ea6 100644 --- a/src/bsoncxx/CMakeLists.txt +++ b/src/bsoncxx/CMakeLists.txt @@ -123,6 +123,7 @@ else() endif() add_subdirectory(cmake) +add_subdirectory(include) add_subdirectory(third_party) add_subdirectory(lib/bsoncxx/v_noabi/bsoncxx/config) @@ -178,16 +179,32 @@ if(ENABLE_TESTS) target_compile_definitions(bsoncxx_testing PUBLIC BSONCXX_TESTING) endif() -install(DIRECTORY include/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} - COMPONENT dev -) - -install(FILES - ${PROJECT_BINARY_DIR}/lib/bsoncxx/v_noabi/bsoncxx/config/export.hpp - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/bsoncxx/v_noabi/bsoncxx/config - COMPONENT dev -) +# Generate and install the export header. +if(1) + function(bsoncxx_install_export_header TARGET) + generate_export_header(${TARGET} + BASE_NAME BSONCXX + EXPORT_MACRO_NAME BSONCXX_API + NO_EXPORT_MACRO_NAME BSONCXX_PRIVATE + EXPORT_FILE_NAME ${PROJECT_BINARY_DIR}/lib/bsoncxx/v_noabi/bsoncxx/config/export.hpp + STATIC_DEFINE BSONCXX_STATIC + ) + + install(FILES + ${PROJECT_BINARY_DIR}/lib/bsoncxx/v_noabi/bsoncxx/config/export.hpp + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/bsoncxx/v_noabi/bsoncxx/config + COMPONENT dev + ) + endfunction() + + # Ensure the export header is generated *at most* once. + # Give priority to the shared library target which sets visibility properties. + if(BSONCXX_BUILD_SHARED) + bsoncxx_install_export_header(bsoncxx_shared) + elseif(BSONCXX_BUILD_STATIC) + bsoncxx_install_export_header(bsoncxx_static) + endif() +endif() # Generate and install the modern CMake install package targets file. if(1) @@ -243,63 +260,10 @@ set_local_dist(src_bsoncxx_lib_v_noabi_DIST_local lib/bsoncxx/v_noabi/bsoncxx/validate.cpp ) -set_local_dist(src_bsoncxx_include_v_noabi_DIST_local - include/bsoncxx/v_noabi/bsoncxx/array/element.hpp - include/bsoncxx/v_noabi/bsoncxx/array/value.hpp - include/bsoncxx/v_noabi/bsoncxx/array/view_or_value.hpp - include/bsoncxx/v_noabi/bsoncxx/array/view.hpp - include/bsoncxx/v_noabi/bsoncxx/builder/basic/array.hpp - include/bsoncxx/v_noabi/bsoncxx/builder/basic/document.hpp - include/bsoncxx/v_noabi/bsoncxx/builder/basic/helpers.hpp - include/bsoncxx/v_noabi/bsoncxx/builder/basic/impl.hpp - include/bsoncxx/v_noabi/bsoncxx/builder/basic/kvp.hpp - include/bsoncxx/v_noabi/bsoncxx/builder/basic/sub_array.hpp - include/bsoncxx/v_noabi/bsoncxx/builder/basic/sub_document.hpp - include/bsoncxx/v_noabi/bsoncxx/builder/concatenate.hpp - include/bsoncxx/v_noabi/bsoncxx/builder/core.hpp - include/bsoncxx/v_noabi/bsoncxx/builder/list.hpp - include/bsoncxx/v_noabi/bsoncxx/builder/stream/array_context.hpp - include/bsoncxx/v_noabi/bsoncxx/builder/stream/array.hpp - include/bsoncxx/v_noabi/bsoncxx/builder/stream/closed_context.hpp - include/bsoncxx/v_noabi/bsoncxx/builder/stream/document.hpp - include/bsoncxx/v_noabi/bsoncxx/builder/stream/helpers.hpp - include/bsoncxx/v_noabi/bsoncxx/builder/stream/key_context.hpp - include/bsoncxx/v_noabi/bsoncxx/builder/stream/single_context.hpp - include/bsoncxx/v_noabi/bsoncxx/builder/stream/value_context.hpp - include/bsoncxx/v_noabi/bsoncxx/config/compiler.hpp - include/bsoncxx/v_noabi/bsoncxx/config/postlude.hpp - include/bsoncxx/v_noabi/bsoncxx/config/prelude.hpp - include/bsoncxx/v_noabi/bsoncxx/decimal128.hpp - include/bsoncxx/v_noabi/bsoncxx/document/element.hpp - include/bsoncxx/v_noabi/bsoncxx/document/value.hpp - include/bsoncxx/v_noabi/bsoncxx/document/view_or_value.hpp - include/bsoncxx/v_noabi/bsoncxx/document/view.hpp - include/bsoncxx/v_noabi/bsoncxx/enums/binary_sub_type.hpp - include/bsoncxx/v_noabi/bsoncxx/enums/type.hpp - include/bsoncxx/v_noabi/bsoncxx/exception/error_code.hpp - include/bsoncxx/v_noabi/bsoncxx/exception/exception.hpp - include/bsoncxx/v_noabi/bsoncxx/json.hpp - include/bsoncxx/v_noabi/bsoncxx/oid.hpp - include/bsoncxx/v_noabi/bsoncxx/stdx/make_unique.hpp - include/bsoncxx/v_noabi/bsoncxx/stdx/optional.hpp - include/bsoncxx/v_noabi/bsoncxx/stdx/string_view.hpp - include/bsoncxx/v_noabi/bsoncxx/string/to_string.hpp - include/bsoncxx/v_noabi/bsoncxx/string/view_or_value.hpp - include/bsoncxx/v_noabi/bsoncxx/types.hpp - include/bsoncxx/v_noabi/bsoncxx/types/bson_value/make_value.hpp - include/bsoncxx/v_noabi/bsoncxx/types/bson_value/value.hpp - include/bsoncxx/v_noabi/bsoncxx/types/bson_value/view_or_value.hpp - include/bsoncxx/v_noabi/bsoncxx/types/bson_value/view.hpp - include/bsoncxx/v_noabi/bsoncxx/types/value.hpp - include/bsoncxx/v_noabi/bsoncxx/util/functor.hpp - include/bsoncxx/v_noabi/bsoncxx/validate.hpp - include/bsoncxx/v_noabi/bsoncxx/view_or_value.hpp -) - set(src_bsoncxx_DIST ${src_bsoncxx_cmake_DIST} + ${src_bsoncxx_include_DIST} ${src_bsoncxx_lib_v_noabi_DIST_local} - ${src_bsoncxx_include_v_noabi_DIST_local} ${src_bsoncxx_config_DIST} ${src_bsoncxx_third_party_DIST} ${src_bsoncxx_test_DIST} diff --git a/src/bsoncxx/include/CMakeLists.txt b/src/bsoncxx/include/CMakeLists.txt new file mode 100644 index 0000000000..ae5b3c7186 --- /dev/null +++ b/src/bsoncxx/include/CMakeLists.txt @@ -0,0 +1,73 @@ +# Copyright 2023 MongoDB Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + COMPONENT dev + FILES_MATCHING PATTERN "*.hpp" +) + +set_dist_list(src_bsoncxx_include_DIST + CMakeLists.txt + bsoncxx/v_noabi/bsoncxx/array/element.hpp + bsoncxx/v_noabi/bsoncxx/array/value.hpp + bsoncxx/v_noabi/bsoncxx/array/view_or_value.hpp + bsoncxx/v_noabi/bsoncxx/array/view.hpp + bsoncxx/v_noabi/bsoncxx/builder/basic/array.hpp + bsoncxx/v_noabi/bsoncxx/builder/basic/document.hpp + bsoncxx/v_noabi/bsoncxx/builder/basic/helpers.hpp + bsoncxx/v_noabi/bsoncxx/builder/basic/impl.hpp + bsoncxx/v_noabi/bsoncxx/builder/basic/kvp.hpp + bsoncxx/v_noabi/bsoncxx/builder/basic/sub_array.hpp + bsoncxx/v_noabi/bsoncxx/builder/basic/sub_document.hpp + bsoncxx/v_noabi/bsoncxx/builder/concatenate.hpp + bsoncxx/v_noabi/bsoncxx/builder/core.hpp + bsoncxx/v_noabi/bsoncxx/builder/list.hpp + bsoncxx/v_noabi/bsoncxx/builder/stream/array_context.hpp + bsoncxx/v_noabi/bsoncxx/builder/stream/array.hpp + bsoncxx/v_noabi/bsoncxx/builder/stream/closed_context.hpp + bsoncxx/v_noabi/bsoncxx/builder/stream/document.hpp + bsoncxx/v_noabi/bsoncxx/builder/stream/helpers.hpp + bsoncxx/v_noabi/bsoncxx/builder/stream/key_context.hpp + bsoncxx/v_noabi/bsoncxx/builder/stream/single_context.hpp + bsoncxx/v_noabi/bsoncxx/builder/stream/value_context.hpp + bsoncxx/v_noabi/bsoncxx/config/compiler.hpp + bsoncxx/v_noabi/bsoncxx/config/postlude.hpp + bsoncxx/v_noabi/bsoncxx/config/prelude.hpp + bsoncxx/v_noabi/bsoncxx/decimal128.hpp + bsoncxx/v_noabi/bsoncxx/document/element.hpp + bsoncxx/v_noabi/bsoncxx/document/value.hpp + bsoncxx/v_noabi/bsoncxx/document/view_or_value.hpp + bsoncxx/v_noabi/bsoncxx/document/view.hpp + bsoncxx/v_noabi/bsoncxx/enums/binary_sub_type.hpp + bsoncxx/v_noabi/bsoncxx/enums/type.hpp + bsoncxx/v_noabi/bsoncxx/exception/error_code.hpp + bsoncxx/v_noabi/bsoncxx/exception/exception.hpp + bsoncxx/v_noabi/bsoncxx/json.hpp + bsoncxx/v_noabi/bsoncxx/oid.hpp + bsoncxx/v_noabi/bsoncxx/stdx/make_unique.hpp + bsoncxx/v_noabi/bsoncxx/stdx/optional.hpp + bsoncxx/v_noabi/bsoncxx/stdx/string_view.hpp + bsoncxx/v_noabi/bsoncxx/string/to_string.hpp + bsoncxx/v_noabi/bsoncxx/string/view_or_value.hpp + bsoncxx/v_noabi/bsoncxx/types.hpp + bsoncxx/v_noabi/bsoncxx/types/bson_value/make_value.hpp + bsoncxx/v_noabi/bsoncxx/types/bson_value/value.hpp + bsoncxx/v_noabi/bsoncxx/types/bson_value/view_or_value.hpp + bsoncxx/v_noabi/bsoncxx/types/bson_value/view.hpp + bsoncxx/v_noabi/bsoncxx/types/value.hpp + bsoncxx/v_noabi/bsoncxx/util/functor.hpp + bsoncxx/v_noabi/bsoncxx/validate.hpp + bsoncxx/v_noabi/bsoncxx/view_or_value.hpp +) diff --git a/src/mongocxx/CMakeLists.txt b/src/mongocxx/CMakeLists.txt index 7f98d4c7d5..49ad08ac04 100644 --- a/src/mongocxx/CMakeLists.txt +++ b/src/mongocxx/CMakeLists.txt @@ -72,6 +72,7 @@ else() endif() add_subdirectory(cmake) +add_subdirectory(include) add_subdirectory(lib/mongocxx/v_noabi/mongocxx/config) set(mongocxx_sources @@ -209,16 +210,32 @@ if(ENABLE_TESTS) endif() endif() -install(DIRECTORY include/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} - COMPONENT dev -) +# Generate and install the export header. +if(1) + function(mongocxx_install_export_header TARGET) + generate_export_header(${TARGET} + BASE_NAME MONGOCXX + EXPORT_MACRO_NAME MONGOCXX_API + NO_EXPORT_MACRO_NAME MONGOCXX_PRIVATE + EXPORT_FILE_NAME ${PROJECT_BINARY_DIR}/lib/mongocxx/v_noabi/mongocxx/config/export.hpp + STATIC_DEFINE MONGOCXX_STATIC + ) -install(FILES - ${PROJECT_BINARY_DIR}/lib/mongocxx/v_noabi/mongocxx/config/export.hpp - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/mongocxx/v_noabi/mongocxx/config - COMPONENT dev -) + install(FILES + ${PROJECT_BINARY_DIR}/lib/mongocxx/v_noabi/mongocxx/config/export.hpp + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/mongocxx/v_noabi/mongocxx/config + COMPONENT dev + ) + endfunction() + + # Ensure the export header is generated *at most* once. + # Give priority to the shared library target which sets visibility properties. + if(MONGOCXX_BUILD_SHARED) + mongocxx_install_export_header(mongocxx_shared) + elseif(MONGOCXX_BUILD_STATIC) + mongocxx_install_export_header(mongocxx_static) + endif() +endif() # Generate and install the modern CMake package install targets file. if(1) @@ -374,116 +391,10 @@ set_local_dist(src_mongocxx_lib_v_noabi_DIST_local lib/mongocxx/v_noabi/mongocxx/write_concern.cpp ) -set_local_dist(src_mongocxx_include_v_noabi_DIST_local - include/mongocxx/v_noabi/mongocxx/bulk_write.hpp - include/mongocxx/v_noabi/mongocxx/change_stream.hpp - include/mongocxx/v_noabi/mongocxx/client_encryption.hpp - include/mongocxx/v_noabi/mongocxx/client_session.hpp - include/mongocxx/v_noabi/mongocxx/client.hpp - include/mongocxx/v_noabi/mongocxx/collection.hpp - include/mongocxx/v_noabi/mongocxx/config/compiler.hpp - include/mongocxx/v_noabi/mongocxx/config/postlude.hpp - include/mongocxx/v_noabi/mongocxx/config/prelude.hpp - include/mongocxx/v_noabi/mongocxx/cursor.hpp - include/mongocxx/v_noabi/mongocxx/database.hpp - include/mongocxx/v_noabi/mongocxx/events/command_failed_event.hpp - include/mongocxx/v_noabi/mongocxx/events/command_started_event.hpp - include/mongocxx/v_noabi/mongocxx/events/command_succeeded_event.hpp - include/mongocxx/v_noabi/mongocxx/events/heartbeat_failed_event.hpp - include/mongocxx/v_noabi/mongocxx/events/heartbeat_started_event.hpp - include/mongocxx/v_noabi/mongocxx/events/heartbeat_succeeded_event.hpp - include/mongocxx/v_noabi/mongocxx/events/server_changed_event.hpp - include/mongocxx/v_noabi/mongocxx/events/server_closed_event.hpp - include/mongocxx/v_noabi/mongocxx/events/server_description.hpp - include/mongocxx/v_noabi/mongocxx/events/server_opening_event.hpp - include/mongocxx/v_noabi/mongocxx/events/topology_changed_event.hpp - include/mongocxx/v_noabi/mongocxx/events/topology_closed_event.hpp - include/mongocxx/v_noabi/mongocxx/events/topology_description.hpp - include/mongocxx/v_noabi/mongocxx/events/topology_opening_event.hpp - include/mongocxx/v_noabi/mongocxx/exception/authentication_exception.hpp - include/mongocxx/v_noabi/mongocxx/exception/bulk_write_exception.hpp - include/mongocxx/v_noabi/mongocxx/exception/error_code.hpp - include/mongocxx/v_noabi/mongocxx/exception/exception.hpp - include/mongocxx/v_noabi/mongocxx/exception/gridfs_exception.hpp - include/mongocxx/v_noabi/mongocxx/exception/logic_error.hpp - include/mongocxx/v_noabi/mongocxx/exception/operation_exception.hpp - include/mongocxx/v_noabi/mongocxx/exception/query_exception.hpp - include/mongocxx/v_noabi/mongocxx/exception/server_error_code.hpp - include/mongocxx/v_noabi/mongocxx/exception/write_exception.hpp - include/mongocxx/v_noabi/mongocxx/gridfs/bucket.hpp - include/mongocxx/v_noabi/mongocxx/gridfs/downloader.hpp - include/mongocxx/v_noabi/mongocxx/gridfs/uploader.hpp - include/mongocxx/v_noabi/mongocxx/hint.hpp - include/mongocxx/v_noabi/mongocxx/index_model.hpp - include/mongocxx/v_noabi/mongocxx/index_view.hpp - include/mongocxx/v_noabi/mongocxx/instance.hpp - include/mongocxx/v_noabi/mongocxx/logger.hpp - include/mongocxx/v_noabi/mongocxx/model/delete_many.hpp - include/mongocxx/v_noabi/mongocxx/model/delete_one.hpp - include/mongocxx/v_noabi/mongocxx/model/insert_one.hpp - include/mongocxx/v_noabi/mongocxx/model/replace_one.hpp - include/mongocxx/v_noabi/mongocxx/model/update_many.hpp - include/mongocxx/v_noabi/mongocxx/model/update_one.hpp - include/mongocxx/v_noabi/mongocxx/model/write.hpp - include/mongocxx/v_noabi/mongocxx/options/aggregate.hpp - include/mongocxx/v_noabi/mongocxx/options/apm.hpp - include/mongocxx/v_noabi/mongocxx/options/auto_encryption.hpp - include/mongocxx/v_noabi/mongocxx/options/bulk_write.hpp - include/mongocxx/v_noabi/mongocxx/options/change_stream.hpp - include/mongocxx/v_noabi/mongocxx/options/client_encryption.hpp - include/mongocxx/v_noabi/mongocxx/options/client_session.hpp - include/mongocxx/v_noabi/mongocxx/options/client.hpp - include/mongocxx/v_noabi/mongocxx/options/count.hpp - include/mongocxx/v_noabi/mongocxx/options/create_collection.hpp - include/mongocxx/v_noabi/mongocxx/options/data_key.hpp - include/mongocxx/v_noabi/mongocxx/options/delete.hpp - include/mongocxx/v_noabi/mongocxx/options/distinct.hpp - include/mongocxx/v_noabi/mongocxx/options/encrypt.hpp - include/mongocxx/v_noabi/mongocxx/options/estimated_document_count.hpp - include/mongocxx/v_noabi/mongocxx/options/find_one_and_delete.hpp - include/mongocxx/v_noabi/mongocxx/options/find_one_and_replace.hpp - include/mongocxx/v_noabi/mongocxx/options/find_one_and_update.hpp - include/mongocxx/v_noabi/mongocxx/options/find_one_common_options.hpp - include/mongocxx/v_noabi/mongocxx/options/find.hpp - include/mongocxx/v_noabi/mongocxx/options/gridfs/bucket.hpp - include/mongocxx/v_noabi/mongocxx/options/gridfs/upload.hpp - include/mongocxx/v_noabi/mongocxx/options/index_view.hpp - include/mongocxx/v_noabi/mongocxx/options/index.hpp - include/mongocxx/v_noabi/mongocxx/options/insert.hpp - include/mongocxx/v_noabi/mongocxx/options/pool.hpp - include/mongocxx/v_noabi/mongocxx/options/range.hpp - include/mongocxx/v_noabi/mongocxx/options/replace.hpp - include/mongocxx/v_noabi/mongocxx/options/rewrap_many_datakey.hpp - include/mongocxx/v_noabi/mongocxx/options/server_api.hpp - include/mongocxx/v_noabi/mongocxx/options/ssl.hpp - include/mongocxx/v_noabi/mongocxx/options/tls.hpp - include/mongocxx/v_noabi/mongocxx/options/transaction.hpp - include/mongocxx/v_noabi/mongocxx/options/update.hpp - include/mongocxx/v_noabi/mongocxx/pipeline.hpp - include/mongocxx/v_noabi/mongocxx/pool.hpp - include/mongocxx/v_noabi/mongocxx/read_concern.hpp - include/mongocxx/v_noabi/mongocxx/read_preference.hpp - include/mongocxx/v_noabi/mongocxx/result/bulk_write.hpp - include/mongocxx/v_noabi/mongocxx/result/delete.hpp - include/mongocxx/v_noabi/mongocxx/result/gridfs/upload.hpp - include/mongocxx/v_noabi/mongocxx/result/insert_many.hpp - include/mongocxx/v_noabi/mongocxx/result/insert_one.hpp - include/mongocxx/v_noabi/mongocxx/result/replace_one.hpp - include/mongocxx/v_noabi/mongocxx/result/rewrap_many_datakey.hpp - include/mongocxx/v_noabi/mongocxx/result/update.hpp - include/mongocxx/v_noabi/mongocxx/search_index_model.hpp - include/mongocxx/v_noabi/mongocxx/search_index_view.hpp - include/mongocxx/v_noabi/mongocxx/stdx.hpp - include/mongocxx/v_noabi/mongocxx/uri.hpp - include/mongocxx/v_noabi/mongocxx/validation_criteria.hpp - include/mongocxx/v_noabi/mongocxx/write_concern.hpp - include/mongocxx/v_noabi/mongocxx/write_type.hpp -) - set(src_mongocxx_DIST ${src_mongocxx_cmake_DIST} + ${src_mongocxx_include_DIST} ${src_mongocxx_lib_v_noabi_DIST_local} - ${src_mongocxx_include_v_noabi_DIST_local} ${src_mongocxx_config_DIST} ${src_mongocxx_test_DIST} PARENT_SCOPE diff --git a/src/mongocxx/include/CMakeLists.txt b/src/mongocxx/include/CMakeLists.txt new file mode 100644 index 0000000000..a6b686dbbb --- /dev/null +++ b/src/mongocxx/include/CMakeLists.txt @@ -0,0 +1,126 @@ +# Copyright 2023 MongoDB Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + COMPONENT dev + FILES_MATCHING PATTERN "*.hpp" +) + +set_dist_list(src_mongocxx_include_DIST + CMakeLists.txt + mongocxx/v_noabi/mongocxx/bulk_write.hpp + mongocxx/v_noabi/mongocxx/change_stream.hpp + mongocxx/v_noabi/mongocxx/client_encryption.hpp + mongocxx/v_noabi/mongocxx/client_session.hpp + mongocxx/v_noabi/mongocxx/client.hpp + mongocxx/v_noabi/mongocxx/collection.hpp + mongocxx/v_noabi/mongocxx/config/compiler.hpp + mongocxx/v_noabi/mongocxx/config/postlude.hpp + mongocxx/v_noabi/mongocxx/config/prelude.hpp + mongocxx/v_noabi/mongocxx/cursor.hpp + mongocxx/v_noabi/mongocxx/database.hpp + mongocxx/v_noabi/mongocxx/events/command_failed_event.hpp + mongocxx/v_noabi/mongocxx/events/command_started_event.hpp + mongocxx/v_noabi/mongocxx/events/command_succeeded_event.hpp + mongocxx/v_noabi/mongocxx/events/heartbeat_failed_event.hpp + mongocxx/v_noabi/mongocxx/events/heartbeat_started_event.hpp + mongocxx/v_noabi/mongocxx/events/heartbeat_succeeded_event.hpp + mongocxx/v_noabi/mongocxx/events/server_changed_event.hpp + mongocxx/v_noabi/mongocxx/events/server_closed_event.hpp + mongocxx/v_noabi/mongocxx/events/server_description.hpp + mongocxx/v_noabi/mongocxx/events/server_opening_event.hpp + mongocxx/v_noabi/mongocxx/events/topology_changed_event.hpp + mongocxx/v_noabi/mongocxx/events/topology_closed_event.hpp + mongocxx/v_noabi/mongocxx/events/topology_description.hpp + mongocxx/v_noabi/mongocxx/events/topology_opening_event.hpp + mongocxx/v_noabi/mongocxx/exception/authentication_exception.hpp + mongocxx/v_noabi/mongocxx/exception/bulk_write_exception.hpp + mongocxx/v_noabi/mongocxx/exception/error_code.hpp + mongocxx/v_noabi/mongocxx/exception/exception.hpp + mongocxx/v_noabi/mongocxx/exception/gridfs_exception.hpp + mongocxx/v_noabi/mongocxx/exception/logic_error.hpp + mongocxx/v_noabi/mongocxx/exception/operation_exception.hpp + mongocxx/v_noabi/mongocxx/exception/query_exception.hpp + mongocxx/v_noabi/mongocxx/exception/server_error_code.hpp + mongocxx/v_noabi/mongocxx/exception/write_exception.hpp + mongocxx/v_noabi/mongocxx/gridfs/bucket.hpp + mongocxx/v_noabi/mongocxx/gridfs/downloader.hpp + mongocxx/v_noabi/mongocxx/gridfs/uploader.hpp + mongocxx/v_noabi/mongocxx/hint.hpp + mongocxx/v_noabi/mongocxx/index_model.hpp + mongocxx/v_noabi/mongocxx/index_view.hpp + mongocxx/v_noabi/mongocxx/instance.hpp + mongocxx/v_noabi/mongocxx/logger.hpp + mongocxx/v_noabi/mongocxx/model/delete_many.hpp + mongocxx/v_noabi/mongocxx/model/delete_one.hpp + mongocxx/v_noabi/mongocxx/model/insert_one.hpp + mongocxx/v_noabi/mongocxx/model/replace_one.hpp + mongocxx/v_noabi/mongocxx/model/update_many.hpp + mongocxx/v_noabi/mongocxx/model/update_one.hpp + mongocxx/v_noabi/mongocxx/model/write.hpp + mongocxx/v_noabi/mongocxx/options/aggregate.hpp + mongocxx/v_noabi/mongocxx/options/apm.hpp + mongocxx/v_noabi/mongocxx/options/auto_encryption.hpp + mongocxx/v_noabi/mongocxx/options/bulk_write.hpp + mongocxx/v_noabi/mongocxx/options/change_stream.hpp + mongocxx/v_noabi/mongocxx/options/client_encryption.hpp + mongocxx/v_noabi/mongocxx/options/client_session.hpp + mongocxx/v_noabi/mongocxx/options/client.hpp + mongocxx/v_noabi/mongocxx/options/count.hpp + mongocxx/v_noabi/mongocxx/options/create_collection.hpp + mongocxx/v_noabi/mongocxx/options/data_key.hpp + mongocxx/v_noabi/mongocxx/options/delete.hpp + mongocxx/v_noabi/mongocxx/options/distinct.hpp + mongocxx/v_noabi/mongocxx/options/encrypt.hpp + mongocxx/v_noabi/mongocxx/options/estimated_document_count.hpp + mongocxx/v_noabi/mongocxx/options/find_one_and_delete.hpp + mongocxx/v_noabi/mongocxx/options/find_one_and_replace.hpp + mongocxx/v_noabi/mongocxx/options/find_one_and_update.hpp + mongocxx/v_noabi/mongocxx/options/find_one_common_options.hpp + mongocxx/v_noabi/mongocxx/options/find.hpp + mongocxx/v_noabi/mongocxx/options/gridfs/bucket.hpp + mongocxx/v_noabi/mongocxx/options/gridfs/upload.hpp + mongocxx/v_noabi/mongocxx/options/index_view.hpp + mongocxx/v_noabi/mongocxx/options/index.hpp + mongocxx/v_noabi/mongocxx/options/insert.hpp + mongocxx/v_noabi/mongocxx/options/pool.hpp + mongocxx/v_noabi/mongocxx/options/range.hpp + mongocxx/v_noabi/mongocxx/options/replace.hpp + mongocxx/v_noabi/mongocxx/options/rewrap_many_datakey.hpp + mongocxx/v_noabi/mongocxx/options/server_api.hpp + mongocxx/v_noabi/mongocxx/options/ssl.hpp + mongocxx/v_noabi/mongocxx/options/tls.hpp + mongocxx/v_noabi/mongocxx/options/transaction.hpp + mongocxx/v_noabi/mongocxx/options/update.hpp + mongocxx/v_noabi/mongocxx/pipeline.hpp + mongocxx/v_noabi/mongocxx/pool.hpp + mongocxx/v_noabi/mongocxx/read_concern.hpp + mongocxx/v_noabi/mongocxx/read_preference.hpp + mongocxx/v_noabi/mongocxx/result/bulk_write.hpp + mongocxx/v_noabi/mongocxx/result/delete.hpp + mongocxx/v_noabi/mongocxx/result/gridfs/upload.hpp + mongocxx/v_noabi/mongocxx/result/insert_many.hpp + mongocxx/v_noabi/mongocxx/result/insert_one.hpp + mongocxx/v_noabi/mongocxx/result/replace_one.hpp + mongocxx/v_noabi/mongocxx/result/rewrap_many_datakey.hpp + mongocxx/v_noabi/mongocxx/result/update.hpp + mongocxx/v_noabi/mongocxx/search_index_model.hpp + mongocxx/v_noabi/mongocxx/search_index_view.hpp + mongocxx/v_noabi/mongocxx/stdx.hpp + mongocxx/v_noabi/mongocxx/uri.hpp + mongocxx/v_noabi/mongocxx/validation_criteria.hpp + mongocxx/v_noabi/mongocxx/write_concern.hpp + mongocxx/v_noabi/mongocxx/write_type.hpp +) From 0b7246bf1783b13273dd7d13c73fe73e08b7309e Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Fri, 22 Sep 2023 13:12:35 -0500 Subject: [PATCH 06/11] Move lib commands into lib/CMakeLists.txt --- src/bsoncxx/CMakeLists.txt | 58 +--- src/bsoncxx/lib/CMakeLists.txt | 100 ++++++ .../v_noabi/bsoncxx/config/CMakeLists.txt | 44 --- src/mongocxx/CMakeLists.txt | 234 +------------- src/mongocxx/lib/CMakeLists.txt | 288 ++++++++++++++++++ .../v_noabi/mongocxx/config/CMakeLists.txt | 56 ---- 6 files changed, 400 insertions(+), 380 deletions(-) create mode 100644 src/bsoncxx/lib/CMakeLists.txt delete mode 100644 src/bsoncxx/lib/bsoncxx/v_noabi/bsoncxx/config/CMakeLists.txt create mode 100644 src/mongocxx/lib/CMakeLists.txt delete mode 100644 src/mongocxx/lib/mongocxx/v_noabi/mongocxx/config/CMakeLists.txt diff --git a/src/bsoncxx/CMakeLists.txt b/src/bsoncxx/CMakeLists.txt index 2de2561ea6..2b085ed4fe 100644 --- a/src/bsoncxx/CMakeLists.txt +++ b/src/bsoncxx/CMakeLists.txt @@ -122,30 +122,12 @@ else() endif() endif() +set(bsoncxx_sources "") # Required by bsoncxx_add_library(). + add_subdirectory(cmake) add_subdirectory(include) +add_subdirectory(lib) add_subdirectory(third_party) -add_subdirectory(lib/bsoncxx/v_noabi/bsoncxx/config) - -set(bsoncxx_sources - lib/bsoncxx/v_noabi/bsoncxx/array/element.cpp - lib/bsoncxx/v_noabi/bsoncxx/array/value.cpp - lib/bsoncxx/v_noabi/bsoncxx/array/view.cpp - lib/bsoncxx/v_noabi/bsoncxx/builder/core.cpp - lib/bsoncxx/v_noabi/bsoncxx/decimal128.cpp - lib/bsoncxx/v_noabi/bsoncxx/document/element.cpp - lib/bsoncxx/v_noabi/bsoncxx/document/value.cpp - lib/bsoncxx/v_noabi/bsoncxx/document/view.cpp - lib/bsoncxx/v_noabi/bsoncxx/exception/error_code.cpp - lib/bsoncxx/v_noabi/bsoncxx/json.cpp - lib/bsoncxx/v_noabi/bsoncxx/oid.cpp - lib/bsoncxx/v_noabi/bsoncxx/private/itoa.cpp - lib/bsoncxx/v_noabi/bsoncxx/string/view_or_value.cpp - lib/bsoncxx/v_noabi/bsoncxx/types.cpp - lib/bsoncxx/v_noabi/bsoncxx/types/bson_value/value.cpp - lib/bsoncxx/v_noabi/bsoncxx/types/bson_value/view.cpp - lib/bsoncxx/v_noabi/bsoncxx/validate.cpp -) include(BsoncxxUtil) @@ -228,43 +210,15 @@ if(ENABLE_TESTS) add_subdirectory(test) endif() -set_local_dist(src_bsoncxx_lib_v_noabi_DIST_local +set_local_dist(src_bsoncxx_DIST_local CMakeLists.txt - lib/bsoncxx/v_noabi/bsoncxx/array/element.cpp - lib/bsoncxx/v_noabi/bsoncxx/array/value.cpp - lib/bsoncxx/v_noabi/bsoncxx/array/view.cpp - lib/bsoncxx/v_noabi/bsoncxx/builder/core.cpp - lib/bsoncxx/v_noabi/bsoncxx/decimal128.cpp - lib/bsoncxx/v_noabi/bsoncxx/document/element.cpp - lib/bsoncxx/v_noabi/bsoncxx/document/value.cpp - lib/bsoncxx/v_noabi/bsoncxx/document/view.cpp - lib/bsoncxx/v_noabi/bsoncxx/exception/error_code.cpp - lib/bsoncxx/v_noabi/bsoncxx/json.cpp - lib/bsoncxx/v_noabi/bsoncxx/oid.cpp - lib/bsoncxx/v_noabi/bsoncxx/private/b64_ntop.hh - lib/bsoncxx/v_noabi/bsoncxx/private/helpers.hh - lib/bsoncxx/v_noabi/bsoncxx/private/itoa.cpp - lib/bsoncxx/v_noabi/bsoncxx/private/itoa.hh - lib/bsoncxx/v_noabi/bsoncxx/private/libbson.hh - lib/bsoncxx/v_noabi/bsoncxx/private/stack.hh - lib/bsoncxx/v_noabi/bsoncxx/private/suppress_deprecation_warnings.hh - lib/bsoncxx/v_noabi/bsoncxx/string/view_or_value.cpp - lib/bsoncxx/v_noabi/bsoncxx/test_util/catch.hh - lib/bsoncxx/v_noabi/bsoncxx/test_util/export_for_testing.hh - lib/bsoncxx/v_noabi/bsoncxx/test_util/to_string.hh - lib/bsoncxx/v_noabi/bsoncxx/types.cpp - lib/bsoncxx/v_noabi/bsoncxx/types/private/convert.hh - lib/bsoncxx/v_noabi/bsoncxx/types/bson_value/private/value.hh - lib/bsoncxx/v_noabi/bsoncxx/types/bson_value/value.cpp - lib/bsoncxx/v_noabi/bsoncxx/types/bson_value/view.cpp - lib/bsoncxx/v_noabi/bsoncxx/validate.cpp ) set(src_bsoncxx_DIST + ${src_bsoncxx_DIST_local} ${src_bsoncxx_cmake_DIST} ${src_bsoncxx_include_DIST} - ${src_bsoncxx_lib_v_noabi_DIST_local} - ${src_bsoncxx_config_DIST} + ${src_bsoncxx_lib_DIST} ${src_bsoncxx_third_party_DIST} ${src_bsoncxx_test_DIST} PARENT_SCOPE diff --git a/src/bsoncxx/lib/CMakeLists.txt b/src/bsoncxx/lib/CMakeLists.txt new file mode 100644 index 0000000000..28f4e8520d --- /dev/null +++ b/src/bsoncxx/lib/CMakeLists.txt @@ -0,0 +1,100 @@ +# Copyright 2023 MongoDB Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +list(APPEND bsoncxx_sources + bsoncxx/v_noabi/bsoncxx/array/element.cpp + bsoncxx/v_noabi/bsoncxx/array/value.cpp + bsoncxx/v_noabi/bsoncxx/array/view.cpp + bsoncxx/v_noabi/bsoncxx/builder/core.cpp + bsoncxx/v_noabi/bsoncxx/decimal128.cpp + bsoncxx/v_noabi/bsoncxx/document/element.cpp + bsoncxx/v_noabi/bsoncxx/document/value.cpp + bsoncxx/v_noabi/bsoncxx/document/view.cpp + bsoncxx/v_noabi/bsoncxx/exception/error_code.cpp + bsoncxx/v_noabi/bsoncxx/json.cpp + bsoncxx/v_noabi/bsoncxx/oid.cpp + bsoncxx/v_noabi/bsoncxx/private/itoa.cpp + bsoncxx/v_noabi/bsoncxx/string/view_or_value.cpp + bsoncxx/v_noabi/bsoncxx/types.cpp + bsoncxx/v_noabi/bsoncxx/types/bson_value/value.cpp + bsoncxx/v_noabi/bsoncxx/types/bson_value/view.cpp + bsoncxx/v_noabi/bsoncxx/validate.cpp +) +list(TRANSFORM bsoncxx_sources PREPEND "${CMAKE_CURRENT_SOURCE_DIR}/") +set(bsoncxx_sources "${bsoncxx_sources}" PARENT_SCOPE) + +# Generate private headers. +if(1) + configure_file( + bsoncxx/v_noabi/bsoncxx/config/private/config.hh.in + bsoncxx/v_noabi/bsoncxx/config/private/config.hh + ) +endif() + +# Generate and install public headers. +if(1) + configure_file( + bsoncxx/v_noabi/bsoncxx/config/config.hpp.in + bsoncxx/v_noabi/bsoncxx/config/config.hpp + ) + + configure_file( + bsoncxx/v_noabi/bsoncxx/config/version.hpp.in + bsoncxx/v_noabi/bsoncxx/config/version.hpp + ) + + install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/bsoncxx/v_noabi/bsoncxx/config/config.hpp + ${CMAKE_CURRENT_BINARY_DIR}/bsoncxx/v_noabi/bsoncxx/config/version.hpp + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/bsoncxx/v_noabi/bsoncxx/config + COMPONENT dev + ) +endif() + +set_dist_list(src_bsoncxx_lib_DIST + CMakeLists.txt + bsoncxx/v_noabi/bsoncxx/array/element.cpp + bsoncxx/v_noabi/bsoncxx/array/value.cpp + bsoncxx/v_noabi/bsoncxx/array/view.cpp + bsoncxx/v_noabi/bsoncxx/builder/core.cpp + bsoncxx/v_noabi/bsoncxx/config/config.hpp.in + bsoncxx/v_noabi/bsoncxx/config/private/config.hh.in + bsoncxx/v_noabi/bsoncxx/config/private/postlude.hh + bsoncxx/v_noabi/bsoncxx/config/private/prelude.hh + bsoncxx/v_noabi/bsoncxx/config/version.hpp.in + bsoncxx/v_noabi/bsoncxx/decimal128.cpp + bsoncxx/v_noabi/bsoncxx/document/element.cpp + bsoncxx/v_noabi/bsoncxx/document/value.cpp + bsoncxx/v_noabi/bsoncxx/document/view.cpp + bsoncxx/v_noabi/bsoncxx/exception/error_code.cpp + bsoncxx/v_noabi/bsoncxx/json.cpp + bsoncxx/v_noabi/bsoncxx/oid.cpp + bsoncxx/v_noabi/bsoncxx/private/b64_ntop.hh + bsoncxx/v_noabi/bsoncxx/private/helpers.hh + bsoncxx/v_noabi/bsoncxx/private/itoa.cpp + bsoncxx/v_noabi/bsoncxx/private/itoa.hh + bsoncxx/v_noabi/bsoncxx/private/libbson.hh + bsoncxx/v_noabi/bsoncxx/private/stack.hh + bsoncxx/v_noabi/bsoncxx/private/suppress_deprecation_warnings.hh + bsoncxx/v_noabi/bsoncxx/string/view_or_value.cpp + bsoncxx/v_noabi/bsoncxx/test_util/catch.hh + bsoncxx/v_noabi/bsoncxx/test_util/export_for_testing.hh + bsoncxx/v_noabi/bsoncxx/test_util/to_string.hh + bsoncxx/v_noabi/bsoncxx/types.cpp + bsoncxx/v_noabi/bsoncxx/types/bson_value/private/value.hh + bsoncxx/v_noabi/bsoncxx/types/bson_value/value.cpp + bsoncxx/v_noabi/bsoncxx/types/bson_value/view.cpp + bsoncxx/v_noabi/bsoncxx/types/private/convert.hh + bsoncxx/v_noabi/bsoncxx/validate.cpp +) diff --git a/src/bsoncxx/lib/bsoncxx/v_noabi/bsoncxx/config/CMakeLists.txt b/src/bsoncxx/lib/bsoncxx/v_noabi/bsoncxx/config/CMakeLists.txt deleted file mode 100644 index 8756118de5..0000000000 --- a/src/bsoncxx/lib/bsoncxx/v_noabi/bsoncxx/config/CMakeLists.txt +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright 2016 MongoDB Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/config.hpp.in - ${CMAKE_CURRENT_BINARY_DIR}/config.hpp -) - -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/private/config.hh.in - ${CMAKE_CURRENT_BINARY_DIR}/private/config.hh -) - -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/version.hpp.in - ${CMAKE_CURRENT_BINARY_DIR}/version.hpp -) - -install(FILES - ${CMAKE_CURRENT_BINARY_DIR}/config.hpp - ${CMAKE_CURRENT_BINARY_DIR}/version.hpp - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/bsoncxx/v_noabi/bsoncxx/config - COMPONENT dev -) - -set_dist_list(src_bsoncxx_config_DIST - CMakeLists.txt - config.hpp.in - private/config.hh.in - private/postlude.hh - private/prelude.hh - version.hpp.in -) diff --git a/src/mongocxx/CMakeLists.txt b/src/mongocxx/CMakeLists.txt index 49ad08ac04..6f0691916f 100644 --- a/src/mongocxx/CMakeLists.txt +++ b/src/mongocxx/CMakeLists.txt @@ -71,105 +71,11 @@ else() endif() endif() +set(mongocxx_sources "") # Required by mongocxx_add_library(). + add_subdirectory(cmake) add_subdirectory(include) -add_subdirectory(lib/mongocxx/v_noabi/mongocxx/config) - -set(mongocxx_sources - lib/mongocxx/v_noabi/mongocxx/bulk_write.cpp - lib/mongocxx/v_noabi/mongocxx/client.cpp - lib/mongocxx/v_noabi/mongocxx/client_encryption.cpp - lib/mongocxx/v_noabi/mongocxx/client_session.cpp - lib/mongocxx/v_noabi/mongocxx/change_stream.cpp - lib/mongocxx/v_noabi/mongocxx/collection.cpp - lib/mongocxx/v_noabi/mongocxx/cursor.cpp - lib/mongocxx/v_noabi/mongocxx/database.cpp - lib/mongocxx/v_noabi/mongocxx/events/command_failed_event.cpp - lib/mongocxx/v_noabi/mongocxx/events/command_started_event.cpp - lib/mongocxx/v_noabi/mongocxx/events/command_succeeded_event.cpp - lib/mongocxx/v_noabi/mongocxx/events/heartbeat_failed_event.cpp - lib/mongocxx/v_noabi/mongocxx/events/heartbeat_started_event.cpp - lib/mongocxx/v_noabi/mongocxx/events/heartbeat_succeeded_event.cpp - lib/mongocxx/v_noabi/mongocxx/events/server_changed_event.cpp - lib/mongocxx/v_noabi/mongocxx/events/server_closed_event.cpp - lib/mongocxx/v_noabi/mongocxx/events/server_description.cpp - lib/mongocxx/v_noabi/mongocxx/events/server_opening_event.cpp - lib/mongocxx/v_noabi/mongocxx/events/topology_changed_event.cpp - lib/mongocxx/v_noabi/mongocxx/events/topology_closed_event.cpp - lib/mongocxx/v_noabi/mongocxx/events/topology_description.cpp - lib/mongocxx/v_noabi/mongocxx/events/topology_opening_event.cpp - lib/mongocxx/v_noabi/mongocxx/exception/error_code.cpp - lib/mongocxx/v_noabi/mongocxx/exception/operation_exception.cpp - lib/mongocxx/v_noabi/mongocxx/exception/server_error_code.cpp - lib/mongocxx/v_noabi/mongocxx/gridfs/bucket.cpp - lib/mongocxx/v_noabi/mongocxx/gridfs/downloader.cpp - lib/mongocxx/v_noabi/mongocxx/gridfs/uploader.cpp - lib/mongocxx/v_noabi/mongocxx/hint.cpp - lib/mongocxx/v_noabi/mongocxx/index_model.cpp - lib/mongocxx/v_noabi/mongocxx/index_view.cpp - lib/mongocxx/v_noabi/mongocxx/instance.cpp - lib/mongocxx/v_noabi/mongocxx/logger.cpp - lib/mongocxx/v_noabi/mongocxx/model/delete_many.cpp - lib/mongocxx/v_noabi/mongocxx/model/delete_one.cpp - lib/mongocxx/v_noabi/mongocxx/model/insert_one.cpp - lib/mongocxx/v_noabi/mongocxx/model/replace_one.cpp - lib/mongocxx/v_noabi/mongocxx/model/update_many.cpp - lib/mongocxx/v_noabi/mongocxx/model/update_one.cpp - lib/mongocxx/v_noabi/mongocxx/model/write.cpp - lib/mongocxx/v_noabi/mongocxx/options/aggregate.cpp - lib/mongocxx/v_noabi/mongocxx/options/apm.cpp - lib/mongocxx/v_noabi/mongocxx/options/auto_encryption.cpp - lib/mongocxx/v_noabi/mongocxx/options/bulk_write.cpp - lib/mongocxx/v_noabi/mongocxx/options/change_stream.cpp - lib/mongocxx/v_noabi/mongocxx/options/client.cpp - lib/mongocxx/v_noabi/mongocxx/options/client_encryption.cpp - lib/mongocxx/v_noabi/mongocxx/options/client_session.cpp - lib/mongocxx/v_noabi/mongocxx/options/count.cpp - lib/mongocxx/v_noabi/mongocxx/options/estimated_document_count.cpp - lib/mongocxx/v_noabi/mongocxx/options/create_collection.cpp - lib/mongocxx/v_noabi/mongocxx/options/data_key.cpp - lib/mongocxx/v_noabi/mongocxx/options/delete.cpp - lib/mongocxx/v_noabi/mongocxx/options/distinct.cpp - lib/mongocxx/v_noabi/mongocxx/options/encrypt.cpp - lib/mongocxx/v_noabi/mongocxx/options/find_one_and_delete.cpp - lib/mongocxx/v_noabi/mongocxx/options/find_one_and_replace.cpp - lib/mongocxx/v_noabi/mongocxx/options/find_one_and_update.cpp - lib/mongocxx/v_noabi/mongocxx/options/find.cpp - lib/mongocxx/v_noabi/mongocxx/options/gridfs/bucket.cpp - lib/mongocxx/v_noabi/mongocxx/options/gridfs/upload.cpp - lib/mongocxx/v_noabi/mongocxx/options/index.cpp - lib/mongocxx/v_noabi/mongocxx/options/index_view.cpp - lib/mongocxx/v_noabi/mongocxx/options/insert.cpp - lib/mongocxx/v_noabi/mongocxx/options/pool.cpp - lib/mongocxx/v_noabi/mongocxx/options/range.cpp - lib/mongocxx/v_noabi/mongocxx/options/replace.cpp - lib/mongocxx/v_noabi/mongocxx/options/rewrap_many_datakey.cpp - lib/mongocxx/v_noabi/mongocxx/options/server_api.cpp - lib/mongocxx/v_noabi/mongocxx/options/tls.cpp - lib/mongocxx/v_noabi/mongocxx/options/transaction.cpp - lib/mongocxx/v_noabi/mongocxx/options/update.cpp - lib/mongocxx/v_noabi/mongocxx/pipeline.cpp - lib/mongocxx/v_noabi/mongocxx/pool.cpp - lib/mongocxx/v_noabi/mongocxx/private/conversions.cpp - lib/mongocxx/v_noabi/mongocxx/private/libbson.cpp - lib/mongocxx/v_noabi/mongocxx/private/libmongoc.cpp - lib/mongocxx/v_noabi/mongocxx/private/numeric_casting.cpp - lib/mongocxx/v_noabi/mongocxx/read_concern.cpp - lib/mongocxx/v_noabi/mongocxx/read_preference.cpp - lib/mongocxx/v_noabi/mongocxx/result/bulk_write.cpp - lib/mongocxx/v_noabi/mongocxx/result/delete.cpp - lib/mongocxx/v_noabi/mongocxx/result/gridfs/upload.cpp - lib/mongocxx/v_noabi/mongocxx/result/insert_many.cpp - lib/mongocxx/v_noabi/mongocxx/result/insert_one.cpp - lib/mongocxx/v_noabi/mongocxx/result/replace_one.cpp - lib/mongocxx/v_noabi/mongocxx/result/rewrap_many_datakey.cpp - lib/mongocxx/v_noabi/mongocxx/result/update.cpp - lib/mongocxx/v_noabi/mongocxx/search_index_model.cpp - lib/mongocxx/v_noabi/mongocxx/search_index_view.cpp - lib/mongocxx/v_noabi/mongocxx/uri.cpp - lib/mongocxx/v_noabi/mongocxx/validation_criteria.cpp - lib/mongocxx/v_noabi/mongocxx/write_concern.cpp -) +add_subdirectory(lib) include(MongocxxUtil) @@ -259,143 +165,15 @@ if(ENABLE_TESTS) add_subdirectory(test) endif() -set_local_dist(src_mongocxx_lib_v_noabi_DIST_local +set_local_dist(src_mongocxx_DIST_local CMakeLists.txt - lib/mongocxx/v_noabi/mongocxx/bulk_write.cpp - lib/mongocxx/v_noabi/mongocxx/change_stream.cpp - lib/mongocxx/v_noabi/mongocxx/client.cpp - lib/mongocxx/v_noabi/mongocxx/client_encryption.cpp - lib/mongocxx/v_noabi/mongocxx/client_session.cpp - lib/mongocxx/v_noabi/mongocxx/collection.cpp - lib/mongocxx/v_noabi/mongocxx/cursor.cpp - lib/mongocxx/v_noabi/mongocxx/database.cpp - lib/mongocxx/v_noabi/mongocxx/events/command_failed_event.cpp - lib/mongocxx/v_noabi/mongocxx/events/command_started_event.cpp - lib/mongocxx/v_noabi/mongocxx/events/command_succeeded_event.cpp - lib/mongocxx/v_noabi/mongocxx/events/heartbeat_failed_event.cpp - lib/mongocxx/v_noabi/mongocxx/events/heartbeat_started_event.cpp - lib/mongocxx/v_noabi/mongocxx/events/heartbeat_succeeded_event.cpp - lib/mongocxx/v_noabi/mongocxx/events/server_changed_event.cpp - lib/mongocxx/v_noabi/mongocxx/events/server_closed_event.cpp - lib/mongocxx/v_noabi/mongocxx/events/server_description.cpp - lib/mongocxx/v_noabi/mongocxx/events/server_opening_event.cpp - lib/mongocxx/v_noabi/mongocxx/events/topology_changed_event.cpp - lib/mongocxx/v_noabi/mongocxx/events/topology_closed_event.cpp - lib/mongocxx/v_noabi/mongocxx/events/topology_description.cpp - lib/mongocxx/v_noabi/mongocxx/events/topology_opening_event.cpp - lib/mongocxx/v_noabi/mongocxx/exception/error_code.cpp - lib/mongocxx/v_noabi/mongocxx/exception/operation_exception.cpp - lib/mongocxx/v_noabi/mongocxx/exception/private/mongoc_error.hh - lib/mongocxx/v_noabi/mongocxx/exception/server_error_code.cpp - lib/mongocxx/v_noabi/mongocxx/gridfs/bucket.cpp - lib/mongocxx/v_noabi/mongocxx/gridfs/downloader.cpp - lib/mongocxx/v_noabi/mongocxx/gridfs/private/bucket.hh - lib/mongocxx/v_noabi/mongocxx/gridfs/private/downloader.hh - lib/mongocxx/v_noabi/mongocxx/gridfs/private/uploader.hh - lib/mongocxx/v_noabi/mongocxx/gridfs/uploader.cpp - lib/mongocxx/v_noabi/mongocxx/hint.cpp - lib/mongocxx/v_noabi/mongocxx/index_model.cpp - lib/mongocxx/v_noabi/mongocxx/index_view.cpp - lib/mongocxx/v_noabi/mongocxx/instance.cpp - lib/mongocxx/v_noabi/mongocxx/logger.cpp - lib/mongocxx/v_noabi/mongocxx/model/delete_many.cpp - lib/mongocxx/v_noabi/mongocxx/model/delete_one.cpp - lib/mongocxx/v_noabi/mongocxx/model/insert_one.cpp - lib/mongocxx/v_noabi/mongocxx/model/replace_one.cpp - lib/mongocxx/v_noabi/mongocxx/model/update_many.cpp - lib/mongocxx/v_noabi/mongocxx/model/update_one.cpp - lib/mongocxx/v_noabi/mongocxx/model/write.cpp - lib/mongocxx/v_noabi/mongocxx/options/aggregate.cpp - lib/mongocxx/v_noabi/mongocxx/options/apm.cpp - lib/mongocxx/v_noabi/mongocxx/options/auto_encryption.cpp - lib/mongocxx/v_noabi/mongocxx/options/bulk_write.cpp - lib/mongocxx/v_noabi/mongocxx/options/change_stream.cpp - lib/mongocxx/v_noabi/mongocxx/options/client.cpp - lib/mongocxx/v_noabi/mongocxx/options/client_encryption.cpp - lib/mongocxx/v_noabi/mongocxx/options/client_session.cpp - lib/mongocxx/v_noabi/mongocxx/options/count.cpp - lib/mongocxx/v_noabi/mongocxx/options/create_collection.cpp - lib/mongocxx/v_noabi/mongocxx/options/data_key.cpp - lib/mongocxx/v_noabi/mongocxx/options/delete.cpp - lib/mongocxx/v_noabi/mongocxx/options/distinct.cpp - lib/mongocxx/v_noabi/mongocxx/options/encrypt.cpp - lib/mongocxx/v_noabi/mongocxx/options/estimated_document_count.cpp - lib/mongocxx/v_noabi/mongocxx/options/find.cpp - lib/mongocxx/v_noabi/mongocxx/options/find_one_and_delete.cpp - lib/mongocxx/v_noabi/mongocxx/options/find_one_and_replace.cpp - lib/mongocxx/v_noabi/mongocxx/options/find_one_and_update.cpp - lib/mongocxx/v_noabi/mongocxx/options/gridfs/bucket.cpp - lib/mongocxx/v_noabi/mongocxx/options/gridfs/upload.cpp - lib/mongocxx/v_noabi/mongocxx/options/index.cpp - lib/mongocxx/v_noabi/mongocxx/options/index_view.cpp - lib/mongocxx/v_noabi/mongocxx/options/insert.cpp - lib/mongocxx/v_noabi/mongocxx/options/pool.cpp - lib/mongocxx/v_noabi/mongocxx/options/private/apm.hh - lib/mongocxx/v_noabi/mongocxx/options/private/server_api.hh - lib/mongocxx/v_noabi/mongocxx/options/private/ssl.hh - lib/mongocxx/v_noabi/mongocxx/options/private/transaction.hh - lib/mongocxx/v_noabi/mongocxx/options/range.cpp - lib/mongocxx/v_noabi/mongocxx/options/replace.cpp - lib/mongocxx/v_noabi/mongocxx/options/rewrap_many_datakey.cpp - lib/mongocxx/v_noabi/mongocxx/options/server_api.cpp - lib/mongocxx/v_noabi/mongocxx/options/tls.cpp - lib/mongocxx/v_noabi/mongocxx/options/transaction.cpp - lib/mongocxx/v_noabi/mongocxx/options/update.cpp - lib/mongocxx/v_noabi/mongocxx/pipeline.cpp - lib/mongocxx/v_noabi/mongocxx/pool.cpp - lib/mongocxx/v_noabi/mongocxx/private/append_aggregate_options.hh - lib/mongocxx/v_noabi/mongocxx/private/bulk_write.hh - lib/mongocxx/v_noabi/mongocxx/private/change_stream.hh - lib/mongocxx/v_noabi/mongocxx/private/client.hh - lib/mongocxx/v_noabi/mongocxx/private/client_encryption.hh - lib/mongocxx/v_noabi/mongocxx/private/client_session.hh - lib/mongocxx/v_noabi/mongocxx/private/collection.hh - lib/mongocxx/v_noabi/mongocxx/private/conversions.cpp - lib/mongocxx/v_noabi/mongocxx/private/conversions.hh - lib/mongocxx/v_noabi/mongocxx/private/cursor.hh - lib/mongocxx/v_noabi/mongocxx/private/database.hh - lib/mongocxx/v_noabi/mongocxx/private/index_view.hh - lib/mongocxx/v_noabi/mongocxx/private/libbson.cpp - lib/mongocxx/v_noabi/mongocxx/private/libbson.hh - lib/mongocxx/v_noabi/mongocxx/private/libmongoc.cpp - lib/mongocxx/v_noabi/mongocxx/private/libmongoc.hh - lib/mongocxx/v_noabi/mongocxx/private/libmongoc_symbols.hh - lib/mongocxx/v_noabi/mongocxx/private/numeric_casting.cpp - lib/mongocxx/v_noabi/mongocxx/private/numeric_casting.hh - lib/mongocxx/v_noabi/mongocxx/private/pipeline.hh - lib/mongocxx/v_noabi/mongocxx/private/pool.hh - lib/mongocxx/v_noabi/mongocxx/private/read_concern.hh - lib/mongocxx/v_noabi/mongocxx/private/read_preference.hh - lib/mongocxx/v_noabi/mongocxx/private/search_index_model.hh - lib/mongocxx/v_noabi/mongocxx/private/search_index_view.hh - lib/mongocxx/v_noabi/mongocxx/private/uri.hh - lib/mongocxx/v_noabi/mongocxx/private/write_concern.hh - lib/mongocxx/v_noabi/mongocxx/read_concern.cpp - lib/mongocxx/v_noabi/mongocxx/read_preference.cpp - lib/mongocxx/v_noabi/mongocxx/result/bulk_write.cpp - lib/mongocxx/v_noabi/mongocxx/result/delete.cpp - lib/mongocxx/v_noabi/mongocxx/result/gridfs/upload.cpp - lib/mongocxx/v_noabi/mongocxx/result/insert_many.cpp - lib/mongocxx/v_noabi/mongocxx/result/insert_one.cpp - lib/mongocxx/v_noabi/mongocxx/result/replace_one.cpp - lib/mongocxx/v_noabi/mongocxx/result/rewrap_many_datakey.cpp - lib/mongocxx/v_noabi/mongocxx/result/update.cpp - lib/mongocxx/v_noabi/mongocxx/search_index_model.cpp - lib/mongocxx/v_noabi/mongocxx/search_index_view.cpp - lib/mongocxx/v_noabi/mongocxx/test_util/client_helpers.cpp - lib/mongocxx/v_noabi/mongocxx/test_util/client_helpers.hh - lib/mongocxx/v_noabi/mongocxx/test_util/export_for_testing.hh - lib/mongocxx/v_noabi/mongocxx/test_util/mock.hh - lib/mongocxx/v_noabi/mongocxx/uri.cpp - lib/mongocxx/v_noabi/mongocxx/validation_criteria.cpp - lib/mongocxx/v_noabi/mongocxx/write_concern.cpp ) set(src_mongocxx_DIST + ${src_mongocxx_DIST_local} ${src_mongocxx_cmake_DIST} ${src_mongocxx_include_DIST} - ${src_mongocxx_lib_v_noabi_DIST_local} - ${src_mongocxx_config_DIST} + ${src_mongocxx_lib_DIST} ${src_mongocxx_test_DIST} PARENT_SCOPE ) diff --git a/src/mongocxx/lib/CMakeLists.txt b/src/mongocxx/lib/CMakeLists.txt new file mode 100644 index 0000000000..e39994294f --- /dev/null +++ b/src/mongocxx/lib/CMakeLists.txt @@ -0,0 +1,288 @@ +# Copyright 2023 MongoDB Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +list(APPEND mongocxx_sources + mongocxx/v_noabi/mongocxx/bulk_write.cpp + mongocxx/v_noabi/mongocxx/change_stream.cpp + mongocxx/v_noabi/mongocxx/client.cpp + mongocxx/v_noabi/mongocxx/client_encryption.cpp + mongocxx/v_noabi/mongocxx/client_session.cpp + mongocxx/v_noabi/mongocxx/collection.cpp + mongocxx/v_noabi/mongocxx/cursor.cpp + mongocxx/v_noabi/mongocxx/database.cpp + mongocxx/v_noabi/mongocxx/events/command_failed_event.cpp + mongocxx/v_noabi/mongocxx/events/command_started_event.cpp + mongocxx/v_noabi/mongocxx/events/command_succeeded_event.cpp + mongocxx/v_noabi/mongocxx/events/heartbeat_failed_event.cpp + mongocxx/v_noabi/mongocxx/events/heartbeat_started_event.cpp + mongocxx/v_noabi/mongocxx/events/heartbeat_succeeded_event.cpp + mongocxx/v_noabi/mongocxx/events/server_changed_event.cpp + mongocxx/v_noabi/mongocxx/events/server_closed_event.cpp + mongocxx/v_noabi/mongocxx/events/server_description.cpp + mongocxx/v_noabi/mongocxx/events/server_opening_event.cpp + mongocxx/v_noabi/mongocxx/events/topology_changed_event.cpp + mongocxx/v_noabi/mongocxx/events/topology_closed_event.cpp + mongocxx/v_noabi/mongocxx/events/topology_description.cpp + mongocxx/v_noabi/mongocxx/events/topology_opening_event.cpp + mongocxx/v_noabi/mongocxx/exception/error_code.cpp + mongocxx/v_noabi/mongocxx/exception/operation_exception.cpp + mongocxx/v_noabi/mongocxx/exception/server_error_code.cpp + mongocxx/v_noabi/mongocxx/gridfs/bucket.cpp + mongocxx/v_noabi/mongocxx/gridfs/downloader.cpp + mongocxx/v_noabi/mongocxx/gridfs/uploader.cpp + mongocxx/v_noabi/mongocxx/hint.cpp + mongocxx/v_noabi/mongocxx/index_model.cpp + mongocxx/v_noabi/mongocxx/index_view.cpp + mongocxx/v_noabi/mongocxx/instance.cpp + mongocxx/v_noabi/mongocxx/logger.cpp + mongocxx/v_noabi/mongocxx/model/delete_many.cpp + mongocxx/v_noabi/mongocxx/model/delete_one.cpp + mongocxx/v_noabi/mongocxx/model/insert_one.cpp + mongocxx/v_noabi/mongocxx/model/replace_one.cpp + mongocxx/v_noabi/mongocxx/model/update_many.cpp + mongocxx/v_noabi/mongocxx/model/update_one.cpp + mongocxx/v_noabi/mongocxx/model/write.cpp + mongocxx/v_noabi/mongocxx/options/aggregate.cpp + mongocxx/v_noabi/mongocxx/options/apm.cpp + mongocxx/v_noabi/mongocxx/options/auto_encryption.cpp + mongocxx/v_noabi/mongocxx/options/bulk_write.cpp + mongocxx/v_noabi/mongocxx/options/change_stream.cpp + mongocxx/v_noabi/mongocxx/options/client.cpp + mongocxx/v_noabi/mongocxx/options/client_encryption.cpp + mongocxx/v_noabi/mongocxx/options/client_session.cpp + mongocxx/v_noabi/mongocxx/options/count.cpp + mongocxx/v_noabi/mongocxx/options/create_collection.cpp + mongocxx/v_noabi/mongocxx/options/data_key.cpp + mongocxx/v_noabi/mongocxx/options/delete.cpp + mongocxx/v_noabi/mongocxx/options/distinct.cpp + mongocxx/v_noabi/mongocxx/options/encrypt.cpp + mongocxx/v_noabi/mongocxx/options/estimated_document_count.cpp + mongocxx/v_noabi/mongocxx/options/find.cpp + mongocxx/v_noabi/mongocxx/options/find_one_and_delete.cpp + mongocxx/v_noabi/mongocxx/options/find_one_and_replace.cpp + mongocxx/v_noabi/mongocxx/options/find_one_and_update.cpp + mongocxx/v_noabi/mongocxx/options/gridfs/bucket.cpp + mongocxx/v_noabi/mongocxx/options/gridfs/upload.cpp + mongocxx/v_noabi/mongocxx/options/index.cpp + mongocxx/v_noabi/mongocxx/options/index_view.cpp + mongocxx/v_noabi/mongocxx/options/insert.cpp + mongocxx/v_noabi/mongocxx/options/pool.cpp + mongocxx/v_noabi/mongocxx/options/range.cpp + mongocxx/v_noabi/mongocxx/options/replace.cpp + mongocxx/v_noabi/mongocxx/options/rewrap_many_datakey.cpp + mongocxx/v_noabi/mongocxx/options/server_api.cpp + mongocxx/v_noabi/mongocxx/options/tls.cpp + mongocxx/v_noabi/mongocxx/options/transaction.cpp + mongocxx/v_noabi/mongocxx/options/update.cpp + mongocxx/v_noabi/mongocxx/pipeline.cpp + mongocxx/v_noabi/mongocxx/pool.cpp + mongocxx/v_noabi/mongocxx/private/conversions.cpp + mongocxx/v_noabi/mongocxx/private/libbson.cpp + mongocxx/v_noabi/mongocxx/private/libmongoc.cpp + mongocxx/v_noabi/mongocxx/private/numeric_casting.cpp + mongocxx/v_noabi/mongocxx/read_concern.cpp + mongocxx/v_noabi/mongocxx/read_preference.cpp + mongocxx/v_noabi/mongocxx/result/bulk_write.cpp + mongocxx/v_noabi/mongocxx/result/delete.cpp + mongocxx/v_noabi/mongocxx/result/gridfs/upload.cpp + mongocxx/v_noabi/mongocxx/result/insert_many.cpp + mongocxx/v_noabi/mongocxx/result/insert_one.cpp + mongocxx/v_noabi/mongocxx/result/replace_one.cpp + mongocxx/v_noabi/mongocxx/result/rewrap_many_datakey.cpp + mongocxx/v_noabi/mongocxx/result/update.cpp + mongocxx/v_noabi/mongocxx/search_index_model.cpp + mongocxx/v_noabi/mongocxx/search_index_view.cpp + mongocxx/v_noabi/mongocxx/uri.cpp + mongocxx/v_noabi/mongocxx/validation_criteria.cpp + mongocxx/v_noabi/mongocxx/write_concern.cpp +) +list(TRANSFORM mongocxx_sources PREPEND "${CMAKE_CURRENT_SOURCE_DIR}/") +set(mongocxx_sources "${mongocxx_sources}" PARENT_SCOPE) + +# Generate private headers. +if(1) + if(DEFINED CMAKE_CXX_COMPILER_ID) + set(MONGOCXX_COMPILER_ID "${CMAKE_CXX_COMPILER_ID}") + else() + set(MONGOCXX_COMPILER_ID "Unknown") + endif() + + if(DEFINED CMAKE_CXX_COMPILER_VERSION) + set(MONGOCXX_COMPILER_VERSION "${CMAKE_CXX_COMPILER_VERSION}") + else() + set(MONGOCXX_COMPILER_VERSION "Unknown") + endif() + + configure_file( + mongocxx/v_noabi/mongocxx/config/private/config.hh.in + mongocxx/v_noabi/mongocxx/config/private/config.hh + ) +endif() + +# Generate and install public headers. +if(1) + configure_file( + mongocxx/v_noabi/mongocxx/config/version.hpp.in + mongocxx/v_noabi/mongocxx/config/version.hpp + ) + + configure_file( + mongocxx/v_noabi/mongocxx/config/config.hpp.in + mongocxx/v_noabi/mongocxx/config/config.hpp + ) + + install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/mongocxx/v_noabi/mongocxx/config/config.hpp + ${CMAKE_CURRENT_BINARY_DIR}/mongocxx/v_noabi/mongocxx/config/version.hpp + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/mongocxx/v_noabi/mongocxx/config + COMPONENT dev + ) +endif() + +set_dist_list(src_mongocxx_lib_DIST + CMakeLists.txt + mongocxx/v_noabi/mongocxx/bulk_write.cpp + mongocxx/v_noabi/mongocxx/change_stream.cpp + mongocxx/v_noabi/mongocxx/client_encryption.cpp + mongocxx/v_noabi/mongocxx/client_session.cpp + mongocxx/v_noabi/mongocxx/client.cpp + mongocxx/v_noabi/mongocxx/collection.cpp + mongocxx/v_noabi/mongocxx/config/config.hpp.in + mongocxx/v_noabi/mongocxx/config/private/config.hh.in + mongocxx/v_noabi/mongocxx/config/private/postlude.hh + mongocxx/v_noabi/mongocxx/config/private/prelude.hh + mongocxx/v_noabi/mongocxx/config/version.hpp.in + mongocxx/v_noabi/mongocxx/cursor.cpp + mongocxx/v_noabi/mongocxx/database.cpp + mongocxx/v_noabi/mongocxx/events/command_failed_event.cpp + mongocxx/v_noabi/mongocxx/events/command_started_event.cpp + mongocxx/v_noabi/mongocxx/events/command_succeeded_event.cpp + mongocxx/v_noabi/mongocxx/events/heartbeat_failed_event.cpp + mongocxx/v_noabi/mongocxx/events/heartbeat_started_event.cpp + mongocxx/v_noabi/mongocxx/events/heartbeat_succeeded_event.cpp + mongocxx/v_noabi/mongocxx/events/server_changed_event.cpp + mongocxx/v_noabi/mongocxx/events/server_closed_event.cpp + mongocxx/v_noabi/mongocxx/events/server_description.cpp + mongocxx/v_noabi/mongocxx/events/server_opening_event.cpp + mongocxx/v_noabi/mongocxx/events/topology_changed_event.cpp + mongocxx/v_noabi/mongocxx/events/topology_closed_event.cpp + mongocxx/v_noabi/mongocxx/events/topology_description.cpp + mongocxx/v_noabi/mongocxx/events/topology_opening_event.cpp + mongocxx/v_noabi/mongocxx/exception/error_code.cpp + mongocxx/v_noabi/mongocxx/exception/operation_exception.cpp + mongocxx/v_noabi/mongocxx/exception/private/mongoc_error.hh + mongocxx/v_noabi/mongocxx/exception/server_error_code.cpp + mongocxx/v_noabi/mongocxx/gridfs/bucket.cpp + mongocxx/v_noabi/mongocxx/gridfs/downloader.cpp + mongocxx/v_noabi/mongocxx/gridfs/private/bucket.hh + mongocxx/v_noabi/mongocxx/gridfs/private/downloader.hh + mongocxx/v_noabi/mongocxx/gridfs/private/uploader.hh + mongocxx/v_noabi/mongocxx/gridfs/uploader.cpp + mongocxx/v_noabi/mongocxx/hint.cpp + mongocxx/v_noabi/mongocxx/index_model.cpp + mongocxx/v_noabi/mongocxx/index_view.cpp + mongocxx/v_noabi/mongocxx/instance.cpp + mongocxx/v_noabi/mongocxx/logger.cpp + mongocxx/v_noabi/mongocxx/model/delete_many.cpp + mongocxx/v_noabi/mongocxx/model/delete_one.cpp + mongocxx/v_noabi/mongocxx/model/insert_one.cpp + mongocxx/v_noabi/mongocxx/model/replace_one.cpp + mongocxx/v_noabi/mongocxx/model/update_many.cpp + mongocxx/v_noabi/mongocxx/model/update_one.cpp + mongocxx/v_noabi/mongocxx/model/write.cpp + mongocxx/v_noabi/mongocxx/options/aggregate.cpp + mongocxx/v_noabi/mongocxx/options/apm.cpp + mongocxx/v_noabi/mongocxx/options/auto_encryption.cpp + mongocxx/v_noabi/mongocxx/options/bulk_write.cpp + mongocxx/v_noabi/mongocxx/options/change_stream.cpp + mongocxx/v_noabi/mongocxx/options/client_encryption.cpp + mongocxx/v_noabi/mongocxx/options/client_session.cpp + mongocxx/v_noabi/mongocxx/options/client.cpp + mongocxx/v_noabi/mongocxx/options/count.cpp + mongocxx/v_noabi/mongocxx/options/create_collection.cpp + mongocxx/v_noabi/mongocxx/options/data_key.cpp + mongocxx/v_noabi/mongocxx/options/delete.cpp + mongocxx/v_noabi/mongocxx/options/distinct.cpp + mongocxx/v_noabi/mongocxx/options/encrypt.cpp + mongocxx/v_noabi/mongocxx/options/estimated_document_count.cpp + mongocxx/v_noabi/mongocxx/options/find_one_and_delete.cpp + mongocxx/v_noabi/mongocxx/options/find_one_and_replace.cpp + mongocxx/v_noabi/mongocxx/options/find_one_and_update.cpp + mongocxx/v_noabi/mongocxx/options/find.cpp + mongocxx/v_noabi/mongocxx/options/gridfs/bucket.cpp + mongocxx/v_noabi/mongocxx/options/gridfs/upload.cpp + mongocxx/v_noabi/mongocxx/options/index_view.cpp + mongocxx/v_noabi/mongocxx/options/index.cpp + mongocxx/v_noabi/mongocxx/options/insert.cpp + mongocxx/v_noabi/mongocxx/options/pool.cpp + mongocxx/v_noabi/mongocxx/options/private/apm.hh + mongocxx/v_noabi/mongocxx/options/private/server_api.hh + mongocxx/v_noabi/mongocxx/options/private/ssl.hh + mongocxx/v_noabi/mongocxx/options/private/transaction.hh + mongocxx/v_noabi/mongocxx/options/range.cpp + mongocxx/v_noabi/mongocxx/options/replace.cpp + mongocxx/v_noabi/mongocxx/options/rewrap_many_datakey.cpp + mongocxx/v_noabi/mongocxx/options/server_api.cpp + mongocxx/v_noabi/mongocxx/options/tls.cpp + mongocxx/v_noabi/mongocxx/options/transaction.cpp + mongocxx/v_noabi/mongocxx/options/update.cpp + mongocxx/v_noabi/mongocxx/pipeline.cpp + mongocxx/v_noabi/mongocxx/pool.cpp + mongocxx/v_noabi/mongocxx/private/append_aggregate_options.hh + mongocxx/v_noabi/mongocxx/private/bulk_write.hh + mongocxx/v_noabi/mongocxx/private/change_stream.hh + mongocxx/v_noabi/mongocxx/private/client_encryption.hh + mongocxx/v_noabi/mongocxx/private/client_session.hh + mongocxx/v_noabi/mongocxx/private/client.hh + mongocxx/v_noabi/mongocxx/private/collection.hh + mongocxx/v_noabi/mongocxx/private/conversions.cpp + mongocxx/v_noabi/mongocxx/private/conversions.hh + mongocxx/v_noabi/mongocxx/private/cursor.hh + mongocxx/v_noabi/mongocxx/private/database.hh + mongocxx/v_noabi/mongocxx/private/index_view.hh + mongocxx/v_noabi/mongocxx/private/libbson.cpp + mongocxx/v_noabi/mongocxx/private/libbson.hh + mongocxx/v_noabi/mongocxx/private/libmongoc_symbols.hh + mongocxx/v_noabi/mongocxx/private/libmongoc.cpp + mongocxx/v_noabi/mongocxx/private/libmongoc.hh + mongocxx/v_noabi/mongocxx/private/numeric_casting.cpp + mongocxx/v_noabi/mongocxx/private/numeric_casting.hh + mongocxx/v_noabi/mongocxx/private/pipeline.hh + mongocxx/v_noabi/mongocxx/private/pool.hh + mongocxx/v_noabi/mongocxx/private/read_concern.hh + mongocxx/v_noabi/mongocxx/private/read_preference.hh + mongocxx/v_noabi/mongocxx/private/search_index_model.hh + mongocxx/v_noabi/mongocxx/private/search_index_view.hh + mongocxx/v_noabi/mongocxx/private/uri.hh + mongocxx/v_noabi/mongocxx/private/write_concern.hh + mongocxx/v_noabi/mongocxx/read_concern.cpp + mongocxx/v_noabi/mongocxx/read_preference.cpp + mongocxx/v_noabi/mongocxx/result/bulk_write.cpp + mongocxx/v_noabi/mongocxx/result/delete.cpp + mongocxx/v_noabi/mongocxx/result/gridfs/upload.cpp + mongocxx/v_noabi/mongocxx/result/insert_many.cpp + mongocxx/v_noabi/mongocxx/result/insert_one.cpp + mongocxx/v_noabi/mongocxx/result/replace_one.cpp + mongocxx/v_noabi/mongocxx/result/rewrap_many_datakey.cpp + mongocxx/v_noabi/mongocxx/result/update.cpp + mongocxx/v_noabi/mongocxx/search_index_model.cpp + mongocxx/v_noabi/mongocxx/search_index_view.cpp + mongocxx/v_noabi/mongocxx/test_util/client_helpers.cpp + mongocxx/v_noabi/mongocxx/test_util/client_helpers.hh + mongocxx/v_noabi/mongocxx/test_util/export_for_testing.hh + mongocxx/v_noabi/mongocxx/test_util/mock.hh + mongocxx/v_noabi/mongocxx/uri.cpp + mongocxx/v_noabi/mongocxx/validation_criteria.cpp + mongocxx/v_noabi/mongocxx/write_concern.cpp +) diff --git a/src/mongocxx/lib/mongocxx/v_noabi/mongocxx/config/CMakeLists.txt b/src/mongocxx/lib/mongocxx/v_noabi/mongocxx/config/CMakeLists.txt deleted file mode 100644 index df93e7b257..0000000000 --- a/src/mongocxx/lib/mongocxx/v_noabi/mongocxx/config/CMakeLists.txt +++ /dev/null @@ -1,56 +0,0 @@ -# Copyright 2016 MongoDB Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/version.hpp.in - ${CMAKE_CURRENT_BINARY_DIR}/version.hpp -) - -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/config.hpp.in - ${CMAKE_CURRENT_BINARY_DIR}/config.hpp -) - -if(DEFINED CMAKE_CXX_COMPILER_ID) - set(MONGOCXX_COMPILER_ID "${CMAKE_CXX_COMPILER_ID}") -else() - set(MONGOCXX_COMPILER_ID "Unknown") -endif() - -if(DEFINED CMAKE_CXX_COMPILER_VERSION) - set(MONGOCXX_COMPILER_VERSION "${CMAKE_CXX_COMPILER_VERSION}") -else() - set(MONGOCXX_COMPILER_VERSION "Unknown") -endif() - -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/private/config.hh.in - ${CMAKE_CURRENT_BINARY_DIR}/private/config.hh -) - -install(FILES - ${CMAKE_CURRENT_BINARY_DIR}/config.hpp - ${CMAKE_CURRENT_BINARY_DIR}/version.hpp - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/mongocxx/v_noabi/mongocxx/config - COMPONENT dev -) - -set_dist_list(src_mongocxx_config_DIST - CMakeLists.txt - config.hpp.in - private/config.hh.in - private/postlude.hh - private/prelude.hh - version.hpp.in -) From 8260ccc965e3fd4370a2756e20b7484eb89a23a2 Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Fri, 22 Sep 2023 13:41:31 -0500 Subject: [PATCH 07/11] Move example variables into example config files --- examples/bsoncxx/CMakeLists.txt | 6 ++++++ examples/mongocxx/CMakeLists.txt | 6 ++++++ src/bsoncxx/CMakeLists.txt | 4 ---- src/mongocxx/CMakeLists.txt | 4 ---- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/examples/bsoncxx/CMakeLists.txt b/examples/bsoncxx/CMakeLists.txt index 90047665cd..645f1c3430 100644 --- a/examples/bsoncxx/CMakeLists.txt +++ b/examples/bsoncxx/CMakeLists.txt @@ -27,6 +27,12 @@ set(BSONCXX_EXAMPLES view_and_value.cpp ) +if(BSONCXX_BUILD_SHARED) + set(BSONCXX_LIBRARY_FOR_EXAMPLES bsoncxx_shared) +else() + set(BSONCXX_LIBRARY_FOR_EXAMPLES bsoncxx_static) +endif() + foreach(EXAMPLE_SRC ${BSONCXX_EXAMPLES}) get_filename_component(EXAMPLE_TARGET ${EXAMPLE_SRC} NAME_WE) add_executable(${EXAMPLE_TARGET} ${EXAMPLE_SRC}) diff --git a/examples/mongocxx/CMakeLists.txt b/examples/mongocxx/CMakeLists.txt index 44ddf4519a..30cbd9dd3c 100644 --- a/examples/mongocxx/CMakeLists.txt +++ b/examples/mongocxx/CMakeLists.txt @@ -51,6 +51,12 @@ set(MONGOCXX_EXAMPLES with_transaction.cpp ) +if(MONGOCXX_BUILD_SHARED) + set(MONGOCXX_LIBRARY_FOR_EXAMPLES mongocxx_shared) +else() + set(MONGOCXX_LIBRARY_FOR_EXAMPLES mongocxx_static) +endif() + foreach(EXAMPLE_SRC ${MONGOCXX_EXAMPLES}) get_filename_component(EXAMPLE_TARGET ${EXAMPLE_SRC} NAME_WE) add_executable(${EXAMPLE_TARGET} ${EXAMPLE_SRC}) diff --git a/src/bsoncxx/CMakeLists.txt b/src/bsoncxx/CMakeLists.txt index 2b085ed4fe..f916732ca1 100644 --- a/src/bsoncxx/CMakeLists.txt +++ b/src/bsoncxx/CMakeLists.txt @@ -144,14 +144,10 @@ if(BSONCXX_BUILD_STATIC) endif() if(BSONCXX_BUILD_SHARED) - set(BSONCXX_LIBRARY_FOR_EXAMPLES "bsoncxx_shared" CACHE INTERNAL "") - if(ENABLE_TESTS) bsoncxx_add_library(bsoncxx_testing "bsoncxx-testing" SHARED) endif() else() - set(BSONCXX_LIBRARY_FOR_EXAMPLES "bsoncxx_static" CACHE INTERNAL "") - if(ENABLE_TESTS) bsoncxx_add_library(bsoncxx_testing "bsoncxx-testing" STATIC) endif() diff --git a/src/mongocxx/CMakeLists.txt b/src/mongocxx/CMakeLists.txt index 6f0691916f..c1fc563270 100644 --- a/src/mongocxx/CMakeLists.txt +++ b/src/mongocxx/CMakeLists.txt @@ -94,14 +94,10 @@ if(MONGOCXX_BUILD_STATIC) endif() if(MONGOCXX_BUILD_SHARED) - set(MONGOCXX_LIBRARY_FOR_EXAMPLES "mongocxx_shared" CACHE INTERNAL "") - if(ENABLE_TESTS) mongocxx_add_library(mongocxx_mocked "mongocxx-mocked" SHARED) endif() else() - set(MONGOCXX_LIBRARY_FOR_EXAMPLES "mongocxx_static" CACHE INTERNAL "") - if(ENABLE_TESTS) mongocxx_add_library(mongocxx_mocked "mongocxx-mocked" STATIC) endif() From f375b3e68ec714a95413c5aa3cc015ff84ef82a4 Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Mon, 25 Sep 2023 15:59:51 -0500 Subject: [PATCH 08/11] Move test commands into test/CMakeLists.txt --- .mci.yml | 7 +- CMakeLists.txt | 1 + src/bsoncxx/CMakeLists.txt | 14 -- src/bsoncxx/test/CMakeLists.txt | 52 +++++-- src/mongocxx/CMakeLists.txt | 19 --- src/mongocxx/test/CMakeLists.txt | 247 +++++++++++++++---------------- 6 files changed, 170 insertions(+), 170 deletions(-) diff --git a/.mci.yml b/.mci.yml index ae23fb9a18..34c40eb0b5 100644 --- a/.mci.yml +++ b/.mci.yml @@ -461,7 +461,12 @@ functions: export LD_LIBRARY_PATH=.:$PREFIX/lib/ export DYLD_LIBRARY_PATH=.:$PREFIX/lib/ fi - export PATH=$(pwd)/src/bsoncxx/${build_type}:$(pwd)/src/mongocxx/${build_type}:$PREFIX/bin:$(pwd)/install/bin:$PATH + PATH="$(pwd)/src/mongocxx/test/${build_type}:$PATH" + PATH="$(pwd)/src/bsoncxx/test/${build_type}:$PATH" + PATH="$(pwd)/src/mongocxx/${build_type}:$PATH" + PATH="$(pwd)/src/bsoncxx/${build_type}:$PATH" + PATH="$PREFIX/bin:$PATH" + PATH="$(pwd)/install/bin:$PATH" export CHANGE_STREAMS_UNIFIED_TESTS_PATH="$(pwd)/../data/change-streams/unified" export CLIENT_SIDE_ENCRYPTION_LEGACY_TESTS_PATH="$(pwd)/../data/client_side_encryption/legacy" diff --git a/CMakeLists.txt b/CMakeLists.txt index 91471106d8..13ba7ea766 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -348,6 +348,7 @@ add_custom_target(docs ) set(THIRD_PARTY_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/third_party) +set(DATA_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/data) option(ENABLE_TESTS "Build MongoDB C++ Driver tests." ON) diff --git a/src/bsoncxx/CMakeLists.txt b/src/bsoncxx/CMakeLists.txt index f916732ca1..5d8561edc4 100644 --- a/src/bsoncxx/CMakeLists.txt +++ b/src/bsoncxx/CMakeLists.txt @@ -143,20 +143,6 @@ if(BSONCXX_BUILD_STATIC) list(APPEND bsoncxx_target_list bsoncxx_static) endif() -if(BSONCXX_BUILD_SHARED) - if(ENABLE_TESTS) - bsoncxx_add_library(bsoncxx_testing "bsoncxx-testing" SHARED) - endif() -else() - if(ENABLE_TESTS) - bsoncxx_add_library(bsoncxx_testing "bsoncxx-testing" STATIC) - endif() -endif() - -if(ENABLE_TESTS) - target_compile_definitions(bsoncxx_testing PUBLIC BSONCXX_TESTING) -endif() - # Generate and install the export header. if(1) function(bsoncxx_install_export_header TARGET) diff --git a/src/bsoncxx/test/CMakeLists.txt b/src/bsoncxx/test/CMakeLists.txt index 871eaf2162..3dc0f784f8 100644 --- a/src/bsoncxx/test/CMakeLists.txt +++ b/src/bsoncxx/test/CMakeLists.txt @@ -16,23 +16,55 @@ if(NOT BUILD_TESTING) set_property(DIRECTORY PROPERTY EXCLUDE_FROM_ALL TRUE) endif() -# Allow `#include ` -include_directories(${THIRD_PARTY_SOURCE_DIR}/..) +if(BSONCXX_BUILD_SHARED) + bsoncxx_add_library(bsoncxx_testing "bsoncxx-testing" SHARED) +else() + bsoncxx_add_library(bsoncxx_testing "bsoncxx-testing" STATIC) +endif() -file(GLOB src_bsoncxx_test_DIST_cpps RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp) +target_compile_definitions(bsoncxx_testing PUBLIC BSONCXX_TESTING) + +# Allow `#include ` +target_include_directories(bsoncxx_testing PUBLIC ${THIRD_PARTY_SOURCE_DIR}/..) add_executable(test_bson - ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp - ${src_bsoncxx_test_DIST_cpps} + array.cpp + bson_b_date.cpp + bson_builder.cpp + bson_get_values.cpp + bson_serialization.cpp + bson_types.cpp + bson_util_itoa.cpp + bson_validate.cpp + bson_value.cpp + json.cpp + oid.cpp + view_or_value.cpp ) -target_link_libraries(test_bson bsoncxx_testing ${libbson_target}) -target_include_directories(test_bson PRIVATE ${libbson_include_directories}) -target_compile_definitions(test_bson PRIVATE ${libbson_definitions}) +# Common target properties for test executables. +add_library(bsoncxx_test_properties INTERFACE) +target_sources(bsoncxx_test_properties INTERFACE ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp) +target_link_libraries(bsoncxx_test_properties INTERFACE bsoncxx_testing ${libbson_target}) +target_include_directories(bsoncxx_test_properties INTERFACE ${libbson_include_directories}) +target_compile_definitions(bsoncxx_test_properties INTERFACE ${libbson_definitions}) + +target_link_libraries(test_bson PRIVATE bsoncxx_test_properties) -add_test(bson test_bson) +add_test(NAME bson COMMAND test_bson) set_dist_list(src_bsoncxx_test_DIST CMakeLists.txt - ${src_bsoncxx_test_DIST_cpps} + array.cpp + bson_b_date.cpp + bson_builder.cpp + bson_get_values.cpp + bson_serialization.cpp + bson_types.cpp + bson_util_itoa.cpp + bson_validate.cpp + bson_value.cpp + json.cpp + oid.cpp + view_or_value.cpp ) diff --git a/src/mongocxx/CMakeLists.txt b/src/mongocxx/CMakeLists.txt index c1fc563270..c0c7c4269f 100644 --- a/src/mongocxx/CMakeLists.txt +++ b/src/mongocxx/CMakeLists.txt @@ -93,25 +93,6 @@ if(MONGOCXX_BUILD_STATIC) list(APPEND mongocxx_target_list mongocxx_static) endif() -if(MONGOCXX_BUILD_SHARED) - if(ENABLE_TESTS) - mongocxx_add_library(mongocxx_mocked "mongocxx-mocked" SHARED) - endif() -else() - if(ENABLE_TESTS) - mongocxx_add_library(mongocxx_mocked "mongocxx-mocked" STATIC) - endif() -endif() - -if(ENABLE_TESTS) - target_link_libraries(mongocxx_mocked PUBLIC bsoncxx_testing) - target_compile_definitions(mongocxx_mocked PUBLIC MONGOCXX_TESTING) - - if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - target_compile_options(mongocxx_mocked PRIVATE /bigobj) - endif() -endif() - # Generate and install the export header. if(1) function(mongocxx_install_export_header TARGET) diff --git a/src/mongocxx/test/CMakeLists.txt b/src/mongocxx/test/CMakeLists.txt index 01ec1226b6..f17bf06963 100644 --- a/src/mongocxx/test/CMakeLists.txt +++ b/src/mongocxx/test/CMakeLists.txt @@ -16,18 +16,40 @@ if(NOT BUILD_TESTING) set_property(DIRECTORY PROPERTY EXCLUDE_FROM_ALL TRUE) endif() +if(MONGOCXX_BUILD_SHARED) + mongocxx_add_library(mongocxx_mocked "mongocxx-mocked" SHARED) +else() + mongocxx_add_library(mongocxx_mocked "mongocxx-mocked" STATIC) +endif() + +target_link_libraries(mongocxx_mocked PUBLIC bsoncxx_testing) +target_compile_definitions(mongocxx_mocked PUBLIC MONGOCXX_TESTING) + +if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + target_compile_options(mongocxx_mocked PRIVATE /bigobj) +endif() + # Allow `#include ` -include_directories(${THIRD_PARTY_SOURCE_DIR}/..) +target_include_directories(mongocxx_mocked PUBLIC ${THIRD_PARTY_SOURCE_DIR}/..) -set(test_driver_sources - CMakeLists.txt +set(spec_test_common + spec/operation.cpp + spec/unified_tests/entity.cpp + spec/unified_tests/assert.cpp + spec/monitoring.cpp + spec/util.cpp +) + +set(client_helpers_cpp ${PROJECT_SOURCE_DIR}/lib/mongocxx/v_noabi/mongocxx/test_util/client_helpers.cpp) + +add_executable(test_driver bulk_write.cpp change_streams.cpp - client.cpp client_session.cpp client_side_encryption.cpp - collection.cpp + client.cpp collection_mocked.cpp + collection.cpp conversions.cpp database.cpp gridfs/bucket.cpp @@ -48,10 +70,10 @@ set(test_driver_sources options/create_collection.cpp options/delete.cpp options/distinct.cpp - options/find.cpp options/find_one_and_delete.cpp options/find_one_and_replace.cpp options/find_one_and_update.cpp + options/find.cpp options/gridfs/bucket.cpp options/gridfs/upload.cpp options/index.cpp @@ -71,8 +93,8 @@ set(test_driver_sources result/insert_one.cpp result/replace_one.cpp result/update.cpp - search_index_view.cpp sdam-monitoring.cpp + search_index_view.cpp spec/initial_dns_seedlist_discovery.cpp spec/monitoring.cpp spec/monitoring.hh @@ -83,136 +105,97 @@ set(test_driver_sources uri.cpp validation_criteria.cpp write_concern.cpp -) - -set(spec_test_common - spec/operation.cpp - spec/unified_tests/entity.cpp - spec/unified_tests/assert.cpp - spec/monitoring.cpp - spec/util.cpp -) - -set(client_helpers_cpp ${PROJECT_SOURCE_DIR}/lib/mongocxx/v_noabi/mongocxx/test_util/client_helpers.cpp) - -add_executable(test_driver ${client_helpers_cpp} - ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp - ${test_driver_sources} ) -set(THREADS_PREFER_PTHREAD_FLAG ON) -find_package(Threads REQUIRED) -target_link_libraries(test_driver Threads::Threads) - add_executable(test_logging - ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp logging.cpp ) add_executable(test_instance - ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp instance.cpp ) add_executable(test_crud_specs - ${client_helpers_cpp} - ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp spec/crud.cpp ${spec_test_common} + ${client_helpers_cpp} ) add_executable(test_gridfs_specs - ${client_helpers_cpp} - ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp spec/gridfs.cpp ${spec_test_common} + ${client_helpers_cpp} ) add_executable(test_client_side_encryption_specs - ${client_helpers_cpp} - ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp spec/client_side_encryption.cpp ${spec_test_common} + ${client_helpers_cpp} ) add_executable(test_command_monitoring_specs - ${client_helpers_cpp} - ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp spec/command_monitoring.cpp ${spec_test_common} + ${client_helpers_cpp} ) add_executable(test_transactions_specs - ${client_helpers_cpp} - ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp spec/transactions.cpp ${spec_test_common} + ${client_helpers_cpp} ) add_executable(test_retryable_reads_specs - ${client_helpers_cpp} - ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp spec/retryable-reads.cpp ${spec_test_common} + ${client_helpers_cpp} ) add_executable(test_read_write_concern_specs - ${client_helpers_cpp} - ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp spec/read_write_concern.cpp ${spec_test_common} + ${client_helpers_cpp} ) add_executable(test_mongohouse_specs - ${client_helpers_cpp} - ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp spec/mongohouse.cpp ${spec_test_common} + ${client_helpers_cpp} ) add_executable(test_unified_format_spec - ${client_helpers_cpp} - ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp spec/unified_tests/operations.cpp spec/unified_tests/runner.cpp ${spec_test_common} + ${client_helpers_cpp} ) add_executable(test_versioned_api - ${client_helpers_cpp} - ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp versioned_api.cpp ${spec_test_common} + ${client_helpers_cpp} ) -target_link_libraries(test_driver mongocxx_mocked ${libmongoc_target}) -target_link_libraries(test_logging mongocxx_mocked ${libmongoc_target}) -target_link_libraries(test_instance mongocxx_mocked ${libmongoc_target}) -target_link_libraries(test_client_side_encryption_specs mongocxx_mocked ${libmongoc_target}) -target_link_libraries(test_crud_specs mongocxx_mocked ${libmongoc_target}) -target_link_libraries(test_gridfs_specs mongocxx_mocked ${libmongoc_target}) -target_link_libraries(test_command_monitoring_specs mongocxx_mocked ${libmongoc_target}) -target_link_libraries(test_transactions_specs mongocxx_mocked ${libmongoc_target}) -target_link_libraries(test_retryable_reads_specs mongocxx_mocked ${libmongoc_target}) -target_link_libraries(test_read_write_concern_specs mongocxx_mocked ${libmongoc_target}) -target_link_libraries(test_mongohouse_specs mongocxx_mocked ${libmongoc_target}) -target_link_libraries(test_unified_format_spec mongocxx_mocked ${libmongoc_target}) -target_link_libraries(test_versioned_api mongocxx_mocked ${libmongoc_target}) - -target_include_directories(test_driver PRIVATE ${libmongoc_include_directories}) -target_include_directories(test_logging PRIVATE ${libmongoc_include_directories}) -target_include_directories(test_instance PRIVATE ${libmongoc_include_directories}) -target_include_directories(test_client_side_encryption_specs PRIVATE ${libmongoc_include_directories}) -target_include_directories(test_crud_specs PRIVATE ${libmongoc_include_directories}) -target_include_directories(test_gridfs_specs PRIVATE ${libmongoc_include_directories}) -target_include_directories(test_command_monitoring_specs PRIVATE ${libmongoc_include_directories}) -target_include_directories(test_transactions_specs PRIVATE ${libmongoc_include_directories}) -target_include_directories(test_retryable_reads_specs PRIVATE ${libmongoc_include_directories}) -target_include_directories(test_read_write_concern_specs PRIVATE ${libmongoc_include_directories}) -target_include_directories(test_mongohouse_specs PRIVATE ${libmongoc_include_directories}) -target_include_directories(test_unified_format_spec PRIVATE ${libmongoc_include_directories}) -target_include_directories(test_versioned_api PRIVATE ${libmongoc_include_directories}) +# Common target properties for test executables. +add_library(mongocxx_test_properties INTERFACE) +target_sources(mongocxx_test_properties INTERFACE ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp) +target_link_libraries(mongocxx_test_properties INTERFACE mongocxx_mocked ${libmongoc_target}) +target_include_directories(mongocxx_test_properties INTERFACE ${libmongoc_include_directories}) + +target_link_libraries(test_driver PRIVATE mongocxx_test_properties) +target_link_libraries(test_logging PRIVATE mongocxx_test_properties) +target_link_libraries(test_instance PRIVATE mongocxx_test_properties) +target_link_libraries(test_client_side_encryption_specs PRIVATE mongocxx_test_properties) +target_link_libraries(test_crud_specs PRIVATE mongocxx_test_properties) +target_link_libraries(test_gridfs_specs PRIVATE mongocxx_test_properties) +target_link_libraries(test_command_monitoring_specs PRIVATE mongocxx_test_properties) +target_link_libraries(test_transactions_specs PRIVATE mongocxx_test_properties) +target_link_libraries(test_retryable_reads_specs PRIVATE mongocxx_test_properties) +target_link_libraries(test_read_write_concern_specs PRIVATE mongocxx_test_properties) +target_link_libraries(test_mongohouse_specs PRIVATE mongocxx_test_properties) +target_link_libraries(test_unified_format_spec PRIVATE mongocxx_test_properties) +target_link_libraries(test_versioned_api PRIVATE mongocxx_test_properties) target_compile_definitions(test_driver PRIVATE ${libmongoc_definitions}) target_compile_definitions(test_logging PRIVATE ${libmongoc_definitions}) @@ -227,78 +210,90 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") target_compile_options(test_retryable_reads_specs PRIVATE -Wno-maybe-uninitialized) endif() -add_test(driver test_driver) -add_test(logging test_logging) -add_test(instance test_instance) -add_test(crud_specs test_crud_specs) -add_test(gridfs_specs test_gridfs_specs) -add_test(client_side_encryption_specs test_client_side_encryption_specs) -add_test(command_monitoring_specs test_command_monitoring_specs) -add_test(transactions_specs test_transactions_specs) -add_test(retryable_reads_spec test_retryable_reads_specs) -add_test(read_write_concern_specs test_read_write_concern_specs) -add_test(unified_format_spec test_unified_format_spec) -add_test(versioned_api test_versioned_api) +set(THREADS_PREFER_PTHREAD_FLAG ON) +find_package(Threads REQUIRED) +target_link_libraries(test_driver PRIVATE Threads::Threads) + +add_test(NAME driver COMMAND test_driver) +add_test(NAME logging COMMAND test_logging) +add_test(NAME instance COMMAND test_instance) +add_test(NAME crud_specs COMMAND test_crud_specs) +add_test(NAME gridfs_specs COMMAND test_gridfs_specs) +add_test(NAME client_side_encryption_specs COMMAND test_client_side_encryption_specs) +add_test(NAME command_monitoring_specs COMMAND test_command_monitoring_specs) +add_test(NAME transactions_specs COMMAND test_transactions_specs) +add_test(NAME retryable_reads_spec COMMAND test_retryable_reads_specs) +add_test(NAME read_write_concern_specs COMMAND test_read_write_concern_specs) +add_test(NAME unified_format_spec COMMAND test_unified_format_spec) +add_test(NAME versioned_api COMMAND test_versioned_api) # Adding this as a test will run it as part of the RUN_TESTS command in MSVC. # Do not add, since we only test mongohouse on Linux. -# add_test(mongohouse_specs test_mongohouse_specs) -set_tests_properties(crud_specs PROPERTIES - ENVIRONMENT "CRUD_LEGACY_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/crud/legacy") +if(0) + add_test(mongohouse_specs NAME test_mongohouse_specs COMMAND) +endif() -set_tests_properties(gridfs_specs PROPERTIES - ENVIRONMENT "GRIDFS_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/gridfs") +set_property(TEST crud_specs APPEND PROPERTY ENVIRONMENT + "CRUD_LEGACY_TESTS_PATH=${DATA_SOURCE_DIR}/crud/legacy" +) -set_tests_properties(client_side_encryption_specs PROPERTIES - ENVIRONMENT "CLIENT_SIDE_ENCRYPTION_LEGACY_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/client_side_encryption/legacy") +set_property(TEST gridfs_specs APPEND PROPERTY ENVIRONMENT + "GRIDFS_TESTS_PATH=${DATA_SOURCE_DIR}/gridfs" +) -set_tests_properties(driver PROPERTIES - ENVIRONMENT "CLIENT_SIDE_ENCRYPTION_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/client_side_encryption") -set_property(TEST driver - APPEND PROPERTY ENVIRONMENT "URI_OPTIONS_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/uri-options") +set_property(TEST client_side_encryption_specs APPEND PROPERTY ENVIRONMENT + "CLIENT_SIDE_ENCRYPTION_LEGACY_TESTS_PATH=${DATA_SOURCE_DIR}/client_side_encryption/legacy" +) -set_tests_properties(command_monitoring_specs PROPERTIES - ENVIRONMENT "COMMAND_MONITORING_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/command-monitoring") +set_property(TEST driver APPEND PROPERTY ENVIRONMENT + "CLIENT_SIDE_ENCRYPTION_TESTS_PATH=${DATA_SOURCE_DIR}/client_side_encryption" + "URI_OPTIONS_TESTS_PATH=${DATA_SOURCE_DIR}/uri-options" +) -set_tests_properties(transactions_specs PROPERTIES - ENVIRONMENT "TRANSACTIONS_LEGACY_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/transactions/legacy") -set_property(TEST transactions_specs - APPEND PROPERTY ENVIRONMENT "WITH_TRANSACTION_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/with_transaction") +set_property(TEST command_monitoring_specs APPEND PROPERTY ENVIRONMENT + "COMMAND_MONITORING_TESTS_PATH=${DATA_SOURCE_DIR}/command-monitoring" +) -set_tests_properties(retryable_reads_spec PROPERTIES - ENVIRONMENT "RETRYABLE_READS_LEGACY_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/retryable-reads/legacy") +set_property(TEST transactions_specs APPEND PROPERTY ENVIRONMENT + "TRANSACTIONS_LEGACY_TESTS_PATH=${DATA_SOURCE_DIR}/transactions/legacy" + "WITH_TRANSACTION_TESTS_PATH=${DATA_SOURCE_DIR}/with_transaction" +) -set_tests_properties(read_write_concern_specs PROPERTIES - ENVIRONMENT "READ_WRITE_CONCERN_OPERATION_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/read-write-concern/operation") +set_property(TEST retryable_reads_spec APPEND PROPERTY ENVIRONMENT + "RETRYABLE_READS_LEGACY_TESTS_PATH=${DATA_SOURCE_DIR}/retryable-reads/legacy" +) + +set_property(TEST read_write_concern_specs APPEND PROPERTY ENVIRONMENT + "READ_WRITE_CONCERN_OPERATION_TESTS_PATH=${DATA_SOURCE_DIR}/read-write-concern/operation" +) set_property(TEST unified_format_spec APPEND PROPERTY ENVIRONMENT - "CHANGE_STREAMS_UNIFIED_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/change-streams/unified" - "CLIENT_SIDE_ENCRYPTION_UNIFIED_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/client_side_encryption/unified" - "COLLECTION_MANAGEMENT_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/collection-management" - "CRUD_UNIFIED_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/crud/unified" - "SESSION_UNIFIED_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/sessions/unified/" - "RETRYABLE_READS_UNIFIED_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/retryable-reads/unified/" - "RETRYABLE_WRITES_UNIFIED_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/retryable-writes/unified/" - "TRANSACTIONS_UNIFIED_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/transactions/unified" - "UNIFIED_FORMAT_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/unified-format" - "VERSIONED_API_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/versioned-api" - "INDEX_MANAGEMENT_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/index-management" + "CHANGE_STREAMS_UNIFIED_TESTS_PATH=${DATA_SOURCE_DIR}/change-streams/unified" + "CLIENT_SIDE_ENCRYPTION_UNIFIED_TESTS_PATH=${DATA_SOURCE_DIR}/client_side_encryption/unified" + "COLLECTION_MANAGEMENT_TESTS_PATH=${DATA_SOURCE_DIR}/collection-management" + "CRUD_UNIFIED_TESTS_PATH=${DATA_SOURCE_DIR}/crud/unified" + "INDEX_MANAGEMENT_TESTS_PATH=${DATA_SOURCE_DIR}/index-management" + "RETRYABLE_READS_UNIFIED_TESTS_PATH=${DATA_SOURCE_DIR}/retryable-reads/unified/" + "RETRYABLE_WRITES_UNIFIED_TESTS_PATH=${DATA_SOURCE_DIR}/retryable-writes/unified/" + "SESSION_UNIFIED_TESTS_PATH=${DATA_SOURCE_DIR}/sessions/unified/" + "TRANSACTIONS_UNIFIED_TESTS_PATH=${DATA_SOURCE_DIR}/transactions/unified" + "UNIFIED_FORMAT_TESTS_PATH=${DATA_SOURCE_DIR}/unified-format" + "VERSIONED_API_TESTS_PATH=${DATA_SOURCE_DIR}/versioned-api" ) if(MONGOCXX_ENABLE_SLOW_TESTS) - set_property(TEST driver - APPEND PROPERTY ENVIRONMENT "MONGOCXX_ENABLE_SLOW_TESTS=1") + set_property(TEST driver APPEND PROPERTY ENVIRONMENT "MONGOCXX_ENABLE_SLOW_TESTS=1") endif() set_dist_list(src_mongocxx_test_DIST CMakeLists.txt bulk_write.cpp change_streams.cpp - client.cpp client_session.cpp client_side_encryption.cpp - collection.cpp + client.cpp collection_mocked.cpp + collection.cpp conversions.cpp database.cpp gridfs/bucket.cpp @@ -321,10 +316,10 @@ set_dist_list(src_mongocxx_test_DIST options/create_collection.cpp options/delete.cpp options/distinct.cpp - options/find.cpp options/find_one_and_delete.cpp options/find_one_and_replace.cpp options/find_one_and_update.cpp + options/find.cpp options/gridfs/bucket.cpp options/gridfs/upload.cpp options/index.cpp @@ -344,8 +339,8 @@ set_dist_list(src_mongocxx_test_DIST result/insert_one.cpp result/replace_one.cpp result/update.cpp - search_index_view.cpp sdam-monitoring.cpp + search_index_view.cpp spec/client_side_encryption.cpp spec/command_monitoring.cpp spec/crud.cpp @@ -366,9 +361,9 @@ set_dist_list(src_mongocxx_test_DIST spec/unified_tests/operations.cpp spec/unified_tests/operations.hh spec/unified_tests/runner.cpp + spec/uri_options.cpp spec/util.cpp spec/util.hh - spec/uri_options.cpp transactions.cpp uri.cpp validation_criteria.cpp From 69f81cacb7eb7e5d00d81f1eaee9196aaac9a941 Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Tue, 26 Sep 2023 16:33:12 -0500 Subject: [PATCH 09/11] Update modeless message() commands to STATUS mode --- src/bsoncxx/CMakeLists.txt | 10 +++++----- src/mongocxx/CMakeLists.txt | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/bsoncxx/CMakeLists.txt b/src/bsoncxx/CMakeLists.txt index 5d8561edc4..ee9401c822 100644 --- a/src/bsoncxx/CMakeLists.txt +++ b/src/bsoncxx/CMakeLists.txt @@ -18,7 +18,7 @@ ParseVersion(${BUILD_VERSION} BSONCXX) set(BSONCXX_VERSION_NO_EXTRA ${BSONCXX_VERSION_MAJOR}.${BSONCXX_VERSION_MINOR}.${BSONCXX_VERSION_PATCH}) set(BSONCXX_VERSION ${BSONCXX_VERSION_NO_EXTRA}${BSONCXX_VERSION_EXTRA}) -message("bsoncxx version: ${BSONCXX_VERSION}") +message(STATUS "bsoncxx version: ${BSONCXX_VERSION}") option(BSONCXX_POLY_USE_MNMLSTC "Use MNMLSTC/core for stdx polyfills" OFF) option(BSONCXX_POLY_USE_STD_EXPERIMENTAL "Use std::experimental for stdx polyfills" OFF) @@ -79,7 +79,7 @@ set(BSONCXX_PKG_DEP "") # Required by bsoncxx-config.cmake.in. if(TARGET bson_shared OR TARGET bson_static) # If these targets exist, then libbson has already been included as a project # sub-directory - message("found libbson targets declared in current build scope; version not checked") + message(STATUS "found libbson targets declared in current build scope; version not checked") if(NOT BSONCXX_LINK_WITH_STATIC_MONGOC) set(libbson_target bson_shared) @@ -93,7 +93,7 @@ else() find_package(bson-${LIBBSON_REQUIRED_ABI_VERSION} ${LIBBSON_REQUIRED_VERSION} QUIET) if(bson-${LIBBSON_REQUIRED_ABI_VERSION}_FOUND) - message("found libbson version ${bson-${LIBBSON_REQUIRED_ABI_VERSION}_VERSION}") + message(STATUS "found libbson version ${bson-${LIBBSON_REQUIRED_ABI_VERSION}_VERSION}") if(NOT BSONCXX_LINK_WITH_STATIC_MONGOC) set(libbson_target mongo::bson_shared) @@ -106,14 +106,14 @@ else() # Require package of old libbson name (with lib). if(NOT BSONCXX_LINK_WITH_STATIC_MONGOC) find_package(libbson-${LIBBSON_REQUIRED_ABI_VERSION} ${LIBBSON_REQUIRED_VERSION} REQUIRED) - message("found libbson version ${BSON_VERSION}") + message(STATUS "found libbson version ${BSON_VERSION}") set(libbson_target ${BSON_LIBRARIES}) set(libbson_include_directories ${BSON_INCLUDE_DIRS}) set(libbson_definitions ${BSON_DEFINITIONS}) set(BSONCXX_PKG_DEP "find_dependency(libbson-${LIBBSON_REQUIRED_ABI_VERSION} REQUIRED)") else() find_package(libbson-static-${LIBBSON_REQUIRED_ABI_VERSION} ${LIBBSON_REQUIRED_VERSION} REQUIRED) - message("found libbson version ${BSON_STATIC_VERSION}") + message(STATUS "found libbson version ${BSON_STATIC_VERSION}") set(libbson_target ${BSON_STATIC_LIBRARIES}) set(libbson_include_directories ${BSON_STATIC_INCLUDE_DIRS}) set(libbson_definitions ${BSON_STATIC_DEFINITIONS}) diff --git a/src/mongocxx/CMakeLists.txt b/src/mongocxx/CMakeLists.txt index c0c7c4269f..04471067f0 100644 --- a/src/mongocxx/CMakeLists.txt +++ b/src/mongocxx/CMakeLists.txt @@ -18,7 +18,7 @@ ParseVersion(${BUILD_VERSION} MONGOCXX) set(MONGOCXX_VERSION_NO_EXTRA ${MONGOCXX_VERSION_MAJOR}.${MONGOCXX_VERSION_MINOR}.${MONGOCXX_VERSION_PATCH}) set(MONGOCXX_VERSION ${MONGOCXX_VERSION_NO_EXTRA}${MONGOCXX_VERSION_EXTRA}) -message("mongocxx version: ${MONGOCXX_VERSION}") +message(STATUS "mongocxx version: ${MONGOCXX_VERSION}") option(MONGOCXX_ENABLE_SSL "Enable SSL - if the underlying C driver offers it" ON) option(MONGOCXX_ENABLE_SLOW_TESTS "Run slow tests when invoking the the test target" OFF) @@ -30,7 +30,7 @@ set(MONGOCXX_PKG_DEP "") # Required by bsoncxx-config.cmake.in. if(TARGET mongoc_shared OR TARGET mongoc_static) # If these targets exist, then libmongoc has already been included as a project # sub-directory - message("found libmongoc targets declared in current build scope; version not checked") + message(STATUS "found libmongoc targets declared in current build scope; version not checked") if(NOT MONGOCXX_LINK_WITH_STATIC_MONGOC) set(libmongoc_target mongoc_shared) @@ -44,7 +44,7 @@ else() find_package(mongoc-${LIBMONGOC_REQUIRED_ABI_VERSION} ${LIBMONGOC_REQUIRED_VERSION} QUIET) if(mongoc-${LIBMONGOC_REQUIRED_ABI_VERSION}_FOUND) - message("found libmongoc version ${mongoc-${LIBMONGOC_REQUIRED_ABI_VERSION}_VERSION}") + message(STATUS "found libmongoc version ${mongoc-${LIBMONGOC_REQUIRED_ABI_VERSION}_VERSION}") if(NOT MONGOCXX_LINK_WITH_STATIC_MONGOC) set(libmongoc_target mongo::mongoc_shared) @@ -57,13 +57,13 @@ else() # Require package of old libmongoc name (with lib). if(NOT MONGOCXX_LINK_WITH_STATIC_MONGOC) find_package(libmongoc-${LIBMONGOC_REQUIRED_ABI_VERSION} ${LIBMONGOC_REQUIRED_VERSION} REQUIRED) - message("found libmongoc version ${MONGOC_VERSION}") + message(STATUS "found libmongoc version ${MONGOC_VERSION}") set(libmongoc_target ${MONGOC_LIBRARIES}) set(libmongoc_definitions ${MONGOC_DEFINITIONS}) set(MONGOCXX_PKG_DEP "find_dependency(libmongoc-${LIBMONGOC_REQUIRED_ABI_VERSION} REQUIRED)") else() find_package(libmongoc-static-${LIBMONGOC_REQUIRED_ABI_VERSION} ${LIBMONGOC_REQUIRED_VERSION} REQUIRED) - message("found libmongoc version ${MONGOC_STATIC_VERSION}") + message(STATUS "found libmongoc version ${MONGOC_STATIC_VERSION}") set(libmongoc_target ${MONGOC_STATIC_LIBRARIES}) set(libmongoc_definitions ${MONGOC_STATIC_DEFINITIONS}) set(MONGOCXX_PKG_DEP "find_dependency(libmongoc-static-${LIBMONGOC_REQUIRED_ABI_VERSION} REQUIRED)") From 0f817588c82f937de82d42d221101ea238cdfc4c Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Wed, 11 Oct 2023 11:42:59 -0500 Subject: [PATCH 10/11] Fix reference to mongocxx-config.cmake.in --- src/mongocxx/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mongocxx/CMakeLists.txt b/src/mongocxx/CMakeLists.txt index 04471067f0..c82b1fb71e 100644 --- a/src/mongocxx/CMakeLists.txt +++ b/src/mongocxx/CMakeLists.txt @@ -25,7 +25,7 @@ option(MONGOCXX_ENABLE_SLOW_TESTS "Run slow tests when invoking the the test tar set(MONGOCXX_OUTPUT_BASENAME "mongocxx" CACHE STRING "Output mongocxx library base name") -set(MONGOCXX_PKG_DEP "") # Required by bsoncxx-config.cmake.in. +set(MONGOCXX_PKG_DEP "") # Required by mongocxx-config.cmake.in. if(TARGET mongoc_shared OR TARGET mongoc_static) # If these targets exist, then libmongoc has already been included as a project From 883ddf88ab4967de9c66c3c7764d8cdfad719652 Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Wed, 11 Oct 2023 11:50:08 -0500 Subject: [PATCH 11/11] Move targets file generate and install into cmake subdir --- src/bsoncxx/CMakeLists.txt | 19 +------------------ src/bsoncxx/cmake/CMakeLists.txt | 15 +++++++++++++++ src/mongocxx/CMakeLists.txt | 19 +------------------ src/mongocxx/cmake/CMakeLists.txt | 15 +++++++++++++++ 4 files changed, 32 insertions(+), 36 deletions(-) diff --git a/src/bsoncxx/CMakeLists.txt b/src/bsoncxx/CMakeLists.txt index ee9401c822..09021c5c8c 100644 --- a/src/bsoncxx/CMakeLists.txt +++ b/src/bsoncxx/CMakeLists.txt @@ -124,7 +124,6 @@ endif() set(bsoncxx_sources "") # Required by bsoncxx_add_library(). -add_subdirectory(cmake) add_subdirectory(include) add_subdirectory(lib) add_subdirectory(third_party) @@ -170,23 +169,7 @@ if(1) endif() endif() -# Generate and install the modern CMake install package targets file. -if(1) - install(TARGETS - ${bsoncxx_target_list} - EXPORT bsoncxx_targets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT runtime - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT runtime - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT dev - INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/bsoncxx/v_noabi - ) - - install(EXPORT bsoncxx_targets - NAMESPACE mongo:: - FILE bsoncxx_targets.cmake - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/bsoncxx-${BSONCXX_VERSION} - ) -endif() +add_subdirectory(cmake) if(ENABLE_TESTS) add_subdirectory(test) diff --git a/src/bsoncxx/cmake/CMakeLists.txt b/src/bsoncxx/cmake/CMakeLists.txt index a851afd185..abe9a7c1fd 100644 --- a/src/bsoncxx/cmake/CMakeLists.txt +++ b/src/bsoncxx/cmake/CMakeLists.txt @@ -48,6 +48,21 @@ if(1) @ONLY ) + install(TARGETS + ${bsoncxx_target_list} + EXPORT bsoncxx_targets + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT runtime + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT runtime + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT dev + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/bsoncxx/v_noabi + ) + + install(EXPORT bsoncxx_targets + NAMESPACE mongo:: + FILE bsoncxx_targets.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/bsoncxx-${BSONCXX_VERSION} + ) + install( FILES ${CMAKE_CURRENT_BINARY_DIR}/bsoncxx-config-version.cmake diff --git a/src/mongocxx/CMakeLists.txt b/src/mongocxx/CMakeLists.txt index c82b1fb71e..39f9f4f954 100644 --- a/src/mongocxx/CMakeLists.txt +++ b/src/mongocxx/CMakeLists.txt @@ -73,7 +73,6 @@ endif() set(mongocxx_sources "") # Required by mongocxx_add_library(). -add_subdirectory(cmake) add_subdirectory(include) add_subdirectory(lib) @@ -120,23 +119,7 @@ if(1) endif() endif() -# Generate and install the modern CMake package install targets file. -if(1) - install(TARGETS - ${mongocxx_target_list} - EXPORT mongocxx_targets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT runtime - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT runtime - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT dev - INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/mongocxx/v_noabi - ) - - install(EXPORT mongocxx_targets - NAMESPACE mongo:: - FILE mongocxx_targets.cmake - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/mongocxx-${MONGOCXX_VERSION} - ) -endif() +add_subdirectory(cmake) if(ENABLE_TESTS) add_subdirectory(test) diff --git a/src/mongocxx/cmake/CMakeLists.txt b/src/mongocxx/cmake/CMakeLists.txt index 2aa1d15770..1c33b1e5a8 100644 --- a/src/mongocxx/cmake/CMakeLists.txt +++ b/src/mongocxx/cmake/CMakeLists.txt @@ -28,6 +28,21 @@ if(1) @ONLY ) + install(TARGETS + ${mongocxx_target_list} + EXPORT mongocxx_targets + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT runtime + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT runtime + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT dev + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/mongocxx/v_noabi + ) + + install(EXPORT mongocxx_targets + NAMESPACE mongo:: + FILE mongocxx_targets.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/mongocxx-${MONGOCXX_VERSION} + ) + install( FILES ${CMAKE_CURRENT_BINARY_DIR}/mongocxx-config-version.cmake