From cd6f3e2b7f159e910c240571b3c2920a8b0e0d00 Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Wed, 24 May 2023 09:31:43 -0500 Subject: [PATCH 01/61] Auto download the C driver if it is not already installed --- .evergreen/compile.sh | 2 +- CMakeLists.txt | 55 +++ cmake/BsoncxxUtil.cmake | 6 + cmake/MongocxxUtil.cmake | 6 + src/bsoncxx/test/CMakeLists.txt | 34 +- src/mongocxx/CMakeLists.txt | 13 +- src/mongocxx/test/CMakeLists.txt | 588 ++++++++++++++++--------------- 7 files changed, 393 insertions(+), 311 deletions(-) diff --git a/.evergreen/compile.sh b/.evergreen/compile.sh index fb90276bbb..bf87b3ea2d 100755 --- a/.evergreen/compile.sh +++ b/.evergreen/compile.sh @@ -52,7 +52,7 @@ esac . .evergreen/find_cmake.sh cd build -"$CMAKE" -G "$GENERATOR" "-DCMAKE_BUILD_TYPE=${BUILD_TYPE}" -DMONGOCXX_ENABLE_SLOW_TESTS=ON -DENABLE_UNINSTALL=ON "$@" .. +"$CMAKE" -G "$GENERATOR" "-DCMAKE_BUILD_TYPE=${BUILD_TYPE}" -DMONGOCXX_ENABLE_SLOW_TESTS=ON -DENABLE_UNINSTALL=ON -DBUILD_TESTS=ON "$@" .. "$CMAKE" --build . --config $BUILD_TYPE -- $CMAKE_BUILD_OPTS "$CMAKE" --build . --config $BUILD_TYPE --target install -- $CMAKE_BUILD_OPTS "$CMAKE" --build . --config $BUILD_TYPE --target $CMAKE_EXAMPLES_TARGET -- $CMAKE_BUILD_OPTS diff --git a/CMakeLists.txt b/CMakeLists.txt index 20254facb8..2cc95312de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,6 +40,61 @@ else() message(WARNING "Unknown compiler... recklessly proceeding without a version check") endif() +set(LIBMONGOC_REQUIRED_VERSION 1.22.1) # TODO: update to 1.24.0 once released. +set(LIBMONGOC_REQUIRED_ABI_VERSION 1.0) + +set(NEED_DOWNLOAD_C_DRIVER false CACHE INTERNAL "") +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(NOT MONGOCXX_LINK_WITH_STATIC_MONGOC) + set(libmongoc_target mongoc_shared) + else() + set(libmongoc_target mongoc_static) + endif() + + if(MONGOCXX_BUILD_STATIC) + set(mongocxx_pkg_dep "find_dependency(mongoc-1.0 REQUIRED)") + endif() +else() + find_package(mongoc-${LIBMONGOC_REQUIRED_ABI_VERSION} ${LIBMONGOC_REQUIRED_VERSION} QUIET) + if(mongoc-${LIBMONGOC_REQUIRED_ABI_VERSION}_FOUND) + message("already found libmongoc, don't need to download it.") + else() + set(NEED_DOWNLOAD_C_DRIVER true CACHE INTERNAL "") + endif() +endif() + +if (${NEED_DOWNLOAD_C_DRIVER}) + message("No Mongo C Driver path provided via CMAKE_PREFIX_PATH, will download a release from the internet.") + include(FetchContent) + include(ExternalProject) + + # Declare mongo-c-driver as a dependency + FetchContent_Declare( + mongo-c-driver + GIT_REPOSITORY https://github.com/kkloberdanz/mongo-c-driver.git + GIT_TAG 1.24.0 + ) + + FetchContent_MakeAvailable(mongo-c-driver) + + # Set the installation directory for mongo-c-driver + set(MONGOC_INSTALL_DIR ${CMAKE_BINARY_DIR}/mongo-c-driver-install) + + # Build mongo-c-driver using ExternalProject + ExternalProject_Add(mongo-c-driver-build + SOURCE_DIR ${mongo-c-driver_SOURCE_DIR} + BINARY_DIR ${CMAKE_BINARY_DIR}/mongo-c-driver-build + INSTALL_DIR ${MONGOC_INSTALL_DIR} + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${MONGOC_INSTALL_DIR} + ) + file(REMOVE ${mongo-c-driver_SOURCE_DIR}/build/generate-uninstall.sh) + file(REMOVE ${mongo-c-driver_SOURCE_DIR}/build/generate-uninstall.cmd) +endif() + # All of our target compilers support the deprecated # attribute. Normally, we would just let the GenerateExportHeader # subsystem do this via configure check, but there appears to be a diff --git a/cmake/BsoncxxUtil.cmake b/cmake/BsoncxxUtil.cmake index d98f3ae9bf..91baef7e74 100644 --- a/cmake/BsoncxxUtil.cmake +++ b/cmake/BsoncxxUtil.cmake @@ -62,6 +62,12 @@ function(bsoncxx_add_library TARGET OUTPUT_NAME LINK_TYPE) EXPORT_FILE_NAME config/export.hpp STATIC_DEFINE BSONCXX_STATIC ) + + if (${NEED_DOWNLOAD_C_DRIVER}) + add_dependencies(${TARGET} mongo-c-driver-build) + target_include_directories(${TARGET} PRIVATE ${MONGOC_INSTALL_DIR}/include/libmongoc-1.0/mongoc/) + target_include_directories(${TARGET} PRIVATE ${MONGOC_INSTALL_DIR}/include/libbson-1.0/bson/) + endif() endfunction(bsoncxx_add_library) # Install the specified forms of the bsoncxx library (i.e., shared and/or static) diff --git a/cmake/MongocxxUtil.cmake b/cmake/MongocxxUtil.cmake index 43d406e015..c5c508b346 100644 --- a/cmake/MongocxxUtil.cmake +++ b/cmake/MongocxxUtil.cmake @@ -46,6 +46,12 @@ function(mongocxx_add_library TARGET OUTPUT_NAME LINK_TYPE) EXPORT_FILE_NAME config/export.hpp STATIC_DEFINE MONGOCXX_STATIC ) + + if (${NEED_DOWNLOAD_C_DRIVER}) + add_dependencies(${TARGET} mongo-c-driver-build) + target_include_directories(${TARGET} PRIVATE ${MONGOC_INSTALL_DIR}/include/libmongoc-1.0/mongoc/) + target_include_directories(${TARGET} PRIVATE ${MONGOC_INSTALL_DIR}/include/libbson-1.0/bson/) + endif() endfunction(mongocxx_add_library) # Install the specified forms of the mongocxx library (i.e., shared and/or static) diff --git a/src/bsoncxx/test/CMakeLists.txt b/src/bsoncxx/test/CMakeLists.txt index e06869d441..e76955d180 100644 --- a/src/bsoncxx/test/CMakeLists.txt +++ b/src/bsoncxx/test/CMakeLists.txt @@ -12,24 +12,26 @@ # See the License for the specific language governing permissions and # limitations under the License. -include_directories( - ${MONGO_CXX_DRIVER_SOURCE_DIR}/src/third_party/catch/include -) +if (BUILD_TESTS STREQUAL "ON") + include_directories( + ${MONGO_CXX_DRIVER_SOURCE_DIR}/src/third_party/catch/include + ) -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 - ${src_bsoncxx_test_DIST_cpps} -) + add_executable(test_bson + ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp + ${src_bsoncxx_test_DIST_cpps} + ) -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}) + 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}) -add_test(bson test_bson) + 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} + ) +endif() diff --git a/src/mongocxx/CMakeLists.txt b/src/mongocxx/CMakeLists.txt index e218d884d4..fd5057d308 100644 --- a/src/mongocxx/CMakeLists.txt +++ b/src/mongocxx/CMakeLists.txt @@ -29,9 +29,6 @@ message ("mongocxx version: ${MONGOCXX_VERSION}") set(MONGOCXX_INLINE_NAMESPACE "v${MONGOCXX_ABI_VERSION}") set(MONGOCXX_HEADER_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}/mongocxx/${MONGOCXX_INLINE_NAMESPACE}" CACHE INTERNAL "") -set(LIBMONGOC_REQUIRED_VERSION 1.22.1) # TODO: update to 1.24.0 once released. -set(LIBMONGOC_REQUIRED_ABI_VERSION 1.0) - set(mongocxx_pkg_dep "") if(TARGET mongoc_shared OR TARGET mongoc_static) @@ -69,7 +66,10 @@ else() find_package(libmongoc-${LIBMONGOC_REQUIRED_ABI_VERSION} ${LIBMONGOC_REQUIRED_VERSION} REQUIRED) message ("found libmongoc version ${MONGOC_VERSION}") set(libmongoc_target ${MONGOC_LIBRARIES}) - set(libmongoc_include_directories ${MONGOC_INCLUDE_DIRS}) + set(libmongoc_include_directories ${MONGOC_INCLUDE_DIRS} + ${MONGOC_INSTALL_DIR}/include/libmongoc-1.0/mongoc/ + ${MONGOC_INSTALL_DIR}/include/libbson-1.0/bson/ + ) set(libmongoc_definitions ${MONGOC_DEFINITIONS}) if(MONGOCXX_BUILD_STATIC) set(mongocxx_pkg_dep "find_dependency(libmongoc-1.0 REQUIRED)") @@ -78,7 +78,10 @@ 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_include_directories ${MONGOC_STATIC_INCLUDE_DIRS}) + set(libmongoc_include_directories ${MONGOC_STATIC_INCLUDE_DIRS} + ${MONGOC_INSTALL_DIR}/include/libmongoc-1.0/mongoc/ + ${MONGOC_INSTALL_DIR}/include/libbson-1.0/bson/ + ) set(libmongoc_definitions ${MONGOC_STATIC_DEFINITIONS}) if(MONGOCXX_BUILD_STATIC) set(mongocxx_pkg_dep "find_dependency(libmongoc-static-1.0 REQUIRED)") diff --git a/src/mongocxx/test/CMakeLists.txt b/src/mongocxx/test/CMakeLists.txt index 720074e923..5df29e007d 100644 --- a/src/mongocxx/test/CMakeLists.txt +++ b/src/mongocxx/test/CMakeLists.txt @@ -12,11 +12,286 @@ # See the License for the specific language governing permissions and # limitations under the License. -include_directories( - ${THIRD_PARTY_SOURCE_DIR}/catch/include -) +if (BUILD_TESTS STREQUAL "ON") + include_directories( + ${THIRD_PARTY_SOURCE_DIR}/catch/include + ) + + set(test_driver_sources + 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 + 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 + sdam-monitoring.cpp + spec/initial_dns_seedlist_discovery.cpp + spec/monitoring.cpp + spec/monitoring.hh + spec/unified_tests/assert.cpp + spec/unified_tests/entity.cpp + spec/uri_options.cpp + transactions.cpp + 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 + ) + + add_executable(test_driver + ${PROJECT_SOURCE_DIR}/test_util/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 + ${PROJECT_SOURCE_DIR}/test_util/client_helpers.cpp + ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp + spec/crud.cpp + ${spec_test_common} + ) + + add_executable(test_gridfs_specs + ${PROJECT_SOURCE_DIR}/test_util/client_helpers.cpp + ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp + spec/gridfs.cpp + ${spec_test_common} + ) + + add_executable(test_client_side_encryption_specs + ${PROJECT_SOURCE_DIR}/test_util/client_helpers.cpp + ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp + spec/client_side_encryption.cpp + ${spec_test_common} + ) + + add_executable(test_command_monitoring_specs + ${PROJECT_SOURCE_DIR}/test_util/client_helpers.cpp + ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp + spec/command_monitoring.cpp + ${spec_test_common} + ) + + add_executable(test_transactions_specs + ${PROJECT_SOURCE_DIR}/test_util/client_helpers.cpp + ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp + spec/transactions.cpp + ${spec_test_common} + ) + + add_executable(test_retryable_reads_specs + ${PROJECT_SOURCE_DIR}/test_util/client_helpers.cpp + ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp + spec/retryable-reads.cpp + ${spec_test_common} + ) -set(test_driver_sources + add_executable(test_read_write_concern_specs + ${PROJECT_SOURCE_DIR}/test_util/client_helpers.cpp + ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp + spec/read_write_concern.cpp + ${spec_test_common} + ) + + add_executable(test_mongohouse_specs + ${PROJECT_SOURCE_DIR}/test_util/client_helpers.cpp + ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp + spec/mongohouse.cpp + ${spec_test_common} + ) + + add_executable(test_unified_format_spec + ${PROJECT_SOURCE_DIR}/test_util/client_helpers.cpp + ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp + spec/unified_tests/operations.cpp + spec/unified_tests/runner.cpp + ${spec_test_common} + ) + + add_executable(test_versioned_api + ${PROJECT_SOURCE_DIR}/test_util/client_helpers.cpp + ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp + versioned_api.cpp + ${spec_test_common} + ) + + set (test_include_directories + ${libmongoc_include_directories} + ${MONGOC_INSTALL_DIR}/include/libmongoc-1.0/ + ${MONGOC_INSTALL_DIR}/include/libbson-1.0/ + ${MONGOC_INSTALL_DIR}/include/libbson-1.0/bson/ + ${MONGOC_INSTALL_DIR}/include/libmongoc-1.0/mongoc/ + ) + + 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 ${test_include_directories}) + target_include_directories(test_logging PRIVATE ${test_include_directories}) + target_include_directories(test_instance PRIVATE ${test_include_directories}) + target_include_directories(test_client_side_encryption_specs PRIVATE ${test_include_directories}) + target_include_directories(test_crud_specs PRIVATE ${test_include_directories}) + target_include_directories(test_gridfs_specs PRIVATE ${test_include_directories}) + target_include_directories(test_command_monitoring_specs PRIVATE ${test_include_directories}) + target_include_directories(test_transactions_specs PRIVATE ${test_include_directories}) + target_include_directories(test_retryable_reads_specs PRIVATE ${test_include_directories}) + target_include_directories(test_read_write_concern_specs PRIVATE ${test_include_directories}) + target_include_directories(test_mongohouse_specs PRIVATE ${test_include_directories}) + target_include_directories(test_unified_format_spec PRIVATE ${test_include_directories}) + target_include_directories(test_versioned_api PRIVATE ${test_include_directories}) + + 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") + 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) + 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) + + # 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") + + set_tests_properties(gridfs_specs PROPERTIES + ENVIRONMENT "GRIDFS_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/gridfs") + + set_tests_properties(client_side_encryption_specs PROPERTIES + ENVIRONMENT "CLIENT_SIDE_ENCRYPTION_LEGACY_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/client_side_encryption/legacy") + + 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_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_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/transactions") + set_property(TEST transactions_specs + 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") + + 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 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/" + "UNIFIED_FORMAT_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/unified-format" + "VERSIONED_API_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/versioned-api" + ) + + 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 @@ -32,6 +307,8 @@ set(test_driver_sources gridfs/uploader.cpp hint.cpp index_view.cpp + instance.cpp + logging.cpp model/delete_many.cpp model/delete_one.cpp model/insert_one.cpp @@ -69,300 +346,33 @@ set(test_driver_sources result/replace_one.cpp result/update.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 - 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 -) - -add_executable(test_driver - ${PROJECT_SOURCE_DIR}/test_util/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 - ${PROJECT_SOURCE_DIR}/test_util/client_helpers.cpp - ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp - spec/crud.cpp - ${spec_test_common} -) - -add_executable(test_gridfs_specs - ${PROJECT_SOURCE_DIR}/test_util/client_helpers.cpp - ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp - spec/gridfs.cpp - ${spec_test_common} -) - -add_executable(test_client_side_encryption_specs - ${PROJECT_SOURCE_DIR}/test_util/client_helpers.cpp - ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp - spec/client_side_encryption.cpp - ${spec_test_common} -) - -add_executable(test_command_monitoring_specs - ${PROJECT_SOURCE_DIR}/test_util/client_helpers.cpp - ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp - spec/command_monitoring.cpp - ${spec_test_common} -) - -add_executable(test_transactions_specs - ${PROJECT_SOURCE_DIR}/test_util/client_helpers.cpp - ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp - spec/transactions.cpp - ${spec_test_common} -) - -add_executable(test_retryable_reads_specs - ${PROJECT_SOURCE_DIR}/test_util/client_helpers.cpp - ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp - spec/retryable-reads.cpp - ${spec_test_common} -) - -add_executable(test_read_write_concern_specs - ${PROJECT_SOURCE_DIR}/test_util/client_helpers.cpp - ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp - spec/read_write_concern.cpp - ${spec_test_common} -) - -add_executable(test_mongohouse_specs - ${PROJECT_SOURCE_DIR}/test_util/client_helpers.cpp - ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp - spec/mongohouse.cpp - ${spec_test_common} -) - -add_executable(test_unified_format_spec - ${PROJECT_SOURCE_DIR}/test_util/client_helpers.cpp - ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp - spec/unified_tests/operations.cpp - spec/unified_tests/runner.cpp - ${spec_test_common} -) - -add_executable(test_versioned_api - ${PROJECT_SOURCE_DIR}/test_util/client_helpers.cpp - ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp versioned_api.cpp - ${spec_test_common} + write_concern.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}) - -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") - 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) 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) - -# 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") - -set_tests_properties(gridfs_specs PROPERTIES - ENVIRONMENT "GRIDFS_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/gridfs") - -set_tests_properties(client_side_encryption_specs PROPERTIES - ENVIRONMENT "CLIENT_SIDE_ENCRYPTION_LEGACY_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/client_side_encryption/legacy") - -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_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_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/transactions") -set_property(TEST transactions_specs - 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") - -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 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/" - "UNIFIED_FORMAT_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/unified-format" - "VERSIONED_API_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/versioned-api" -) - -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 - 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 e199b78df28a40aff38a09b7d2222c3c97449e03 Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Wed, 24 May 2023 11:09:50 -0500 Subject: [PATCH 02/61] pin to latest C driver --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2cc95312de..971468552d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,8 +75,8 @@ if (${NEED_DOWNLOAD_C_DRIVER}) # Declare mongo-c-driver as a dependency FetchContent_Declare( mongo-c-driver - GIT_REPOSITORY https://github.com/kkloberdanz/mongo-c-driver.git - GIT_TAG 1.24.0 + GIT_REPOSITORY https://github.com/mongodb/mongo-c-driver.git + GIT_TAG b9ca36ff8c64f12330326f080c725c5502294834 ) FetchContent_MakeAvailable(mongo-c-driver) From 2660f5ad89d0854ffbac7173b312092de3bf3387 Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Wed, 24 May 2023 14:51:01 -0500 Subject: [PATCH 03/61] Update CMakeLists.txt Co-authored-by: vector-of-bool --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 971468552d..335cc07e05 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,7 +47,7 @@ set(NEED_DOWNLOAD_C_DRIVER false CACHE INTERNAL "") 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) From 9ea5b5250287969b6873e48e2644731d49de3b25 Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Wed, 24 May 2023 14:51:09 -0500 Subject: [PATCH 04/61] Update CMakeLists.txt Co-authored-by: vector-of-bool --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 335cc07e05..bad6c765d6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,7 +61,7 @@ if(TARGET mongoc_shared OR TARGET mongoc_static) else() find_package(mongoc-${LIBMONGOC_REQUIRED_ABI_VERSION} ${LIBMONGOC_REQUIRED_VERSION} QUIET) if(mongoc-${LIBMONGOC_REQUIRED_ABI_VERSION}_FOUND) - message("already found libmongoc, don't need to download it.") + message(STATUS "Already found libmongoc, don't need to download it.") else() set(NEED_DOWNLOAD_C_DRIVER true CACHE INTERNAL "") endif() From 51d91ee1cff033dd2d86c24b3f42c887834ce234 Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Wed, 24 May 2023 14:51:16 -0500 Subject: [PATCH 05/61] Update CMakeLists.txt Co-authored-by: vector-of-bool --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bad6c765d6..9cff70dfe1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,7 +68,7 @@ else() endif() if (${NEED_DOWNLOAD_C_DRIVER}) - message("No Mongo C Driver path provided via CMAKE_PREFIX_PATH, will download a release from the internet.") + message(STATUS "No Mongo C Driver path provided via CMAKE_PREFIX_PATH, will download a release from the internet.") include(FetchContent) include(ExternalProject) From 599ca9ddd2b66e8e9d78f2b4128694175403090b Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Wed, 24 May 2023 14:51:27 -0500 Subject: [PATCH 06/61] Update CMakeLists.txt Co-authored-by: vector-of-bool --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9cff70dfe1..36cc7b4308 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,7 +67,7 @@ else() endif() endif() -if (${NEED_DOWNLOAD_C_DRIVER}) +if (NEED_DOWNLOAD_C_DRIVER) message(STATUS "No Mongo C Driver path provided via CMAKE_PREFIX_PATH, will download a release from the internet.") include(FetchContent) include(ExternalProject) From 81a6b7c51bac4eeefd14cf9b64f2f4d3ea0ad93a Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Wed, 24 May 2023 14:55:07 -0500 Subject: [PATCH 07/61] Update cmake/BsoncxxUtil.cmake Co-authored-by: vector-of-bool --- cmake/BsoncxxUtil.cmake | 6 ------ 1 file changed, 6 deletions(-) diff --git a/cmake/BsoncxxUtil.cmake b/cmake/BsoncxxUtil.cmake index 91baef7e74..d98f3ae9bf 100644 --- a/cmake/BsoncxxUtil.cmake +++ b/cmake/BsoncxxUtil.cmake @@ -62,12 +62,6 @@ function(bsoncxx_add_library TARGET OUTPUT_NAME LINK_TYPE) EXPORT_FILE_NAME config/export.hpp STATIC_DEFINE BSONCXX_STATIC ) - - if (${NEED_DOWNLOAD_C_DRIVER}) - add_dependencies(${TARGET} mongo-c-driver-build) - target_include_directories(${TARGET} PRIVATE ${MONGOC_INSTALL_DIR}/include/libmongoc-1.0/mongoc/) - target_include_directories(${TARGET} PRIVATE ${MONGOC_INSTALL_DIR}/include/libbson-1.0/bson/) - endif() endfunction(bsoncxx_add_library) # Install the specified forms of the bsoncxx library (i.e., shared and/or static) From 16b115a3a77b222e09e0f2476bd2cabe89686e91 Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Wed, 24 May 2023 14:55:25 -0500 Subject: [PATCH 08/61] Update cmake/MongocxxUtil.cmake Co-authored-by: vector-of-bool --- cmake/MongocxxUtil.cmake | 6 ------ 1 file changed, 6 deletions(-) diff --git a/cmake/MongocxxUtil.cmake b/cmake/MongocxxUtil.cmake index c5c508b346..43d406e015 100644 --- a/cmake/MongocxxUtil.cmake +++ b/cmake/MongocxxUtil.cmake @@ -46,12 +46,6 @@ function(mongocxx_add_library TARGET OUTPUT_NAME LINK_TYPE) EXPORT_FILE_NAME config/export.hpp STATIC_DEFINE MONGOCXX_STATIC ) - - if (${NEED_DOWNLOAD_C_DRIVER}) - add_dependencies(${TARGET} mongo-c-driver-build) - target_include_directories(${TARGET} PRIVATE ${MONGOC_INSTALL_DIR}/include/libmongoc-1.0/mongoc/) - target_include_directories(${TARGET} PRIVATE ${MONGOC_INSTALL_DIR}/include/libbson-1.0/bson/) - endif() endfunction(mongocxx_add_library) # Install the specified forms of the mongocxx library (i.e., shared and/or static) From 67037d0f986109a0221cc36319491c2098eded41 Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Wed, 24 May 2023 14:56:13 -0500 Subject: [PATCH 09/61] Update src/mongocxx/test/CMakeLists.txt Co-authored-by: vector-of-bool --- src/mongocxx/test/CMakeLists.txt | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/mongocxx/test/CMakeLists.txt b/src/mongocxx/test/CMakeLists.txt index 5df29e007d..243a2b0a16 100644 --- a/src/mongocxx/test/CMakeLists.txt +++ b/src/mongocxx/test/CMakeLists.txt @@ -181,13 +181,6 @@ if (BUILD_TESTS STREQUAL "ON") ${spec_test_common} ) - set (test_include_directories - ${libmongoc_include_directories} - ${MONGOC_INSTALL_DIR}/include/libmongoc-1.0/ - ${MONGOC_INSTALL_DIR}/include/libbson-1.0/ - ${MONGOC_INSTALL_DIR}/include/libbson-1.0/bson/ - ${MONGOC_INSTALL_DIR}/include/libmongoc-1.0/mongoc/ - ) target_link_libraries(test_driver mongocxx_mocked ${libmongoc_target}) target_link_libraries(test_logging mongocxx_mocked ${libmongoc_target}) From d7de582b34d0b3b24b0b19a72c1f8352d2ed438c Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Wed, 24 May 2023 14:56:30 -0500 Subject: [PATCH 10/61] Update src/mongocxx/CMakeLists.txt Co-authored-by: vector-of-bool --- src/mongocxx/CMakeLists.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/mongocxx/CMakeLists.txt b/src/mongocxx/CMakeLists.txt index fd5057d308..5d4ba4deff 100644 --- a/src/mongocxx/CMakeLists.txt +++ b/src/mongocxx/CMakeLists.txt @@ -66,10 +66,6 @@ else() find_package(libmongoc-${LIBMONGOC_REQUIRED_ABI_VERSION} ${LIBMONGOC_REQUIRED_VERSION} REQUIRED) message ("found libmongoc version ${MONGOC_VERSION}") set(libmongoc_target ${MONGOC_LIBRARIES}) - set(libmongoc_include_directories ${MONGOC_INCLUDE_DIRS} - ${MONGOC_INSTALL_DIR}/include/libmongoc-1.0/mongoc/ - ${MONGOC_INSTALL_DIR}/include/libbson-1.0/bson/ - ) set(libmongoc_definitions ${MONGOC_DEFINITIONS}) if(MONGOCXX_BUILD_STATIC) set(mongocxx_pkg_dep "find_dependency(libmongoc-1.0 REQUIRED)") From 086a13411ba16527d0467f386bd5efc8b47c7ec0 Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Wed, 24 May 2023 14:56:35 -0500 Subject: [PATCH 11/61] Update src/mongocxx/CMakeLists.txt Co-authored-by: vector-of-bool --- src/mongocxx/CMakeLists.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/mongocxx/CMakeLists.txt b/src/mongocxx/CMakeLists.txt index 5d4ba4deff..6b10ef289c 100644 --- a/src/mongocxx/CMakeLists.txt +++ b/src/mongocxx/CMakeLists.txt @@ -74,10 +74,6 @@ 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_include_directories ${MONGOC_STATIC_INCLUDE_DIRS} - ${MONGOC_INSTALL_DIR}/include/libmongoc-1.0/mongoc/ - ${MONGOC_INSTALL_DIR}/include/libbson-1.0/bson/ - ) set(libmongoc_definitions ${MONGOC_STATIC_DEFINITIONS}) if(MONGOCXX_BUILD_STATIC) set(mongocxx_pkg_dep "find_dependency(libmongoc-static-1.0 REQUIRED)") From dce2690e87c349074968f64ddc16c558e8f9a2c9 Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Wed, 24 May 2023 15:07:50 -0500 Subject: [PATCH 12/61] dont need to call ExternalProject_Add and dont need to cache variable --- CMakeLists.txt | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 36cc7b4308..b6580f767d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,7 +43,7 @@ endif() set(LIBMONGOC_REQUIRED_VERSION 1.22.1) # TODO: update to 1.24.0 once released. set(LIBMONGOC_REQUIRED_ABI_VERSION 1.0) -set(NEED_DOWNLOAD_C_DRIVER false CACHE INTERNAL "") +set(NEED_DOWNLOAD_C_DRIVER false INTERNAL "") if(TARGET mongoc_shared OR TARGET mongoc_static) # If these targets exist, then libmongoc has already been included as a project # sub-directory @@ -84,13 +84,6 @@ if (NEED_DOWNLOAD_C_DRIVER) # Set the installation directory for mongo-c-driver set(MONGOC_INSTALL_DIR ${CMAKE_BINARY_DIR}/mongo-c-driver-install) - # Build mongo-c-driver using ExternalProject - ExternalProject_Add(mongo-c-driver-build - SOURCE_DIR ${mongo-c-driver_SOURCE_DIR} - BINARY_DIR ${CMAKE_BINARY_DIR}/mongo-c-driver-build - INSTALL_DIR ${MONGOC_INSTALL_DIR} - CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${MONGOC_INSTALL_DIR} - ) file(REMOVE ${mongo-c-driver_SOURCE_DIR}/build/generate-uninstall.sh) file(REMOVE ${mongo-c-driver_SOURCE_DIR}/build/generate-uninstall.cmd) endif() From 0654a5a4b15f5b804091fd521457b6030b1cb608 Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Wed, 24 May 2023 15:49:05 -0500 Subject: [PATCH 13/61] it appears this variable must be CACHE'ed --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b6580f767d..fd3f507d1a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,7 +43,7 @@ endif() set(LIBMONGOC_REQUIRED_VERSION 1.22.1) # TODO: update to 1.24.0 once released. set(LIBMONGOC_REQUIRED_ABI_VERSION 1.0) -set(NEED_DOWNLOAD_C_DRIVER false INTERNAL "") +set(NEED_DOWNLOAD_C_DRIVER false CACHE INTERNAL "") if(TARGET mongoc_shared OR TARGET mongoc_static) # If these targets exist, then libmongoc has already been included as a project # sub-directory From fec94f4ae58c790d2edc67245b55d6f2f429a811 Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Thu, 25 May 2023 11:22:07 -0500 Subject: [PATCH 14/61] initialize NEED_DOWNLOAD_C_DRIVER as a simple cmake variable --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fd3f507d1a..0c3340232d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,7 +43,7 @@ endif() set(LIBMONGOC_REQUIRED_VERSION 1.22.1) # TODO: update to 1.24.0 once released. set(LIBMONGOC_REQUIRED_ABI_VERSION 1.0) -set(NEED_DOWNLOAD_C_DRIVER false CACHE INTERNAL "") +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 From a921a7c399c540d9ed74e98d0852527c11d2a488 Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Thu, 25 May 2023 12:44:10 -0500 Subject: [PATCH 15/61] Update CMakeLists.txt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Roberto C. Sánchez --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0c3340232d..591259b7e4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,7 +67,7 @@ else() endif() endif() -if (NEED_DOWNLOAD_C_DRIVER) +if(NEED_DOWNLOAD_C_DRIVER) message(STATUS "No Mongo C Driver path provided via CMAKE_PREFIX_PATH, will download a release from the internet.") include(FetchContent) include(ExternalProject) From c28eec54676824019c8c09455924457410acdbb9 Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Thu, 25 May 2023 15:27:00 -0500 Subject: [PATCH 16/61] Update CMakeLists.txt Co-authored-by: Kevin Albertson --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 591259b7e4..1637658832 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,7 +40,7 @@ else() message(WARNING "Unknown compiler... recklessly proceeding without a version check") endif() -set(LIBMONGOC_REQUIRED_VERSION 1.22.1) # TODO: update to 1.24.0 once released. +set(LIBMONGOC_REQUIRED_VERSION 1.22.1) # TODO (CXX-2696): update to 1.24.0 once released. set(LIBMONGOC_REQUIRED_ABI_VERSION 1.0) set(NEED_DOWNLOAD_C_DRIVER false) From f30f17c5c33c86d27a9281eacf6b8ab18ca27684 Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Thu, 25 May 2023 15:32:26 -0500 Subject: [PATCH 17/61] Update CMakeLists.txt Co-authored-by: Kevin Albertson --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1637658832..4dbf46796e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,7 +61,7 @@ if(TARGET mongoc_shared OR TARGET mongoc_static) else() find_package(mongoc-${LIBMONGOC_REQUIRED_ABI_VERSION} ${LIBMONGOC_REQUIRED_VERSION} QUIET) if(mongoc-${LIBMONGOC_REQUIRED_ABI_VERSION}_FOUND) - message(STATUS "Already found libmongoc, don't need to download it.") + message(STATUS "Found libmongoc ${mongoc-${LIBMONGOC_REQUIRED_ABI_VERSION}_VERSION}, don't need to download it.") else() set(NEED_DOWNLOAD_C_DRIVER true CACHE INTERNAL "") endif() From d805d468a41ca0273f4534ea07e6c40086e06f0b Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Thu, 25 May 2023 15:33:49 -0500 Subject: [PATCH 18/61] Update CMakeLists.txt Co-authored-by: Kevin Albertson --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4dbf46796e..7d6c0f32d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,7 +68,7 @@ else() endif() if(NEED_DOWNLOAD_C_DRIVER) - message(STATUS "No Mongo C Driver path provided via CMAKE_PREFIX_PATH, will download a release from the internet.") + message(STATUS "No Mongo C Driver path provided via CMAKE_PREFIX_PATH, will download C driver version ${LIBMONGOC_DOWNLOAD_VERSION} from the internet.") include(FetchContent) include(ExternalProject) From 04fbff6e3975f2a9b5916ac10cfe32d95395052b Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Thu, 25 May 2023 15:35:11 -0500 Subject: [PATCH 19/61] Update CMakeLists.txt Co-authored-by: Kevin Albertson --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d6c0f32d9..4f4080484d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -76,7 +76,7 @@ if(NEED_DOWNLOAD_C_DRIVER) FetchContent_Declare( mongo-c-driver GIT_REPOSITORY https://github.com/mongodb/mongo-c-driver.git - GIT_TAG b9ca36ff8c64f12330326f080c725c5502294834 + GIT_TAG ${LIBMONGOC_DOWNLOAD_VERSION} ) FetchContent_MakeAvailable(mongo-c-driver) From 6f7227f441c50efcc2229a1d5586fa1905d38ce7 Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Fri, 26 May 2023 09:08:46 -0500 Subject: [PATCH 20/61] don't make tests opt-in for this PR --- src/bsoncxx/test/CMakeLists.txt | 34 +- src/mongocxx/test/CMakeLists.txt | 581 +++++++++++++++---------------- 2 files changed, 305 insertions(+), 310 deletions(-) diff --git a/src/bsoncxx/test/CMakeLists.txt b/src/bsoncxx/test/CMakeLists.txt index e76955d180..e06869d441 100644 --- a/src/bsoncxx/test/CMakeLists.txt +++ b/src/bsoncxx/test/CMakeLists.txt @@ -12,26 +12,24 @@ # See the License for the specific language governing permissions and # limitations under the License. -if (BUILD_TESTS STREQUAL "ON") - include_directories( - ${MONGO_CXX_DRIVER_SOURCE_DIR}/src/third_party/catch/include - ) +include_directories( + ${MONGO_CXX_DRIVER_SOURCE_DIR}/src/third_party/catch/include +) - 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 - ${src_bsoncxx_test_DIST_cpps} - ) +add_executable(test_bson + ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp + ${src_bsoncxx_test_DIST_cpps} +) - 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}) +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}) - add_test(bson test_bson) +add_test(bson test_bson) - set_dist_list (src_bsoncxx_test_DIST - CMakeLists.txt - ${src_bsoncxx_test_DIST_cpps} - ) -endif() +set_dist_list (src_bsoncxx_test_DIST + CMakeLists.txt + ${src_bsoncxx_test_DIST_cpps} +) diff --git a/src/mongocxx/test/CMakeLists.txt b/src/mongocxx/test/CMakeLists.txt index 243a2b0a16..720074e923 100644 --- a/src/mongocxx/test/CMakeLists.txt +++ b/src/mongocxx/test/CMakeLists.txt @@ -12,279 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -if (BUILD_TESTS STREQUAL "ON") - include_directories( - ${THIRD_PARTY_SOURCE_DIR}/catch/include - ) - - set(test_driver_sources - 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 - 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 - sdam-monitoring.cpp - spec/initial_dns_seedlist_discovery.cpp - spec/monitoring.cpp - spec/monitoring.hh - spec/unified_tests/assert.cpp - spec/unified_tests/entity.cpp - spec/uri_options.cpp - transactions.cpp - 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 - ) - - add_executable(test_driver - ${PROJECT_SOURCE_DIR}/test_util/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 - ${PROJECT_SOURCE_DIR}/test_util/client_helpers.cpp - ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp - spec/crud.cpp - ${spec_test_common} - ) - - add_executable(test_gridfs_specs - ${PROJECT_SOURCE_DIR}/test_util/client_helpers.cpp - ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp - spec/gridfs.cpp - ${spec_test_common} - ) - - add_executable(test_client_side_encryption_specs - ${PROJECT_SOURCE_DIR}/test_util/client_helpers.cpp - ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp - spec/client_side_encryption.cpp - ${spec_test_common} - ) - - add_executable(test_command_monitoring_specs - ${PROJECT_SOURCE_DIR}/test_util/client_helpers.cpp - ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp - spec/command_monitoring.cpp - ${spec_test_common} - ) - - add_executable(test_transactions_specs - ${PROJECT_SOURCE_DIR}/test_util/client_helpers.cpp - ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp - spec/transactions.cpp - ${spec_test_common} - ) - - add_executable(test_retryable_reads_specs - ${PROJECT_SOURCE_DIR}/test_util/client_helpers.cpp - ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp - spec/retryable-reads.cpp - ${spec_test_common} - ) +include_directories( + ${THIRD_PARTY_SOURCE_DIR}/catch/include +) - add_executable(test_read_write_concern_specs - ${PROJECT_SOURCE_DIR}/test_util/client_helpers.cpp - ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp - spec/read_write_concern.cpp - ${spec_test_common} - ) - - add_executable(test_mongohouse_specs - ${PROJECT_SOURCE_DIR}/test_util/client_helpers.cpp - ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp - spec/mongohouse.cpp - ${spec_test_common} - ) - - add_executable(test_unified_format_spec - ${PROJECT_SOURCE_DIR}/test_util/client_helpers.cpp - ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp - spec/unified_tests/operations.cpp - spec/unified_tests/runner.cpp - ${spec_test_common} - ) - - add_executable(test_versioned_api - ${PROJECT_SOURCE_DIR}/test_util/client_helpers.cpp - ${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}) - 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 ${test_include_directories}) - target_include_directories(test_logging PRIVATE ${test_include_directories}) - target_include_directories(test_instance PRIVATE ${test_include_directories}) - target_include_directories(test_client_side_encryption_specs PRIVATE ${test_include_directories}) - target_include_directories(test_crud_specs PRIVATE ${test_include_directories}) - target_include_directories(test_gridfs_specs PRIVATE ${test_include_directories}) - target_include_directories(test_command_monitoring_specs PRIVATE ${test_include_directories}) - target_include_directories(test_transactions_specs PRIVATE ${test_include_directories}) - target_include_directories(test_retryable_reads_specs PRIVATE ${test_include_directories}) - target_include_directories(test_read_write_concern_specs PRIVATE ${test_include_directories}) - target_include_directories(test_mongohouse_specs PRIVATE ${test_include_directories}) - target_include_directories(test_unified_format_spec PRIVATE ${test_include_directories}) - target_include_directories(test_versioned_api PRIVATE ${test_include_directories}) - - 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") - 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) - 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) - - # 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") - - set_tests_properties(gridfs_specs PROPERTIES - ENVIRONMENT "GRIDFS_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/gridfs") - - set_tests_properties(client_side_encryption_specs PROPERTIES - ENVIRONMENT "CLIENT_SIDE_ENCRYPTION_LEGACY_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/client_side_encryption/legacy") - - 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_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_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/transactions") - set_property(TEST transactions_specs - 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") - - 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 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/" - "UNIFIED_FORMAT_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/unified-format" - "VERSIONED_API_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/versioned-api" - ) - - 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 +set(test_driver_sources CMakeLists.txt bulk_write.cpp change_streams.cpp @@ -300,8 +32,6 @@ if (BUILD_TESTS STREQUAL "ON") gridfs/uploader.cpp hint.cpp index_view.cpp - instance.cpp - logging.cpp model/delete_many.cpp model/delete_one.cpp model/insert_one.cpp @@ -339,33 +69,300 @@ if (BUILD_TESTS STREQUAL "ON") result/replace_one.cpp result/update.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(spec_test_common + spec/operation.cpp + spec/unified_tests/entity.cpp + spec/unified_tests/assert.cpp + spec/monitoring.cpp + spec/util.cpp +) + +add_executable(test_driver + ${PROJECT_SOURCE_DIR}/test_util/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 + ${PROJECT_SOURCE_DIR}/test_util/client_helpers.cpp + ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp + spec/crud.cpp + ${spec_test_common} +) + +add_executable(test_gridfs_specs + ${PROJECT_SOURCE_DIR}/test_util/client_helpers.cpp + ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp + spec/gridfs.cpp + ${spec_test_common} +) + +add_executable(test_client_side_encryption_specs + ${PROJECT_SOURCE_DIR}/test_util/client_helpers.cpp + ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp + spec/client_side_encryption.cpp + ${spec_test_common} +) + +add_executable(test_command_monitoring_specs + ${PROJECT_SOURCE_DIR}/test_util/client_helpers.cpp + ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp + spec/command_monitoring.cpp + ${spec_test_common} +) + +add_executable(test_transactions_specs + ${PROJECT_SOURCE_DIR}/test_util/client_helpers.cpp + ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp + spec/transactions.cpp + ${spec_test_common} +) + +add_executable(test_retryable_reads_specs + ${PROJECT_SOURCE_DIR}/test_util/client_helpers.cpp + ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp + spec/retryable-reads.cpp + ${spec_test_common} +) + +add_executable(test_read_write_concern_specs + ${PROJECT_SOURCE_DIR}/test_util/client_helpers.cpp + ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp + spec/read_write_concern.cpp + ${spec_test_common} +) + +add_executable(test_mongohouse_specs + ${PROJECT_SOURCE_DIR}/test_util/client_helpers.cpp + ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp + spec/mongohouse.cpp + ${spec_test_common} +) + +add_executable(test_unified_format_spec + ${PROJECT_SOURCE_DIR}/test_util/client_helpers.cpp + ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp + spec/unified_tests/operations.cpp + spec/unified_tests/runner.cpp + ${spec_test_common} +) + +add_executable(test_versioned_api + ${PROJECT_SOURCE_DIR}/test_util/client_helpers.cpp + ${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}) +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}) + +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") + 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) 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) + +# 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") + +set_tests_properties(gridfs_specs PROPERTIES + ENVIRONMENT "GRIDFS_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/gridfs") + +set_tests_properties(client_side_encryption_specs PROPERTIES + ENVIRONMENT "CLIENT_SIDE_ENCRYPTION_LEGACY_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/client_side_encryption/legacy") + +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_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_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/transactions") +set_property(TEST transactions_specs + 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") + +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 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/" + "UNIFIED_FORMAT_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/unified-format" + "VERSIONED_API_TESTS_PATH=${PROJECT_SOURCE_DIR}/../../data/versioned-api" +) + +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 + 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 b604f40f28b8edb9160cc9c8c35304d52ae0dae9 Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Fri, 26 May 2023 09:15:03 -0500 Subject: [PATCH 21/61] add LIBMONGOC_DOWNLOAD_VERSION --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f4080484d..8f27a11d4b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,6 +41,7 @@ else() endif() set(LIBMONGOC_REQUIRED_VERSION 1.22.1) # TODO (CXX-2696): update to 1.24.0 once released. +set(LIBMONGOC_DOWNLOAD_VERSION b9ca36ff8c64f12330326f080c725c5502294834) # TODO (CXX-2696): update to 1.24.0 once released. set(LIBMONGOC_REQUIRED_ABI_VERSION 1.0) set(NEED_DOWNLOAD_C_DRIVER false) From 6477f54f3b450f3909d9dbc3566f622dc62641a0 Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Fri, 26 May 2023 09:19:38 -0500 Subject: [PATCH 22/61] this variable is no longer used --- .evergreen/compile.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.evergreen/compile.sh b/.evergreen/compile.sh index bf87b3ea2d..fb90276bbb 100755 --- a/.evergreen/compile.sh +++ b/.evergreen/compile.sh @@ -52,7 +52,7 @@ esac . .evergreen/find_cmake.sh cd build -"$CMAKE" -G "$GENERATOR" "-DCMAKE_BUILD_TYPE=${BUILD_TYPE}" -DMONGOCXX_ENABLE_SLOW_TESTS=ON -DENABLE_UNINSTALL=ON -DBUILD_TESTS=ON "$@" .. +"$CMAKE" -G "$GENERATOR" "-DCMAKE_BUILD_TYPE=${BUILD_TYPE}" -DMONGOCXX_ENABLE_SLOW_TESTS=ON -DENABLE_UNINSTALL=ON "$@" .. "$CMAKE" --build . --config $BUILD_TYPE -- $CMAKE_BUILD_OPTS "$CMAKE" --build . --config $BUILD_TYPE --target install -- $CMAKE_BUILD_OPTS "$CMAKE" --build . --config $BUILD_TYPE --target $CMAKE_EXAMPLES_TARGET -- $CMAKE_BUILD_OPTS From d2f0f762f9dea146ad022c748c2afd82c87ef610 Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Fri, 26 May 2023 10:50:20 -0500 Subject: [PATCH 23/61] comment on why remove the C driver uninstall scripts --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8f27a11d4b..4aa50e46ed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -85,6 +85,7 @@ if(NEED_DOWNLOAD_C_DRIVER) # Set the installation directory for mongo-c-driver set(MONGOC_INSTALL_DIR ${CMAKE_BINARY_DIR}/mongo-c-driver-install) + # These scripts are not needed, and cause the installation to freeze. file(REMOVE ${mongo-c-driver_SOURCE_DIR}/build/generate-uninstall.sh) file(REMOVE ${mongo-c-driver_SOURCE_DIR}/build/generate-uninstall.cmd) endif() From 5ec77f2d0bcfb4707272146cdac78f96a986582e Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Tue, 30 May 2023 09:55:26 -0500 Subject: [PATCH 24/61] supress installation of C driver --- CMakeLists.txt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4aa50e46ed..7099d8742d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,6 +73,10 @@ if(NEED_DOWNLOAD_C_DRIVER) include(FetchContent) include(ExternalProject) + set(libmongoc_target mongoc_static) + set(BUILD_SHARED_LIBS_WITH_STATIC_MONGOC ON CACHE INTERNAL "") + set(MONGOCXX_LINK_WITH_STATIC_MONGOC ON CACHE INTERNAL "") + # Declare mongo-c-driver as a dependency FetchContent_Declare( mongo-c-driver @@ -80,7 +84,11 @@ if(NEED_DOWNLOAD_C_DRIVER) GIT_TAG ${LIBMONGOC_DOWNLOAD_VERSION} ) - FetchContent_MakeAvailable(mongo-c-driver) + FetchContent_GetProperties(mongo-c-driver) + if(NOT mongo-c-driver_POPULATED) + FetchContent_Populate(mongo-c-driver) + add_subdirectory(${mongo-c-driver_SOURCE_DIR} ${mongo-c-driver_BINARY_DIR} EXCLUDE_FROM_ALL) + endif() # Set the installation directory for mongo-c-driver set(MONGOC_INSTALL_DIR ${CMAKE_BINARY_DIR}/mongo-c-driver-install) From 7e4bed224882f493f72efc290fade94cf9f4c0ff Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Tue, 30 May 2023 10:43:44 -0500 Subject: [PATCH 25/61] remove unneeded lines --- CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7099d8742d..5101a1aa32 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,9 +73,7 @@ if(NEED_DOWNLOAD_C_DRIVER) include(FetchContent) include(ExternalProject) - set(libmongoc_target mongoc_static) set(BUILD_SHARED_LIBS_WITH_STATIC_MONGOC ON CACHE INTERNAL "") - set(MONGOCXX_LINK_WITH_STATIC_MONGOC ON CACHE INTERNAL "") # Declare mongo-c-driver as a dependency FetchContent_Declare( From 138985fa9c4fab11def0de01225476c24cacfe53 Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Tue, 30 May 2023 13:41:04 -0500 Subject: [PATCH 26/61] update documentation to reflect new C driver installation process --- .../mongocxx-v3/installation/advanced.md | 30 +++++++++++++++ .../content/mongocxx-v3/installation/linux.md | 35 ++--------------- .../content/mongocxx-v3/installation/macos.md | 35 ++--------------- .../mongocxx-v3/installation/windows.md | 38 ++----------------- etc/releasing.md | 8 ++++ 5 files changed, 50 insertions(+), 96 deletions(-) diff --git a/docs/content/mongocxx-v3/installation/advanced.md b/docs/content/mongocxx-v3/installation/advanced.md index 5e287fa0fd..7fe38e6296 100644 --- a/docs/content/mongocxx-v3/installation/advanced.md +++ b/docs/content/mongocxx-v3/installation/advanced.md @@ -19,6 +19,36 @@ cmake .. \ The above command would produce libraries named `libcustom_bsoncxx.so` and `libcustom_mongocxx.so` (or with the extension appropriate for the build platform). Those libraries could be placed in a standard system directory or in an alternate location and could be linked to by specifying something like `-lcustom_mongocxx -lcustom_bsoncxx` on the linker command line (possibly adjusting the specific flags to those required by your linker). +## Installing the MongoDB C driver. + +The mongocxx driver builds on top of the MongoDB C driver. + +The build of mongocxx-3.8.0 automatically installs the C driver if the C driver is not detected. +To use an existing install of the C driver, set `CMAKE_PREFIX_PATH` to the directory containing the C driver install. + +* For mongocxx-3.7.x, libmongoc 1.22.1 or later is required. +* For mongocxx-3.6.x, libmongoc 1.17.0 or later is required. +* For mongocxx-3.5.x, libmongoc 1.15.0 or later is required. +* For mongocxx-3.4.x, libmongoc 1.13.0 or later is required. +* For mongocxx-3.3.x, libmongoc 1.10.1 or later is required. +* For mongocxx-3.2.x, libmongoc 1.9.2 or later is required. +* For mongocxx-3.1.4+, libmongoc 1.7.0 or later is required. +* For mongocxx-3.1.[0-3], libmongoc 1.5.0 or later is required. +* For mongocxx-3.0.x, we recommend the last 1.4.x version of libmongoc + +Unless you know that your package manager offers a high enough version, you +will need to download and build from the source code. Get a tarball from +the [C Driver releases](https://github.com/mongodb/mongo-c-driver/releases) +page. + +Follow the instructions for building from a tarball at +[Installing libmongoc](http://mongoc.org/libmongoc/current/installing.html). + +Industry best practices and some regulations require the use of TLS 1.1 +or newer. The MongoDB C Driver supports TLS 1.1 on Linux if OpenSSL is +at least version 1.0.1. On macOS and Windows, the C Driver uses native +TLS implementations that support TLS 1.1. + ## Advanced configuration (static configurations) The following sub-sections detail advanced options for configuring the C++ driver and/or its diff --git a/docs/content/mongocxx-v3/installation/linux.md b/docs/content/mongocxx-v3/installation/linux.md index 0ef2cdc557..a4e8c88ff8 100644 --- a/docs/content/mongocxx-v3/installation/linux.md +++ b/docs/content/mongocxx-v3/installation/linux.md @@ -7,34 +7,7 @@ title = "Linux" weight = 33 +++ -### Step 1: Install the latest version of the MongoDB C driver. - -The mongocxx driver builds on top of the MongoDB C driver. - -* For mongocxx-3.7.x, libmongoc 1.22.1 or later is required. -* For mongocxx-3.6.x, libmongoc 1.17.0 or later is required. -* For mongocxx-3.5.x, libmongoc 1.15.0 or later is required. -* For mongocxx-3.4.x, libmongoc 1.13.0 or later is required. -* For mongocxx-3.3.x, libmongoc 1.10.1 or later is required. -* For mongocxx-3.2.x, libmongoc 1.9.2 or later is required. -* For mongocxx-3.1.4+, libmongoc 1.7.0 or later is required. -* For mongocxx-3.1.[0-3], libmongoc 1.5.0 or later is required. -* For mongocxx-3.0.x, we recommend the last 1.4.x version of libmongoc - -Unless you know that your package manager offers a high enough version, you -will need to download and build from the source code. Get a tarball from -the [C Driver releases](https://github.com/mongodb/mongo-c-driver/releases) -page. - -Follow the instructions for building from a tarball at -[Installing libmongoc](http://mongoc.org/libmongoc/current/installing.html). - -Industry best practices and some regulations require the use of TLS 1.1 -or newer. The MongoDB C Driver supports TLS 1.1 on Linux if OpenSSL is -at least version 1.0.1. On macOS and Windows, the C Driver uses native -TLS implementations that support TLS 1.1. - -### Step 2: Choose a C++17 polyfill +### Step 1: Choose a C++17 polyfill The mongocxx driver uses the C++17 features `std::optional` and `std::string_view`. To compile the mongocxx driver for pre-C++17, you @@ -70,7 +43,7 @@ against the same library. **DO NOT** change your project's polyfill if you need to create a stable binary interface. -### Step 3: Download the latest version of the mongocxx driver. +### Step 2: Download the latest version of the mongocxx driver. The most reliable starting point for building the mongocxx driver is the latest release tarball. @@ -88,7 +61,7 @@ cd mongo-cxx-driver-r3.7.1/build Make sure you change to the `build` directory of whatever source tree you obtain. -### Step 4: Configure the driver +### Step 3: Configure the driver On Unix systems, `libmongoc` installs into `/usr/local` by default. Without additional configuration, `mongocxx` installs into its local build directory as a courtesy to those who build @@ -110,7 +83,7 @@ cmake .. \ -DCMAKE_INSTALL_PREFIX=/usr/local ``` -### Step 5: Build and install the driver +### Step 4: Build and install the driver If you are using the default MNMLSTC polyfill and are installing to a directory requiring root permissions, you should install the polyfill with diff --git a/docs/content/mongocxx-v3/installation/macos.md b/docs/content/mongocxx-v3/installation/macos.md index 17f1d7d8a8..84d41c6c27 100644 --- a/docs/content/mongocxx-v3/installation/macos.md +++ b/docs/content/mongocxx-v3/installation/macos.md @@ -7,34 +7,7 @@ title = "macOS" weight = 32 +++ -### Step 1: Install the latest version of the MongoDB C driver. - -The mongocxx driver builds on top of the MongoDB C driver. - -* For mongocxx-3.7.x, libmongoc 1.22.1 or later is required. -* For mongocxx-3.6.x, libmongoc 1.17.0 or later is required. -* For mongocxx-3.5.x, libmongoc 1.15.0 or later is required. -* For mongocxx-3.4.x, libmongoc 1.13.0 or later is required. -* For mongocxx-3.3.x, libmongoc 1.10.1 or later is required. -* For mongocxx-3.2.x, libmongoc 1.9.2 or later is required. -* For mongocxx-3.1.4+, libmongoc 1.7.0 or later is required. -* For mongocxx-3.1.[0-3], libmongoc 1.5.0 or later is required. -* For mongocxx-3.0.x, we recommend the last 1.4.x version of libmongoc - -Unless you know that your package manager offers a high enough version, you -will need to download and build from the source code. Get a tarball from -the [C Driver releases](https://github.com/mongodb/mongo-c-driver/releases) -page. - -Follow the instructions for building from a tarball at -[Installing libmongoc](http://mongoc.org/libmongoc/current/installing.html). - -Industry best practices and some regulations require the use of TLS 1.1 -or newer. The MongoDB C Driver supports TLS 1.1 on Linux if OpenSSL is -at least version 1.0.1. On macOS and Windows, the C Driver uses native -TLS implementations that support TLS 1.1. - -### Step 2: Choose a C++17 polyfill +### Step 1: Choose a C++17 polyfill The mongocxx driver uses the C++17 features `std::optional` and `std::string_view`. To compile the mongocxx driver for pre-C++17, you @@ -70,7 +43,7 @@ against the same library. **DO NOT** change your project's polyfill if you need to create a stable binary interface. -### Step 3: Download the latest version of the mongocxx driver. +### Step 2: Download the latest version of the mongocxx driver. The most reliable starting point for building the mongocxx driver is the latest release tarball. @@ -88,7 +61,7 @@ cd mongo-cxx-driver-r3.7.1/build Make sure you change to the `build` directory of whatever source tree you obtain. -### Step 4: Configure the driver +### Step 3: Configure the driver On Unix systems, `libmongoc` installs into `/usr/local` by default. Without additional configuration, `mongocxx` installs into its local build directory as a courtesy to those who build @@ -110,7 +83,7 @@ cmake .. \ -DCMAKE_INSTALL_PREFIX=/usr/local ``` -### Step 5: Build and install the driver +### Step 4: Build and install the driver If you are using the default MNMLSTC polyfill and are installing to a directory requiring root permissions, you should install the polyfill with diff --git a/docs/content/mongocxx-v3/installation/windows.md b/docs/content/mongocxx-v3/installation/windows.md index 0a8287a346..48fc90ce48 100644 --- a/docs/content/mongocxx-v3/installation/windows.md +++ b/docs/content/mongocxx-v3/installation/windows.md @@ -7,37 +7,7 @@ title = "Windows" weight = 31 +++ -### Step 1: Install the latest version of the MongoDB C driver. - -The mongocxx driver builds on top of the MongoDB C driver. - -* For mongocxx-3.7.x, libmongoc 1.22.1 or later is required. -* For mongocxx-3.6.x, libmongoc 1.17.0 or later is required. -* For mongocxx-3.5.x, libmongoc 1.15.0 or later is required. -* For mongocxx-3.4.x, libmongoc 1.13.0 or later is required. -* For mongocxx-3.3.x, libmongoc 1.10.1 or later is required. -* For mongocxx-3.2.x, libmongoc 1.9.2 or later is required. -* For mongocxx-3.1.4+, libmongoc 1.7.0 or later is required. -* For mongocxx-3.1.[0-3], libmongoc 1.5.0 or later is required. -* For mongocxx-3.0.x, we recommend the last 1.4.x version of libmongoc - -Unless you know that your package manager offers a high enough version, you -will need to download and build from the source code. Get a tarball from -the [C Driver releases](https://github.com/mongodb/mongo-c-driver/releases) -page. - -Follow the instructions for building from a tarball at -[Installing libmongoc](http://mongoc.org/libmongoc/current/installing.html). - -Industry best practices and some regulations require the use of TLS 1.1 -or newer. The MongoDB C Driver supports TLS 1.1 on Linux if OpenSSL is -at least version 1.0.1. On macOS and Windows, the C Driver uses native -TLS implementations that support TLS 1.1. - -If you are compiling on Windows, you should disable extra alignment with -`-DENABLE_EXTRA_ALIGNMENT=0` when configuring the C driver. - -### Step 2: Choose a C++17 polyfill +### Step 1: Choose a C++17 polyfill The mongocxx driver uses the C++17 features `std::optional` and `std::string_view`. To compile the mongocxx driver for pre-C++17, you @@ -73,7 +43,7 @@ against the same library. **DO NOT** change your project's polyfill if you need to create a stable binary interface. -### Step 3: Download the latest version of the mongocxx driver. +### Step 2: Download the latest version of the mongocxx driver. The most reliable starting point for building the mongocxx driver is the latest release tarball. @@ -91,7 +61,7 @@ cd mongo-cxx-driver-r3.7.1/build Make sure you change to the `build` directory of whatever source tree you obtain. -### Step 4: Configure the driver +### Step 3: Configure the driver On Windows, the C++ driver is configured as follows (adjusting the path of the CMake executable as appropriate to your system): @@ -150,7 +120,7 @@ cmake .. \ -DCMAKE_INSTALL_PREFIX=C:\mongo-cxx-driver ``` -### Step 5: Build and install the driver +### Step 4: Build and install the driver Build and install the driver: diff --git a/etc/releasing.md b/etc/releasing.md index c67c8c9706..359ac6d925 100644 --- a/etc/releasing.md +++ b/etc/releasing.md @@ -205,6 +205,14 @@ pushed. - Checkout the master branch. Push the commit containing changes to `etc/` and `docs/`. This may require pushing the commit to a fork of the C++ Driver repository and creating a pull request. +- Edit the `Installing the MongoDB C driver` section of + `docs/content/mongocxx-v3/installation/advanced.md` to reflect to libmongoc + requirements. +- Edit `docs/content/mongocxx-v3/installation/linux.md`, + `docs/content/mongocxx-v3/installation/macos.md` and + `docs/content/mongocxx-v3/installation/windows.md`. + If the release was not a release candidate, update `Step 3` to reflect the + new latest stable version to download. ## Homebrew This requires a macOS machine. From 9a824f62ecdac59b310ba6d65150e3001909ee4f Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Tue, 30 May 2023 13:47:39 -0500 Subject: [PATCH 27/61] remove unused variable --- CMakeLists.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5101a1aa32..edfbb749c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -88,9 +88,6 @@ if(NEED_DOWNLOAD_C_DRIVER) add_subdirectory(${mongo-c-driver_SOURCE_DIR} ${mongo-c-driver_BINARY_DIR} EXCLUDE_FROM_ALL) endif() - # Set the installation directory for mongo-c-driver - set(MONGOC_INSTALL_DIR ${CMAKE_BINARY_DIR}/mongo-c-driver-install) - # These scripts are not needed, and cause the installation to freeze. file(REMOVE ${mongo-c-driver_SOURCE_DIR}/build/generate-uninstall.sh) file(REMOVE ${mongo-c-driver_SOURCE_DIR}/build/generate-uninstall.cmd) From 467a8f4fcb8fd900829eeed555ac635918f2e4fc Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Tue, 30 May 2023 13:55:39 -0500 Subject: [PATCH 28/61] after supressing C driver installation, this is no longer needed --- CMakeLists.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index edfbb749c1..a84b0643d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -87,10 +87,6 @@ if(NEED_DOWNLOAD_C_DRIVER) FetchContent_Populate(mongo-c-driver) add_subdirectory(${mongo-c-driver_SOURCE_DIR} ${mongo-c-driver_BINARY_DIR} EXCLUDE_FROM_ALL) endif() - - # These scripts are not needed, and cause the installation to freeze. - file(REMOVE ${mongo-c-driver_SOURCE_DIR}/build/generate-uninstall.sh) - file(REMOVE ${mongo-c-driver_SOURCE_DIR}/build/generate-uninstall.cmd) endif() # All of our target compilers support the deprecated From 5e4e7ab155fc1651e8124ad615b29270301d6437 Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Tue, 30 May 2023 14:39:37 -0500 Subject: [PATCH 29/61] check there are no TODOs in CMakeLists.txt when releaseing --- etc/make_release.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/etc/make_release.py b/etc/make_release.py index ab4c3dcab4..9c196b75a3 100755 --- a/etc/make_release.py +++ b/etc/make_release.py @@ -123,6 +123,8 @@ def release(jira_creds_file, Perform the steps associated with the release. """ + check_libmongoc_version() + # Read Jira credentials and GitHub token first, to check that # user has proper credentials before embarking on lengthy builds. jira_options = {'server': 'https://jira.mongodb.org'} @@ -220,6 +222,43 @@ def release(jira_creds_file, create_github_release_draft(gh_repo, release_tag, is_pre_release, dist_file, release_notes_text, output_file, quiet) + +def check_libmongoc_version(): + got_LIBMONGOC_REQUIRED_VERSION = None + got_LIBMONGOC_DOWNLOAD_VERSION = None + with open("CMakeLists.txt", "r") as cmakelists: + for line in cmakelists: + match = re.match( + r"set\(LIBMONGOC_REQUIRED_VERSION\s+(.*?)\)", line) + if match: + if 'TODO' in line: + click.echo( + 'Found TODO on LIBMONGOC_REQUIRED_VERSION line in CMakeLists.txt: {}'.format(line)) + sys.exit(1) + got_LIBMONGOC_REQUIRED_VERSION = match.group(1) + continue + match = re.match( + r"set\(LIBMONGOC_DOWNLOAD_VERSION\s+(.*?)\)", line) + if match: + if 'TODO' in line: + click.echo( + 'Found TODO on LIBMONGOC_DOWNLOAD_VERSION line in CMakeLists.txt: {}'.format(line)) + sys.exit(1) + got_LIBMONGOC_DOWNLOAD_VERSION = match.group(1) + continue + assert got_LIBMONGOC_DOWNLOAD_VERSION + assert got_LIBMONGOC_REQUIRED_VERSION + libmongoc_version_pattern = r'[0-9]+\.[0-9]+\.[0-9]+' + if not re.match (libmongoc_version_pattern, got_LIBMONGOC_DOWNLOAD_VERSION): + click.echo("Expected LIBMONGOC_DOWNLOAD_VERSION to match: {}, got: {}".format( + libmongoc_version_pattern, got_LIBMONGOC_DOWNLOAD_VERSION)) + sys.exit(1) + if not re.match (libmongoc_version_pattern, got_LIBMONGOC_REQUIRED_VERSION): + click.echo("Expected LIBMONGOC_REQUIRED_VERSION to match: {}, got: {}".format( + libmongoc_version_pattern, got_LIBMONGOC_REQUIRED_VERSION)) + sys.exit(1) + + # pylint: enable=too-many-arguments,too-many-locals,too-many-branches,too-many-statements def is_valid_remote(remote): """ From b81be0429b73e88e809ad9c231ed883f91225ebc Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Tue, 30 May 2023 15:15:44 -0500 Subject: [PATCH 30/61] make auto installation of C driver the default installation path --- .mci.yml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/.mci.yml b/.mci.yml index d95135527a..7a91db0cee 100644 --- a/.mci.yml +++ b/.mci.yml @@ -811,11 +811,10 @@ tasks: - name: clang-tidy commands: - func: "setup" - - func: "install_c_driver" - func: "compile" - func: "clang-tidy" - - name: compile_and_test_with_shared_libs + - name: preinstalled_c_driver commands: - func: "setup" - func: "start_mongod" @@ -827,11 +826,21 @@ tasks: - func: "run_kms_servers" - func: "test" + - name: compile_and_test_with_shared_libs + commands: + - func: "setup" + - func: "start_mongod" + - func: "compile" + vars: + RUN_DISTCHECK: 1 + - func: "clone_drivers-evergreen-tools" + - func: "run_kms_servers" + - func: "test" + - name: compile_and_test_with_shared_libs_extra_alignment commands: - func: "setup" - func: "start_mongod" - - func: "install_c_driver" vars: BSON_EXTRA_ALIGNMENT: 1 - func: "compile" @@ -843,13 +852,11 @@ tasks: commands: - func: "setup" - func: "start_mongod" - - func: "install_c_driver" - func: "compile" - name: compile_without_tests commands: - func: "setup" - - func: "install_c_driver" - func: "compile" vars: ENABLE_TESTS: OFF @@ -860,7 +867,6 @@ tasks: - func: "start_mongod" vars: AUTH: auth - - func: "install_c_driver" - func: "compile" - func: "test auth" - func: "test atlas connectivity" @@ -869,7 +875,6 @@ tasks: commands: - func: "setup" - func: "start_mongod" - - func: "install_c_driver" - func: "compile" vars: USE_STATIC_LIBS: 1 @@ -884,7 +889,6 @@ tasks: commands: - func: "setup" - func: "start_mongod" - - func: "install_c_driver" vars: BSON_EXTRA_ALIGNMENT: 1 - func: "compile" @@ -902,7 +906,6 @@ tasks: - func: "start_mongod" vars: TOPOLOGY: "replica_set" - - func: "install_c_driver" - func: "compile" vars: RUN_DISTCHECK: 1 @@ -913,7 +916,6 @@ tasks: - name: uninstall_check commands: - func: "setup" - - func: "install_c_driver" - func: "compile" - command: expansions.update params: @@ -933,7 +935,6 @@ tasks: - name: uninstall_check_windows commands: - func: "setup" - - func: "install_c_driver" - func: "compile" - command: expansions.update params: @@ -1043,7 +1044,6 @@ tasks: - name: test_mongohouse commands: - func: "setup" - - func: "install_c_driver" - func: "compile" - func: "build_mongohouse" - func: "run_mongohouse" @@ -1058,7 +1058,6 @@ tasks: # Authentication with versioned API should already be tested # in the C driver. AUTH: noauth - - func: "install_c_driver" - func: "compile" - func: "clone_drivers-evergreen-tools" - func: "run_kms_servers" @@ -1073,7 +1072,6 @@ tasks: vars: ORCHESTRATION_FILE: versioned-api-testing.json AUTH: noauth - - func: "install_c_driver" - func: "compile" - func: "clone_drivers-evergreen-tools" - func: "run_kms_servers" @@ -1209,6 +1207,7 @@ buildvariants: - name: compile_and_test_with_static_libs_extra_alignment - name: compile_and_test_with_shared_libs_replica_set - name: build_example_with_add_subdirectory + - name: preinstalled_c_driver distros: - debian11-large - name: uninstall_check @@ -1284,6 +1283,7 @@ buildvariants: - name: compile_and_test_with_static_libs - name: compile_and_test_with_static_libs_extra_alignment - name: compile_and_test_with_shared_libs_replica_set + - name: preinstalled_c_driver - name: build_example_with_add_subdirectory distros: - ubuntu2004-large From d9ff175e1e724a575b6da98eac2403c146e2e15b Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Thu, 1 Jun 2023 13:26:55 -0500 Subject: [PATCH 31/61] Update etc/releasing.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Roberto C. Sánchez --- etc/releasing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/releasing.md b/etc/releasing.md index 359ac6d925..f3479fe89a 100644 --- a/etc/releasing.md +++ b/etc/releasing.md @@ -206,7 +206,7 @@ pushed. `docs/`. This may require pushing the commit to a fork of the C++ Driver repository and creating a pull request. - Edit the `Installing the MongoDB C driver` section of - `docs/content/mongocxx-v3/installation/advanced.md` to reflect to libmongoc + `docs/content/mongocxx-v3/installation/advanced.md` to reflect libmongoc requirements. - Edit `docs/content/mongocxx-v3/installation/linux.md`, `docs/content/mongocxx-v3/installation/macos.md` and From 0e82524cf32b9782b51b7d4473dc8050838d6ab0 Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Tue, 13 Jun 2023 08:56:41 -0500 Subject: [PATCH 32/61] Document the auto download of the C driver --- docs/content/mongocxx-v3/installation/linux.md | 6 ++++++ docs/content/mongocxx-v3/installation/macos.md | 6 ++++++ docs/content/mongocxx-v3/installation/windows.md | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/docs/content/mongocxx-v3/installation/linux.md b/docs/content/mongocxx-v3/installation/linux.md index a4e8c88ff8..0c68ba2b6c 100644 --- a/docs/content/mongocxx-v3/installation/linux.md +++ b/docs/content/mongocxx-v3/installation/linux.md @@ -83,6 +83,12 @@ cmake .. \ -DCMAKE_INSTALL_PREFIX=/usr/local ``` +If CMake is unable to find an existing C driver installation, then it will +automatically download a C driver release from the internet and include it in +the build. If you wish to override this behavior with your preferred +installation, then please refer to the `Installing the MongoDB C driver` section +in the `advanced.md` document for the instructions for how to do so. + ### Step 4: Build and install the driver If you are using the default MNMLSTC polyfill and are installing to a diff --git a/docs/content/mongocxx-v3/installation/macos.md b/docs/content/mongocxx-v3/installation/macos.md index 84d41c6c27..1c31e6192d 100644 --- a/docs/content/mongocxx-v3/installation/macos.md +++ b/docs/content/mongocxx-v3/installation/macos.md @@ -83,6 +83,12 @@ cmake .. \ -DCMAKE_INSTALL_PREFIX=/usr/local ``` +If CMake is unable to find an existing C driver installation, then it will +automatically download a C driver release from the internet and include it in +the build. If you wish to override this behavior with your preferred +installation, then please refer to the `Installing the MongoDB C driver` section +in the `advanced.md` document for the instructions for how to do so. + ### Step 4: Build and install the driver If you are using the default MNMLSTC polyfill and are installing to a diff --git a/docs/content/mongocxx-v3/installation/windows.md b/docs/content/mongocxx-v3/installation/windows.md index 48fc90ce48..333d2af946 100644 --- a/docs/content/mongocxx-v3/installation/windows.md +++ b/docs/content/mongocxx-v3/installation/windows.md @@ -89,6 +89,12 @@ To build with Visual Studio 2017 without a C++17 polyfill, configure as follows: -DCMAKE_INSTALL_PREFIX=C:\mongo-cxx-driver \ ``` +If CMake is unable to find an existing C driver installation, then it will +automatically download a C driver release from the internet and include it in +the build. If you wish to override this behavior with your preferred +installation, then please refer to the `Installing the MongoDB C driver` section +in the `advanced.md` document for the instructions for how to do so. + For details on how to install libmongoc for Windows, see the [mongoc Windows installation instructions](http://mongoc.org/libmongoc/current/installing.html#building-windows). From f1c3d36ae67cb2c63eda4a36ab7f55f8763e7cfb Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Tue, 13 Jun 2023 10:32:50 -0500 Subject: [PATCH 33/61] see if this works --- .evergreen/build_example_projects.sh | 6 +++--- .mci.yml | 30 ++++++++++++++-------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/.evergreen/build_example_projects.sh b/.evergreen/build_example_projects.sh index d718fced7d..c690f833ac 100755 --- a/.evergreen/build_example_projects.sh +++ b/.evergreen/build_example_projects.sh @@ -17,18 +17,18 @@ for project in bsoncxx mongocxx; do ( cd $project - if ! ( cd cmake/$DIR && ./build.sh >|output.txt 2>&1); then + if ! ( cd cmake/$DIR && ./build.sh ); then cat output.txt 1>&2 exit 1 fi - if ! ( cd cmake-deprecated/$DIR && ./build.sh >|output.txt 2>&1); then + if ! ( cd cmake-deprecated/$DIR && ./build.sh ); then cat output.txt 1>&2 exit 1 fi if [ "Windows_NT" != "$OS" ]; then - if ! ( cd pkg-config/$DIR && ./build.sh >|output.txt 2>&1); then + if ! ( cd pkg-config/$DIR && ./build.sh ); then cat output.txt 1>&2 exit 1 fi diff --git a/.mci.yml b/.mci.yml index 7a91db0cee..7ca573fbf0 100644 --- a/.mci.yml +++ b/.mci.yml @@ -680,7 +680,7 @@ functions: # is true. if [[ -z "$MONGODB_API_VERSION" ]]; then echo "Building example projects..." - .evergreen/build_example_projects.sh + .evergreen/build_example_projects>|output.txt.sh echo "Building example projects... done." fi unset MONGODB_API_VERSION @@ -811,25 +811,15 @@ tasks: - name: clang-tidy commands: - func: "setup" - - func: "compile" - - func: "clang-tidy" - - - name: preinstalled_c_driver - commands: - - func: "setup" - - func: "start_mongod" - func: "install_c_driver" - func: "compile" - vars: - RUN_DISTCHECK: 1 - - func: "clone_drivers-evergreen-tools" - - func: "run_kms_servers" - - func: "test" + - func: "clang-tidy" - name: compile_and_test_with_shared_libs commands: - func: "setup" - func: "start_mongod" + - func: "install_c_driver" - func: "compile" vars: RUN_DISTCHECK: 1 @@ -841,6 +831,7 @@ tasks: commands: - func: "setup" - func: "start_mongod" + - func: "install_c_driver" vars: BSON_EXTRA_ALIGNMENT: 1 - func: "compile" @@ -852,11 +843,13 @@ tasks: commands: - func: "setup" - func: "start_mongod" + - func: "install_c_driver" - func: "compile" - name: compile_without_tests commands: - func: "setup" + - func: "install_c_driver" - func: "compile" vars: ENABLE_TESTS: OFF @@ -867,6 +860,7 @@ tasks: - func: "start_mongod" vars: AUTH: auth + - func: "install_c_driver" - func: "compile" - func: "test auth" - func: "test atlas connectivity" @@ -875,6 +869,7 @@ tasks: commands: - func: "setup" - func: "start_mongod" + - func: "install_c_driver" - func: "compile" vars: USE_STATIC_LIBS: 1 @@ -889,6 +884,7 @@ tasks: commands: - func: "setup" - func: "start_mongod" + - func: "install_c_driver" vars: BSON_EXTRA_ALIGNMENT: 1 - func: "compile" @@ -906,6 +902,7 @@ tasks: - func: "start_mongod" vars: TOPOLOGY: "replica_set" + - func: "install_c_driver" - func: "compile" vars: RUN_DISTCHECK: 1 @@ -916,6 +913,7 @@ tasks: - name: uninstall_check commands: - func: "setup" + - func: "install_c_driver" - func: "compile" - command: expansions.update params: @@ -935,6 +933,7 @@ tasks: - name: uninstall_check_windows commands: - func: "setup" + - func: "install_c_driver" - func: "compile" - command: expansions.update params: @@ -1044,6 +1043,7 @@ tasks: - name: test_mongohouse commands: - func: "setup" + - func: "install_c_driver" - func: "compile" - func: "build_mongohouse" - func: "run_mongohouse" @@ -1058,6 +1058,7 @@ tasks: # Authentication with versioned API should already be tested # in the C driver. AUTH: noauth + - func: "install_c_driver" - func: "compile" - func: "clone_drivers-evergreen-tools" - func: "run_kms_servers" @@ -1072,6 +1073,7 @@ tasks: vars: ORCHESTRATION_FILE: versioned-api-testing.json AUTH: noauth + - func: "install_c_driver" - func: "compile" - func: "clone_drivers-evergreen-tools" - func: "run_kms_servers" @@ -1207,7 +1209,6 @@ buildvariants: - name: compile_and_test_with_static_libs_extra_alignment - name: compile_and_test_with_shared_libs_replica_set - name: build_example_with_add_subdirectory - - name: preinstalled_c_driver distros: - debian11-large - name: uninstall_check @@ -1283,7 +1284,6 @@ buildvariants: - name: compile_and_test_with_static_libs - name: compile_and_test_with_static_libs_extra_alignment - name: compile_and_test_with_shared_libs_replica_set - - name: preinstalled_c_driver - name: build_example_with_add_subdirectory distros: - ubuntu2004-large From 91afe7cfddc8bc698ef46f1774dbe343afc9f845 Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Tue, 13 Jun 2023 10:33:17 -0500 Subject: [PATCH 34/61] Revert "see if this works" This reverts commit f1c3d36ae67cb2c63eda4a36ab7f55f8763e7cfb. --- .evergreen/build_example_projects.sh | 6 +++--- .mci.yml | 30 ++++++++++++++-------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/.evergreen/build_example_projects.sh b/.evergreen/build_example_projects.sh index c690f833ac..d718fced7d 100755 --- a/.evergreen/build_example_projects.sh +++ b/.evergreen/build_example_projects.sh @@ -17,18 +17,18 @@ for project in bsoncxx mongocxx; do ( cd $project - if ! ( cd cmake/$DIR && ./build.sh ); then + if ! ( cd cmake/$DIR && ./build.sh >|output.txt 2>&1); then cat output.txt 1>&2 exit 1 fi - if ! ( cd cmake-deprecated/$DIR && ./build.sh ); then + if ! ( cd cmake-deprecated/$DIR && ./build.sh >|output.txt 2>&1); then cat output.txt 1>&2 exit 1 fi if [ "Windows_NT" != "$OS" ]; then - if ! ( cd pkg-config/$DIR && ./build.sh ); then + if ! ( cd pkg-config/$DIR && ./build.sh >|output.txt 2>&1); then cat output.txt 1>&2 exit 1 fi diff --git a/.mci.yml b/.mci.yml index 7ca573fbf0..7a91db0cee 100644 --- a/.mci.yml +++ b/.mci.yml @@ -680,7 +680,7 @@ functions: # is true. if [[ -z "$MONGODB_API_VERSION" ]]; then echo "Building example projects..." - .evergreen/build_example_projects>|output.txt.sh + .evergreen/build_example_projects.sh echo "Building example projects... done." fi unset MONGODB_API_VERSION @@ -811,11 +811,10 @@ tasks: - name: clang-tidy commands: - func: "setup" - - func: "install_c_driver" - func: "compile" - func: "clang-tidy" - - name: compile_and_test_with_shared_libs + - name: preinstalled_c_driver commands: - func: "setup" - func: "start_mongod" @@ -827,11 +826,21 @@ tasks: - func: "run_kms_servers" - func: "test" + - name: compile_and_test_with_shared_libs + commands: + - func: "setup" + - func: "start_mongod" + - func: "compile" + vars: + RUN_DISTCHECK: 1 + - func: "clone_drivers-evergreen-tools" + - func: "run_kms_servers" + - func: "test" + - name: compile_and_test_with_shared_libs_extra_alignment commands: - func: "setup" - func: "start_mongod" - - func: "install_c_driver" vars: BSON_EXTRA_ALIGNMENT: 1 - func: "compile" @@ -843,13 +852,11 @@ tasks: commands: - func: "setup" - func: "start_mongod" - - func: "install_c_driver" - func: "compile" - name: compile_without_tests commands: - func: "setup" - - func: "install_c_driver" - func: "compile" vars: ENABLE_TESTS: OFF @@ -860,7 +867,6 @@ tasks: - func: "start_mongod" vars: AUTH: auth - - func: "install_c_driver" - func: "compile" - func: "test auth" - func: "test atlas connectivity" @@ -869,7 +875,6 @@ tasks: commands: - func: "setup" - func: "start_mongod" - - func: "install_c_driver" - func: "compile" vars: USE_STATIC_LIBS: 1 @@ -884,7 +889,6 @@ tasks: commands: - func: "setup" - func: "start_mongod" - - func: "install_c_driver" vars: BSON_EXTRA_ALIGNMENT: 1 - func: "compile" @@ -902,7 +906,6 @@ tasks: - func: "start_mongod" vars: TOPOLOGY: "replica_set" - - func: "install_c_driver" - func: "compile" vars: RUN_DISTCHECK: 1 @@ -913,7 +916,6 @@ tasks: - name: uninstall_check commands: - func: "setup" - - func: "install_c_driver" - func: "compile" - command: expansions.update params: @@ -933,7 +935,6 @@ tasks: - name: uninstall_check_windows commands: - func: "setup" - - func: "install_c_driver" - func: "compile" - command: expansions.update params: @@ -1043,7 +1044,6 @@ tasks: - name: test_mongohouse commands: - func: "setup" - - func: "install_c_driver" - func: "compile" - func: "build_mongohouse" - func: "run_mongohouse" @@ -1058,7 +1058,6 @@ tasks: # Authentication with versioned API should already be tested # in the C driver. AUTH: noauth - - func: "install_c_driver" - func: "compile" - func: "clone_drivers-evergreen-tools" - func: "run_kms_servers" @@ -1073,7 +1072,6 @@ tasks: vars: ORCHESTRATION_FILE: versioned-api-testing.json AUTH: noauth - - func: "install_c_driver" - func: "compile" - func: "clone_drivers-evergreen-tools" - func: "run_kms_servers" @@ -1209,6 +1207,7 @@ buildvariants: - name: compile_and_test_with_static_libs_extra_alignment - name: compile_and_test_with_shared_libs_replica_set - name: build_example_with_add_subdirectory + - name: preinstalled_c_driver distros: - debian11-large - name: uninstall_check @@ -1284,6 +1283,7 @@ buildvariants: - name: compile_and_test_with_static_libs - name: compile_and_test_with_static_libs_extra_alignment - name: compile_and_test_with_shared_libs_replica_set + - name: preinstalled_c_driver - name: build_example_with_add_subdirectory distros: - ubuntu2004-large From 91f7c7c2273f2485033c2b31cbd9287132c00758 Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Mon, 24 Jul 2023 13:29:51 -0500 Subject: [PATCH 35/61] make autodownloading the C driver the default for CI --- .mci.yml | 98 ++++++++++++++----- CMakeLists.txt | 38 +++++-- .../projects/bsoncxx/cmake/static/build.sh | 2 +- 3 files changed, 104 insertions(+), 34 deletions(-) diff --git a/.mci.yml b/.mci.yml index 2dd826d09b..a1abcbb9a5 100644 --- a/.mci.yml +++ b/.mci.yml @@ -283,6 +283,16 @@ functions: add_expansions_to_env: true script: mongo-cxx-driver/.evergreen/install_c_driver.sh + "fetch_latest_cmake": + - command: shell.exec + params: + shell: bash + working_dir: "." + script: | + set -o errexit + set -o pipefail + git clone --depth 1 https://github.com/mongodb/mongo-c-driver mongoc + "lint": - command: shell.exec params: @@ -832,54 +842,48 @@ tasks: - name: clang-tidy commands: - func: "setup" + - func: "fetch_latest_cmake" - func: "compile" - func: "clang-tidy" - - name: preinstalled_c_driver - commands: - - func: "setup" - - func: "start_mongod" - - func: "install_c_driver" - - func: "compile" - vars: - RUN_DISTCHECK: 1 - - func: "clone_drivers-evergreen-tools" - - func: "run_kms_servers" - - func: "test" - - name: compile_and_test_with_shared_libs commands: - func: "setup" - func: "start_mongod" + - func: "fetch_latest_cmake" - func: "compile" vars: RUN_DISTCHECK: 1 - func: "clone_drivers-evergreen-tools" - func: "run_kms_servers" + - func: "install_c_driver" - func: "test" - name: compile_and_test_with_shared_libs_extra_alignment commands: - func: "setup" - func: "start_mongod" + - func: "fetch_latest_cmake" vars: BSON_EXTRA_ALIGNMENT: 1 - func: "compile" - func: "clone_drivers-evergreen-tools" - func: "run_kms_servers" + - func: "install_c_driver" - func: "test" - name: compile_and_test_with_shared_libs_cxx20 commands: - func: "setup" - func: "start_mongod" - - func: "install_c_driver" + - func: "fetch_latest_cmake" - func: "compile" vars: RUN_DISTCHECK: 1 REQUIRED_CXX_STANDARD: 20 - func: "clone_drivers-evergreen-tools" - func: "run_kms_servers" + - func: "install_c_driver" - func: "test" vars: REQUIRED_CXX_STANDARD: 20 @@ -889,7 +893,7 @@ tasks: commands: - func: "setup" - func: "start_mongod" - - func: "install_c_driver" + - func: "fetch_latest_cmake" vars: BSON_EXTRA_ALIGNMENT: 1 - func: "compile" @@ -897,6 +901,7 @@ tasks: REQUIRED_CXX_STANDARD: 20 - func: "clone_drivers-evergreen-tools" - func: "run_kms_servers" + - func: "install_c_driver" - func: "test" vars: REQUIRED_CXX_STANDARD: 20 @@ -906,11 +911,13 @@ tasks: commands: - func: "setup" - func: "start_mongod" + - func: "fetch_latest_cmake" - func: "compile" - name: compile_without_tests commands: - func: "setup" + - func: "fetch_latest_cmake" - func: "compile" vars: ENABLE_TESTS: OFF @@ -921,6 +928,7 @@ tasks: - func: "start_mongod" vars: AUTH: auth + - func: "fetch_latest_cmake" - func: "compile" - func: "test auth" - func: "test atlas connectivity" @@ -929,12 +937,14 @@ tasks: commands: - func: "setup" - func: "start_mongod" + - func: "fetch_latest_cmake" - func: "compile" vars: USE_STATIC_LIBS: 1 RUN_DISTCHECK: 1 - func: "clone_drivers-evergreen-tools" - func: "run_kms_servers" + - func: "install_c_driver" - func: "test" vars: USE_STATIC_LIBS: 1 @@ -943,6 +953,7 @@ tasks: commands: - func: "setup" - func: "start_mongod" + - func: "fetch_latest_cmake" vars: BSON_EXTRA_ALIGNMENT: 1 - func: "compile" @@ -950,6 +961,7 @@ tasks: USE_STATIC_LIBS: 1 - func: "clone_drivers-evergreen-tools" - func: "run_kms_servers" + - func: "install_c_driver" - func: "test" vars: USE_STATIC_LIBS: 1 @@ -960,6 +972,26 @@ tasks: - func: "start_mongod" vars: TOPOLOGY: "replica_set" + - func: "fetch_latest_cmake" + - func: "compile" + vars: + RUN_DISTCHECK: 1 + - func: "clone_drivers-evergreen-tools" + - func: "run_kms_servers" + - func: "install_c_driver" + - func: "test" + + # Auto downloading the C driver in the C++ build does not currently include + # support for libmongocrypt, therefore it is not configured with + # -DENABLE_CLIENT_SIDE_ENCRYPTION=ON. For now, CSFLE tests will need to have + # a manually configured C driver, hence the need to seperate this task. + - name: compile_and_test_with_shared_libs_replica_set_with_libmongocrypt + commands: + - func: "setup" + - func: "start_mongod" + vars: + TOPOLOGY: "replica_set" + - func: "install_c_driver" - func: "compile" vars: RUN_DISTCHECK: 1 @@ -970,6 +1002,7 @@ tasks: - name: uninstall_check commands: - func: "setup" + - func: "fetch_latest_cmake" - func: "compile" - command: expansions.update params: @@ -989,6 +1022,7 @@ tasks: - name: uninstall_check_windows commands: - func: "setup" + - func: "fetch_latest_cmake" - func: "compile" - command: expansions.update params: @@ -1023,8 +1057,8 @@ tasks: . ./mongo-c-driver/.evergreen/scripts/find-cmake-latest.sh export CMAKE="$(find_cmake_latest)" cd build - $CMAKE .. - $CMAKE --build . -- -j 8 + $CMAKE .. -DENABLE_UNINSTALL=OFF + $CMAKE --build . -- -j $(nproc) ./hello_mongocxx - name: debian-package-build @@ -1099,6 +1133,7 @@ tasks: - name: test_mongohouse commands: - func: "setup" + - func: "fetch_latest_cmake" - func: "compile" - func: "build_mongohouse" - func: "run_mongohouse" @@ -1113,6 +1148,7 @@ tasks: # Authentication with versioned API should already be tested # in the C driver. AUTH: noauth + - func: "fetch_latest_cmake" - func: "compile" - func: "clone_drivers-evergreen-tools" - func: "run_kms_servers" @@ -1127,6 +1163,7 @@ tasks: vars: ORCHESTRATION_FILE: versioned-api-testing.json AUTH: noauth + - func: "fetch_latest_cmake" - func: "compile" - func: "clone_drivers-evergreen-tools" - func: "run_kms_servers" @@ -1218,7 +1255,7 @@ buildvariants: matrix_spec: {os: "ubuntu-1804", mongodb_version: "*"} display_name: "${os} replica set (MongoDB ${mongodb_version})" tasks: - - name: compile_and_test_with_shared_libs_replica_set + - name: compile_and_test_with_shared_libs_replica_set_with_libmongocrypt - matrix_name: "auth" matrix_spec: {os: "*", mongodb_version: "latest"} @@ -1263,7 +1300,7 @@ buildvariants: - name: compile_and_test_with_shared_libs_extra_alignment_cxx20 - name: compile_and_test_with_static_libs - name: compile_and_test_with_static_libs_extra_alignment - - name: compile_and_test_with_shared_libs_replica_set + - name: compile_and_test_with_shared_libs_replica_set_with_libmongocrypt - name: build_example_with_add_subdirectory distros: - rhel90-large @@ -1286,7 +1323,7 @@ buildvariants: - name: compile_and_test_with_shared_libs_extra_alignment_cxx20 - name: compile_and_test_with_static_libs - name: compile_and_test_with_static_libs_extra_alignment - - name: compile_and_test_with_shared_libs_replica_set + - name: compile_and_test_with_shared_libs_replica_set_with_libmongocrypt - name: build_example_with_add_subdirectory distros: - rhel90-arm64-large @@ -1308,7 +1345,7 @@ buildvariants: - name: compile_and_test_with_shared_libs_extra_alignment_cxx20 - name: compile_and_test_with_static_libs - name: compile_and_test_with_static_libs_extra_alignment - - name: compile_and_test_with_shared_libs_replica_set + - name: compile_and_test_with_shared_libs_replica_set_with_libmongocrypt - name: build_example_with_add_subdirectory distros: - debian11-large @@ -1333,7 +1370,6 @@ buildvariants: - name: compile_and_test_with_static_libs_extra_alignment - name: compile_and_test_with_shared_libs_replica_set - name: build_example_with_add_subdirectory - - name: preinstalled_c_driver distros: - debian11-large - name: uninstall_check @@ -1353,7 +1389,7 @@ buildvariants: - name: compile_and_test_with_shared_libs_extra_alignment - name: compile_and_test_with_static_libs - name: compile_and_test_with_static_libs_extra_alignment - - name: compile_and_test_with_shared_libs_replica_set + - name: compile_and_test_with_shared_libs_replica_set_with_libmongocrypt - name: build_example_with_add_subdirectory distros: - debian10-large @@ -1380,6 +1416,19 @@ buildvariants: - debian10-large - name: uninstall_check + # Add matrix for specification test requirement of mongocryptd: + # "Drivers MUST run all tests with mongocryptd on at least one platform for all tested server versions (4.2+)." + - matrix_name: "mongocryptd" + matrix_spec: + os: "ubuntu-1804" + mongodb_version: ["4.2", "4.4", "5.0", "latest"] + display_name: "${os} (MongoDB ${mongodb_version}) with mongocryptd" + tasks: + - name: compile_and_test_with_shared_libs + - name: compile_and_test_with_shared_libs_replica_set_with_libmongocrypt + expansions: + use_mongocryptd: true + - name: ubuntu2004-release-latest display_name: "Ubuntu 20.04 Release (MongoDB Latest)" expansions: @@ -1395,8 +1444,7 @@ buildvariants: - name: compile_and_test_with_shared_libs_extra_alignment - name: compile_and_test_with_static_libs - name: compile_and_test_with_static_libs_extra_alignment - - name: compile_and_test_with_shared_libs_replica_set - - name: preinstalled_c_driver + - name: compile_and_test_with_shared_libs_replica_set_with_libmongocrypt - name: build_example_with_add_subdirectory distros: - ubuntu2004-large @@ -1439,7 +1487,7 @@ buildvariants: - name: compile_and_test_with_shared_libs_extra_alignment - name: compile_and_test_with_static_libs - name: compile_and_test_with_static_libs_extra_alignment - - name: compile_and_test_with_shared_libs_replica_set + - name: compile_and_test_with_shared_libs_replica_set_with_libmongocrypt - name: build_example_with_add_subdirectory distros: - ubuntu1804-build diff --git a/CMakeLists.txt b/CMakeLists.txt index a84b0643d7..aba78edcc4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,8 +40,8 @@ else() message(WARNING "Unknown compiler... recklessly proceeding without a version check") endif() -set(LIBMONGOC_REQUIRED_VERSION 1.22.1) # TODO (CXX-2696): update to 1.24.0 once released. -set(LIBMONGOC_DOWNLOAD_VERSION b9ca36ff8c64f12330326f080c725c5502294834) # TODO (CXX-2696): update to 1.24.0 once released. +set(LIBMONGOC_REQUIRED_VERSION 1.24.0) # TODO (CXX-2696): update to 1.24.0 once released. +set(LIBMONGOC_DOWNLOAD_VERSION b80c88377636f385391ff2ca899654b3ce54d1c9) # TODO (CXX-2696): update to 1.24.0 once released. set(LIBMONGOC_REQUIRED_ABI_VERSION 1.0) set(NEED_DOWNLOAD_C_DRIVER false) @@ -73,19 +73,41 @@ if(NEED_DOWNLOAD_C_DRIVER) include(FetchContent) include(ExternalProject) - set(BUILD_SHARED_LIBS_WITH_STATIC_MONGOC ON CACHE INTERNAL "") - # Declare mongo-c-driver as a dependency FetchContent_Declare( mongo-c-driver - GIT_REPOSITORY https://github.com/mongodb/mongo-c-driver.git + GIT_REPOSITORY https://github.com/kkloberdanz/mongo-c-driver.git GIT_TAG ${LIBMONGOC_DOWNLOAD_VERSION} ) + if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + set(CMAKE_C_FLAGS -Wno-error) + endif() + FetchContent_GetProperties(mongo-c-driver) if(NOT mongo-c-driver_POPULATED) - FetchContent_Populate(mongo-c-driver) - add_subdirectory(${mongo-c-driver_SOURCE_DIR} ${mongo-c-driver_BINARY_DIR} EXCLUDE_FROM_ALL) + set(OLD_ENABLE_TESTS ${ENABLE_TESTS}) + set(OLD_BUILD_TESTING ${BUILD_TESTING}) + set(OLD_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) + set(OLD_CMAKE_C_FLAGS ${CMAKE_C_FLAGS}) + + set(ENABLE_EXTRA_ALIGNMENT OFF) + add_compile_definitions(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. + # Attempting to execute test-libmongoc results in an error: "Unable to find executable: NOT_FOUND" + set(ENABLE_TESTS OFF) + set(BUILD_TESTING OFF) + string(REPLACE " -Werror" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + string(REPLACE " -Werror" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") + add_subdirectory(${mongo-c-driver_SOURCE_DIR} ${mongo-c-driver_BINARY_DIR}) + set(CMAKE_CXX_FLAGS ${OLD_CMAKE_CXX_FLAGS}) + set(CMAKE_C_FLAGS ${OLD_CMAKE_C_FLAGS}) + set(ENABLE_TESTS OLD_ENABLE_TESTS) + set(BUILD_TESTING OLD_BUILD_TESTING) endif() endif() @@ -403,7 +425,7 @@ if(NOT (TARGET bson_shared OR TARGET mongoc_shared)) ) endif() -if(ENABLE_UNINSTALL AND NOT (TARGET bson_shared OR TARGET mongoc_shared)) +if(ENABLE_UNINSTALL) if(WIN32) set(UNINSTALL_PROG "uninstall.cmd") else() diff --git a/examples/projects/bsoncxx/cmake/static/build.sh b/examples/projects/bsoncxx/cmake/static/build.sh index 3ce50b5bbe..fc11a3abe4 100755 --- a/examples/projects/bsoncxx/cmake/static/build.sh +++ b/examples/projects/bsoncxx/cmake/static/build.sh @@ -9,7 +9,7 @@ CMAKE=${cmake_binary:-cmake} rm -rf build/* cd build if [ -z "$MSVC" ]; then - "$CMAKE" -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" -DCMAKE_CXX_STANDARD="${CXX_STANDARD}" .. + "$CMAKE" -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" -DCMAKE_CXX_STANDARD="${CXX_STANDARD}" -DCMAKE_INSTALL_PREFIX="../../../../../../build/install" .. "$CMAKE" --build . --target run else if [ "$CXX_STANDARD" = "17" ]; then From fd6616053599941b929085f501baabd252a36e6b Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Tue, 25 Jul 2023 08:09:29 -0500 Subject: [PATCH 36/61] remove TODOs, remove duplicate definitions --- CMakeLists.txt | 4 ++-- src/mongocxx/CMakeLists.txt | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index aba78edcc4..fdc945ae73 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,8 +40,8 @@ else() message(WARNING "Unknown compiler... recklessly proceeding without a version check") endif() -set(LIBMONGOC_REQUIRED_VERSION 1.24.0) # TODO (CXX-2696): update to 1.24.0 once released. -set(LIBMONGOC_DOWNLOAD_VERSION b80c88377636f385391ff2ca899654b3ce54d1c9) # TODO (CXX-2696): update to 1.24.0 once released. +set(LIBMONGOC_REQUIRED_VERSION 1.24.0) +set(LIBMONGOC_DOWNLOAD_VERSION b80c88377636f385391ff2ca899654b3ce54d1c9) set(LIBMONGOC_REQUIRED_ABI_VERSION 1.0) set(NEED_DOWNLOAD_C_DRIVER false) diff --git a/src/mongocxx/CMakeLists.txt b/src/mongocxx/CMakeLists.txt index 7d91b2b9f8..45f6bfc1d0 100644 --- a/src/mongocxx/CMakeLists.txt +++ b/src/mongocxx/CMakeLists.txt @@ -29,9 +29,6 @@ message ("mongocxx version: ${MONGOCXX_VERSION}") set(MONGOCXX_INLINE_NAMESPACE "v${MONGOCXX_ABI_VERSION}") set(MONGOCXX_HEADER_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}/mongocxx/${MONGOCXX_INLINE_NAMESPACE}" CACHE INTERNAL "") -set(LIBMONGOC_REQUIRED_VERSION 1.24.0) -set(LIBMONGOC_REQUIRED_ABI_VERSION 1.0) - set(mongocxx_pkg_dep "") if(TARGET mongoc_shared OR TARGET mongoc_static) From 6bbe865b8a2832e420ba8a5217c53d480bb55767 Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Tue, 25 Jul 2023 08:14:58 -0500 Subject: [PATCH 37/61] use the mongodb repo rather than mine --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fdc945ae73..f2e5c476f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,7 +41,7 @@ else() endif() set(LIBMONGOC_REQUIRED_VERSION 1.24.0) -set(LIBMONGOC_DOWNLOAD_VERSION b80c88377636f385391ff2ca899654b3ce54d1c9) +set(LIBMONGOC_DOWNLOAD_VERSION ba5ab6de26a874d33b0abc3d2b46961a69380e7a) set(LIBMONGOC_REQUIRED_ABI_VERSION 1.0) set(NEED_DOWNLOAD_C_DRIVER false) @@ -76,7 +76,7 @@ if(NEED_DOWNLOAD_C_DRIVER) # Declare mongo-c-driver as a dependency FetchContent_Declare( mongo-c-driver - GIT_REPOSITORY https://github.com/kkloberdanz/mongo-c-driver.git + GIT_REPOSITORY https://github.com/mongodb/mongo-c-driver.git GIT_TAG ${LIBMONGOC_DOWNLOAD_VERSION} ) From c6e404c4a1f2c2b7f70701dd0ea0d6a121e36b2e Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Tue, 25 Jul 2023 12:55:08 -0500 Subject: [PATCH 38/61] add distcheck unconditionally --- CMakeLists.txt | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f2e5c476f7..6c6c716af2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -409,21 +409,16 @@ add_custom_command (OUTPUT ${DIST_FILE} ${ALL_DIST} ${dist_generated_depends} ) -if(NOT (TARGET bson_shared OR TARGET mongoc_shared)) - # If these targets exist, then libbson/libmongoc have already been included - # as a project sub-directory; the 'dist' and 'distcheck' targets here would - # collide with those declared in the mongo-c-driver project - 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 - ) -endif() +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 +) if(ENABLE_UNINSTALL) if(WIN32) From 16166d3f0931717411d84802fe2d592ffb056fd6 Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Tue, 25 Jul 2023 14:23:49 -0500 Subject: [PATCH 39/61] only add distcheck target if it is not yet defined --- CMakeLists.txt | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c6c716af2..469c1987b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -409,16 +409,18 @@ add_custom_command (OUTPUT ${DIST_FILE} ${ALL_DIST} ${dist_generated_depends} ) -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 -) +if(NOT (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 + ) +endif() if(ENABLE_UNINSTALL) if(WIN32) From 2add8df9b8d50005436fede02ac9a7bfad97a357 Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Thu, 27 Jul 2023 10:11:39 -0500 Subject: [PATCH 40/61] Update etc/releasing.md Co-authored-by: Kevin Albertson --- etc/releasing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/releasing.md b/etc/releasing.md index c24e3787d2..aadb671f3a 100644 --- a/etc/releasing.md +++ b/etc/releasing.md @@ -211,7 +211,7 @@ pushed. - Edit `docs/content/mongocxx-v3/installation/linux.md`, `docs/content/mongocxx-v3/installation/macos.md` and `docs/content/mongocxx-v3/installation/windows.md`. - If the release was not a release candidate, update `Step 3` to reflect the + If the release was not a release candidate, update `Step 2` to reflect the new latest stable version to download. ## Homebrew From 982030e449c1b1e3843f4800f884561509fedf0f Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Thu, 27 Jul 2023 10:12:29 -0500 Subject: [PATCH 41/61] Update CMakeLists.txt Co-authored-by: Kevin Albertson --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 469c1987b9..ae0aacead2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,7 +41,7 @@ else() endif() set(LIBMONGOC_REQUIRED_VERSION 1.24.0) -set(LIBMONGOC_DOWNLOAD_VERSION ba5ab6de26a874d33b0abc3d2b46961a69380e7a) +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) set(NEED_DOWNLOAD_C_DRIVER false) From 24f2455c8ed273d79ff15b2623e7e9c0e0b7bcec Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Thu, 27 Jul 2023 10:13:44 -0500 Subject: [PATCH 42/61] Update CMakeLists.txt Co-authored-by: Kevin Albertson --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index ae0aacead2..8e6c86ccd2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,6 +70,7 @@ endif() if(NEED_DOWNLOAD_C_DRIVER) message(STATUS "No Mongo C Driver path provided via CMAKE_PREFIX_PATH, will download C driver version ${LIBMONGOC_DOWNLOAD_VERSION} from the internet.") + message(STATUS "Download and configure C driver version ${LIBMONGOC_DOWNLOAD_VERSION} ... begin") include(FetchContent) include(ExternalProject) From d34fcd8415dc8875f19243f05fff549e107d2b13 Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Thu, 27 Jul 2023 10:15:33 -0500 Subject: [PATCH 43/61] Update CMakeLists.txt Co-authored-by: Kevin Albertson --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8e6c86ccd2..9064b29ba9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -110,6 +110,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() # All of our target compilers support the deprecated From bf68afa3c0a4a5b0a87374e8b92c2fe34d2e12c1 Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Thu, 27 Jul 2023 10:20:09 -0500 Subject: [PATCH 44/61] Update CMakeLists.txt Co-authored-by: Kevin Albertson --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9064b29ba9..39a6ec3116 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -411,7 +411,7 @@ add_custom_command (OUTPUT ${DIST_FILE} ${ALL_DIST} ${dist_generated_depends} ) -if(NOT (TARGET distcheck)) +if(NOT (TARGET dist OR TARGET distcheck)) add_custom_target (dist DEPENDS ${DIST_FILE}) add_custom_target (distcheck DEPENDS dist From ba550a916fbf73b992f6e895cf83c0db68d75664 Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Thu, 27 Jul 2023 10:21:30 -0500 Subject: [PATCH 45/61] Update docs/content/mongocxx-v3/installation/advanced.md Co-authored-by: Kevin Albertson --- docs/content/mongocxx-v3/installation/advanced.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/mongocxx-v3/installation/advanced.md b/docs/content/mongocxx-v3/installation/advanced.md index 666369b588..23f08a61c0 100644 --- a/docs/content/mongocxx-v3/installation/advanced.md +++ b/docs/content/mongocxx-v3/installation/advanced.md @@ -21,7 +21,7 @@ The above command would produce libraries named `libcustom_bsoncxx.so` and `libc ## Installing the MongoDB C driver. -The mongocxx driver builds on top of the MongoDB C driver. +The mongocxx driver builds on top of the [MongoDB C driver](https://www.mongodb.com/docs/drivers/c/). The build of mongocxx-3.8.0 automatically installs the C driver if the C driver is not detected. To use an existing install of the C driver, set `CMAKE_PREFIX_PATH` to the directory containing the C driver install. From 8914c8a6a5c794a055ee04afc2c462a2bda7199d Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Thu, 27 Jul 2023 10:22:06 -0500 Subject: [PATCH 46/61] Update docs/content/mongocxx-v3/installation/linux.md Co-authored-by: Kevin Albertson --- docs/content/mongocxx-v3/installation/linux.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/mongocxx-v3/installation/linux.md b/docs/content/mongocxx-v3/installation/linux.md index 2b2dd67eea..13442d4b57 100644 --- a/docs/content/mongocxx-v3/installation/linux.md +++ b/docs/content/mongocxx-v3/installation/linux.md @@ -63,7 +63,7 @@ obtain. ### Step 3: Configure the driver -On Unix systems, `libmongoc` installs into `/usr/local` by default. Without additional +Without additional configuration, `mongocxx` installs into its local build directory as a courtesy to those who build from source. To configure `mongocxx` for installation into `/usr/local` as well, use the following `cmake` command: From e290b37e6dcbd60f2e2df5a7f37d9e4d2a02c53b Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Thu, 27 Jul 2023 10:22:41 -0500 Subject: [PATCH 47/61] Update docs/content/mongocxx-v3/installation/macos.md Co-authored-by: Kevin Albertson --- docs/content/mongocxx-v3/installation/macos.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/mongocxx-v3/installation/macos.md b/docs/content/mongocxx-v3/installation/macos.md index 56db965902..52fd1bc9db 100644 --- a/docs/content/mongocxx-v3/installation/macos.md +++ b/docs/content/mongocxx-v3/installation/macos.md @@ -63,7 +63,7 @@ obtain. ### Step 3: Configure the driver -On Unix systems, `libmongoc` installs into `/usr/local` by default. Without additional +Without additional configuration, `mongocxx` installs into its local build directory as a courtesy to those who build from source. To configure `mongocxx` for installation into `/usr/local` as well, use the following `cmake` command: From bc9d572d1dc0757138abeff073a68d3bcfafee67 Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Thu, 27 Jul 2023 10:23:13 -0500 Subject: [PATCH 48/61] Update docs/content/mongocxx-v3/installation/advanced.md Co-authored-by: Kevin Albertson --- docs/content/mongocxx-v3/installation/advanced.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/mongocxx-v3/installation/advanced.md b/docs/content/mongocxx-v3/installation/advanced.md index 23f08a61c0..ef3f095c83 100644 --- a/docs/content/mongocxx-v3/installation/advanced.md +++ b/docs/content/mongocxx-v3/installation/advanced.md @@ -23,7 +23,7 @@ The above command would produce libraries named `libcustom_bsoncxx.so` and `libc The mongocxx driver builds on top of the [MongoDB C driver](https://www.mongodb.com/docs/drivers/c/). -The build of mongocxx-3.8.0 automatically installs the C driver if the C driver is not detected. +The build of mongocxx-3.8.0 automatically downloads and installs the C driver if the C driver is not detected. To use an existing install of the C driver, set `CMAKE_PREFIX_PATH` to the directory containing the C driver install. * For mongocxx-3.8.x, libmongoc 1.24.0 or later is required. From b9772531f1ea2a1ed835993fc1a3d7c7efba0e96 Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Thu, 27 Jul 2023 10:27:16 -0500 Subject: [PATCH 49/61] remove paragraphs describing C deriver auto install as requested --- docs/content/mongocxx-v3/installation/linux.md | 6 ------ docs/content/mongocxx-v3/installation/macos.md | 6 ------ docs/content/mongocxx-v3/installation/windows.md | 6 ------ 3 files changed, 18 deletions(-) diff --git a/docs/content/mongocxx-v3/installation/linux.md b/docs/content/mongocxx-v3/installation/linux.md index 13442d4b57..ecc8acbb3a 100644 --- a/docs/content/mongocxx-v3/installation/linux.md +++ b/docs/content/mongocxx-v3/installation/linux.md @@ -83,12 +83,6 @@ cmake .. \ -DCMAKE_INSTALL_PREFIX=/usr/local ``` -If CMake is unable to find an existing C driver installation, then it will -automatically download a C driver release from the internet and include it in -the build. If you wish to override this behavior with your preferred -installation, then please refer to the `Installing the MongoDB C driver` section -in the `advanced.md` document for the instructions for how to do so. - ### Step 4: Build and install the driver If you are using the default MNMLSTC polyfill and are installing to a diff --git a/docs/content/mongocxx-v3/installation/macos.md b/docs/content/mongocxx-v3/installation/macos.md index 52fd1bc9db..54514fe58a 100644 --- a/docs/content/mongocxx-v3/installation/macos.md +++ b/docs/content/mongocxx-v3/installation/macos.md @@ -83,12 +83,6 @@ cmake .. \ -DCMAKE_INSTALL_PREFIX=/usr/local ``` -If CMake is unable to find an existing C driver installation, then it will -automatically download a C driver release from the internet and include it in -the build. If you wish to override this behavior with your preferred -installation, then please refer to the `Installing the MongoDB C driver` section -in the `advanced.md` document for the instructions for how to do so. - ### Step 4: Build and install the driver If you are using the default MNMLSTC polyfill and are installing to a diff --git a/docs/content/mongocxx-v3/installation/windows.md b/docs/content/mongocxx-v3/installation/windows.md index 09a59d5132..829dad8519 100644 --- a/docs/content/mongocxx-v3/installation/windows.md +++ b/docs/content/mongocxx-v3/installation/windows.md @@ -89,12 +89,6 @@ To build with Visual Studio 2017 without a C++17 polyfill, configure as follows: -DCMAKE_INSTALL_PREFIX=C:\mongo-cxx-driver \ ``` -If CMake is unable to find an existing C driver installation, then it will -automatically download a C driver release from the internet and include it in -the build. If you wish to override this behavior with your preferred -installation, then please refer to the `Installing the MongoDB C driver` section -in the `advanced.md` document for the instructions for how to do so. - For details on how to install libmongoc for Windows, see the [mongoc Windows installation instructions](http://mongoc.org/libmongoc/current/installing.html#building-windows). From 2f5a2aada1c3679ec371bbdd24a84413b0cf0e1e Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Thu, 27 Jul 2023 10:31:22 -0500 Subject: [PATCH 50/61] as suggested, remove mentions of mongo C driver --- docs/content/mongocxx-v3/installation/windows.md | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/docs/content/mongocxx-v3/installation/windows.md b/docs/content/mongocxx-v3/installation/windows.md index 829dad8519..765d3f32d3 100644 --- a/docs/content/mongocxx-v3/installation/windows.md +++ b/docs/content/mongocxx-v3/installation/windows.md @@ -69,14 +69,12 @@ On Windows, the C++ driver is configured as follows (adjusting the path of the C 'C:\Program Files (x86)\CMake\bin\cmake.exe' .. \ -G "Visual Studio 14 2015 Win64" \ -DBOOST_ROOT=C:\local\boost_1_60_0 \ - -DCMAKE_PREFIX_PATH=C:\mongo-c-driver \ -DCMAKE_INSTALL_PREFIX=C:\mongo-cxx-driver ``` The example above assumes: * Boost is found in `C:\local\boost_1_60_0`. -* `libmongoc` is found in `C:\mongo-c-driver`. * `mongocxx` is to be installed into `C:\mongo-cxx-driver`. To build with Visual Studio 2017 without a C++17 polyfill, configure as follows: @@ -85,13 +83,9 @@ To build with Visual Studio 2017 without a C++17 polyfill, configure as follows: 'C:\Program Files (x86)\CMake\bin\cmake.exe' .. \ -G "Visual Studio 15 2017 Win64" \ -DCMAKE_CXX_STANDARD=17 \ - -DCMAKE_PREFIX_PATH=C:\mongo-c-driver \ -DCMAKE_INSTALL_PREFIX=C:\mongo-cxx-driver \ ``` -For details on how to install libmongoc for Windows, see the -[mongoc Windows installation instructions](http://mongoc.org/libmongoc/current/installing.html#building-windows). - #### Configuring with `mongocxx` 3.7.0 and older To build versions 3.7.0 and older without a C++17 polyfill, it is necessary to configure with additional options: @@ -103,20 +97,15 @@ To build versions 3.7.0 and older without a C++17 polyfill, it is necessary to c -G "Visual Studio 15 2017 Win64" \ -DCMAKE_CXX_STANDARD=17 \ -DCMAKE_CXX_FLAGS="/Zc:__cplusplus /EHsc" \ - -DCMAKE_PREFIX_PATH=C:\mongo-c-driver \ -DCMAKE_INSTALL_PREFIX=C:\mongo-cxx-driver \ ``` #### Configuring with `mongocxx` 3.1.x or 3.0.x -Instead of the `-DCMAKE_PREFIX_PATH` option, users must specify the `libmongoc` installation -directory by using the `-DLIBMONGOC_DIR` and `-DLIBBSON_DIR` options: - ```sh cmake .. \ -DCMAKE_BUILD_TYPE=Release \ -DLIBMONGOC_DIR=C:\mongo-c-driver \ - -DLIBBSON_DIR=C:\mongo-c-driver \ -DCMAKE_INSTALL_PREFIX=C:\mongo-cxx-driver ``` From 0484da00ea76044dd8e467496296de0c4ced34d8 Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Thu, 27 Jul 2023 10:59:38 -0500 Subject: [PATCH 51/61] Update .mci.yml Co-authored-by: Kevin Albertson --- .mci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.mci.yml b/.mci.yml index a1abcbb9a5..269351ca30 100644 --- a/.mci.yml +++ b/.mci.yml @@ -1424,7 +1424,6 @@ buildvariants: mongodb_version: ["4.2", "4.4", "5.0", "latest"] display_name: "${os} (MongoDB ${mongodb_version}) with mongocryptd" tasks: - - name: compile_and_test_with_shared_libs - name: compile_and_test_with_shared_libs_replica_set_with_libmongocrypt expansions: use_mongocryptd: true From 7b55221214097e8a7ff1279575cd38b09cf64dac Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Thu, 27 Jul 2023 13:13:59 -0500 Subject: [PATCH 52/61] Update docs/content/mongocxx-v3/installation/advanced.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Roberto C. Sánchez --- docs/content/mongocxx-v3/installation/advanced.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/mongocxx-v3/installation/advanced.md b/docs/content/mongocxx-v3/installation/advanced.md index ef3f095c83..ad4b73d985 100644 --- a/docs/content/mongocxx-v3/installation/advanced.md +++ b/docs/content/mongocxx-v3/installation/advanced.md @@ -37,7 +37,7 @@ To use an existing install of the C driver, set `CMAKE_PREFIX_PATH` to the direc * For mongocxx-3.1.[0-3], libmongoc 1.5.0 or later is required. * For mongocxx-3.0.x, we recommend the last 1.4.x version of libmongoc -Unless you know that your package manager offers a high enough version, you +Unless you know that your package manager offers a sufficiently recent version, you will need to download and build from the source code. Get a tarball from the [C Driver releases](https://github.com/mongodb/mongo-c-driver/releases) page. From 4df03a8cf817475216706ba47fb1ae651ca49704 Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Thu, 27 Jul 2023 13:25:39 -0500 Subject: [PATCH 53/61] Update CMakeLists.txt Co-authored-by: Kevin Albertson --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 39a6ec3116..fb86ff22dc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -93,7 +93,6 @@ if(NEED_DOWNLOAD_C_DRIVER) set(OLD_CMAKE_C_FLAGS ${CMAKE_C_FLAGS}) set(ENABLE_EXTRA_ALIGNMENT OFF) - add_compile_definitions(ENABLE_EXTRA_ALIGNMENT=OFF) FetchContent_Populate(mongo-c-driver) # Set ENABLE_TESTS to OFF to disable the test-libmongoc target in the C driver. From 95c05dcac10a08ac22d6ad41f0f42d72ab7acd7a Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Mon, 31 Jul 2023 08:15:37 -0500 Subject: [PATCH 54/61] 'ENABLE_UNINSTALL=OFF' no longer appears to be necessary --- .mci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.mci.yml b/.mci.yml index 269351ca30..fa293af3a9 100644 --- a/.mci.yml +++ b/.mci.yml @@ -1057,7 +1057,7 @@ tasks: . ./mongo-c-driver/.evergreen/scripts/find-cmake-latest.sh export CMAKE="$(find_cmake_latest)" cd build - $CMAKE .. -DENABLE_UNINSTALL=OFF + $CMAKE .. $CMAKE --build . -- -j $(nproc) ./hello_mongocxx From 403665d4d63f0b03095bfaf6979281245a7256df Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Mon, 31 Jul 2023 08:20:49 -0500 Subject: [PATCH 55/61] install prefix no longer appears necessary --- examples/projects/bsoncxx/cmake/static/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/projects/bsoncxx/cmake/static/build.sh b/examples/projects/bsoncxx/cmake/static/build.sh index fc11a3abe4..3ce50b5bbe 100755 --- a/examples/projects/bsoncxx/cmake/static/build.sh +++ b/examples/projects/bsoncxx/cmake/static/build.sh @@ -9,7 +9,7 @@ CMAKE=${cmake_binary:-cmake} rm -rf build/* cd build if [ -z "$MSVC" ]; then - "$CMAKE" -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" -DCMAKE_CXX_STANDARD="${CXX_STANDARD}" -DCMAKE_INSTALL_PREFIX="../../../../../../build/install" .. + "$CMAKE" -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" -DCMAKE_CXX_STANDARD="${CXX_STANDARD}" .. "$CMAKE" --build . --target run else if [ "$CXX_STANDARD" = "17" ]; then From bd3b78a2e6879301c32391f74837bbf939c19bbf Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Mon, 31 Jul 2023 09:35:52 -0500 Subject: [PATCH 56/61] remove -Wno-error --- CMakeLists.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fb86ff22dc..0fbf2c4883 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -81,10 +81,6 @@ if(NEED_DOWNLOAD_C_DRIVER) GIT_TAG ${LIBMONGOC_DOWNLOAD_VERSION} ) - if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - set(CMAKE_C_FLAGS -Wno-error) - endif() - FetchContent_GetProperties(mongo-c-driver) if(NOT mongo-c-driver_POPULATED) set(OLD_ENABLE_TESTS ${ENABLE_TESTS}) From c831ec5a154e522b60b16bf32c31e1aa4e022dd0 Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Mon, 31 Jul 2023 15:27:56 -0500 Subject: [PATCH 57/61] rename fetch_latest_cmake to fetch_c_driver_source --- .mci.yml | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/.mci.yml b/.mci.yml index fa293af3a9..3aee87a4fd 100644 --- a/.mci.yml +++ b/.mci.yml @@ -283,7 +283,8 @@ functions: add_expansions_to_env: true script: mongo-cxx-driver/.evergreen/install_c_driver.sh - "fetch_latest_cmake": + # This function may be used to fetch CI scripts in the C driver + "fetch_c_driver_source": - command: shell.exec params: shell: bash @@ -842,7 +843,7 @@ tasks: - name: clang-tidy commands: - func: "setup" - - func: "fetch_latest_cmake" + - func: "fetch_c_driver_source" - func: "compile" - func: "clang-tidy" @@ -850,7 +851,7 @@ tasks: commands: - func: "setup" - func: "start_mongod" - - func: "fetch_latest_cmake" + - func: "fetch_c_driver_source" - func: "compile" vars: RUN_DISTCHECK: 1 @@ -863,7 +864,7 @@ tasks: commands: - func: "setup" - func: "start_mongod" - - func: "fetch_latest_cmake" + - func: "fetch_c_driver_source" vars: BSON_EXTRA_ALIGNMENT: 1 - func: "compile" @@ -876,7 +877,7 @@ tasks: commands: - func: "setup" - func: "start_mongod" - - func: "fetch_latest_cmake" + - func: "fetch_c_driver_source" - func: "compile" vars: RUN_DISTCHECK: 1 @@ -893,7 +894,7 @@ tasks: commands: - func: "setup" - func: "start_mongod" - - func: "fetch_latest_cmake" + - func: "fetch_c_driver_source" vars: BSON_EXTRA_ALIGNMENT: 1 - func: "compile" @@ -911,13 +912,13 @@ tasks: commands: - func: "setup" - func: "start_mongod" - - func: "fetch_latest_cmake" + - func: "fetch_c_driver_source" - func: "compile" - name: compile_without_tests commands: - func: "setup" - - func: "fetch_latest_cmake" + - func: "fetch_c_driver_source" - func: "compile" vars: ENABLE_TESTS: OFF @@ -928,7 +929,7 @@ tasks: - func: "start_mongod" vars: AUTH: auth - - func: "fetch_latest_cmake" + - func: "fetch_c_driver_source" - func: "compile" - func: "test auth" - func: "test atlas connectivity" @@ -937,7 +938,7 @@ tasks: commands: - func: "setup" - func: "start_mongod" - - func: "fetch_latest_cmake" + - func: "fetch_c_driver_source" - func: "compile" vars: USE_STATIC_LIBS: 1 @@ -953,7 +954,7 @@ tasks: commands: - func: "setup" - func: "start_mongod" - - func: "fetch_latest_cmake" + - func: "fetch_c_driver_source" vars: BSON_EXTRA_ALIGNMENT: 1 - func: "compile" @@ -972,7 +973,7 @@ tasks: - func: "start_mongod" vars: TOPOLOGY: "replica_set" - - func: "fetch_latest_cmake" + - func: "fetch_c_driver_source" - func: "compile" vars: RUN_DISTCHECK: 1 @@ -1002,7 +1003,7 @@ tasks: - name: uninstall_check commands: - func: "setup" - - func: "fetch_latest_cmake" + - func: "fetch_c_driver_source" - func: "compile" - command: expansions.update params: @@ -1022,7 +1023,7 @@ tasks: - name: uninstall_check_windows commands: - func: "setup" - - func: "fetch_latest_cmake" + - func: "fetch_c_driver_source" - func: "compile" - command: expansions.update params: @@ -1133,7 +1134,7 @@ tasks: - name: test_mongohouse commands: - func: "setup" - - func: "fetch_latest_cmake" + - func: "fetch_c_driver_source" - func: "compile" - func: "build_mongohouse" - func: "run_mongohouse" @@ -1148,7 +1149,7 @@ tasks: # Authentication with versioned API should already be tested # in the C driver. AUTH: noauth - - func: "fetch_latest_cmake" + - func: "fetch_c_driver_source" - func: "compile" - func: "clone_drivers-evergreen-tools" - func: "run_kms_servers" @@ -1163,7 +1164,7 @@ tasks: vars: ORCHESTRATION_FILE: versioned-api-testing.json AUTH: noauth - - func: "fetch_latest_cmake" + - func: "fetch_c_driver_source" - func: "compile" - func: "clone_drivers-evergreen-tools" - func: "run_kms_servers" From de877674eeb3cf9720dedd02a55d0415bc186f1d Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Tue, 1 Aug 2023 08:05:26 -0500 Subject: [PATCH 58/61] dont remove -Werror from CMAKE_CXX_FLAGS --- CMakeLists.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0fbf2c4883..495d9d747d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -85,7 +85,6 @@ if(NEED_DOWNLOAD_C_DRIVER) if(NOT mongo-c-driver_POPULATED) set(OLD_ENABLE_TESTS ${ENABLE_TESTS}) set(OLD_BUILD_TESTING ${BUILD_TESTING}) - set(OLD_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) set(OLD_CMAKE_C_FLAGS ${CMAKE_C_FLAGS}) set(ENABLE_EXTRA_ALIGNMENT OFF) @@ -97,10 +96,8 @@ if(NEED_DOWNLOAD_C_DRIVER) # Attempting to execute test-libmongoc results in an error: "Unable to find executable: NOT_FOUND" set(ENABLE_TESTS OFF) set(BUILD_TESTING OFF) - string(REPLACE " -Werror" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") string(REPLACE " -Werror" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") add_subdirectory(${mongo-c-driver_SOURCE_DIR} ${mongo-c-driver_BINARY_DIR}) - set(CMAKE_CXX_FLAGS ${OLD_CMAKE_CXX_FLAGS}) set(CMAKE_C_FLAGS ${OLD_CMAKE_C_FLAGS}) set(ENABLE_TESTS OLD_ENABLE_TESTS) set(BUILD_TESTING OLD_BUILD_TESTING) From 3533b5165f58c798b65e05b62ea9935c04168157 Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Wed, 2 Aug 2023 08:57:13 -0500 Subject: [PATCH 59/61] Revert "dont remove -Werror from CMAKE_CXX_FLAGS" This reverts commit de877674eeb3cf9720dedd02a55d0415bc186f1d. --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 495d9d747d..0fbf2c4883 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -85,6 +85,7 @@ if(NEED_DOWNLOAD_C_DRIVER) if(NOT mongo-c-driver_POPULATED) set(OLD_ENABLE_TESTS ${ENABLE_TESTS}) set(OLD_BUILD_TESTING ${BUILD_TESTING}) + set(OLD_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) set(OLD_CMAKE_C_FLAGS ${CMAKE_C_FLAGS}) set(ENABLE_EXTRA_ALIGNMENT OFF) @@ -96,8 +97,10 @@ if(NEED_DOWNLOAD_C_DRIVER) # Attempting to execute test-libmongoc results in an error: "Unable to find executable: NOT_FOUND" set(ENABLE_TESTS OFF) set(BUILD_TESTING OFF) + string(REPLACE " -Werror" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") string(REPLACE " -Werror" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") add_subdirectory(${mongo-c-driver_SOURCE_DIR} ${mongo-c-driver_BINARY_DIR}) + set(CMAKE_CXX_FLAGS ${OLD_CMAKE_CXX_FLAGS}) set(CMAKE_C_FLAGS ${OLD_CMAKE_C_FLAGS}) set(ENABLE_TESTS OLD_ENABLE_TESTS) set(BUILD_TESTING OLD_BUILD_TESTING) From ee573d2eeca5cfc7d7d5e6192e372e3823527c5c Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Wed, 2 Aug 2023 15:05:32 -0500 Subject: [PATCH 60/61] Update .mci.yml Co-authored-by: Kevin Albertson --- .mci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.mci.yml b/.mci.yml index 3aee87a4fd..e5fe6462cc 100644 --- a/.mci.yml +++ b/.mci.yml @@ -857,6 +857,7 @@ tasks: RUN_DISTCHECK: 1 - func: "clone_drivers-evergreen-tools" - func: "run_kms_servers" + # Call "install_c_driver" before "test" to build static C driver libraries. Example projects require static C driver libraries. - func: "install_c_driver" - func: "test" From e759cd94327440c6a86d522d190c9744ed972652 Mon Sep 17 00:00:00 2001 From: Kyle Kloberdanz Date: Wed, 2 Aug 2023 15:05:41 -0500 Subject: [PATCH 61/61] Update .mci.yml Co-authored-by: Kevin Albertson --- .mci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.mci.yml b/.mci.yml index e5fe6462cc..3512c9f7fd 100644 --- a/.mci.yml +++ b/.mci.yml @@ -283,7 +283,8 @@ functions: add_expansions_to_env: true script: mongo-cxx-driver/.evergreen/install_c_driver.sh - # This function may be used to fetch CI scripts in the C driver + # fetch_c_driver_source may be used to fetch the C driver source without installing the C driver. + # This can be used when only CI scripts are needed. "fetch_c_driver_source": - command: shell.exec params: