From 4c799518978da2d814c85a9ede89882781dbb8fd Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Thu, 14 Sep 2023 16:38:02 -0500 Subject: [PATCH 01/12] CXX-2748 Disable generation of build tree targets file --- cmake/BsoncxxUtil.cmake | 9 +++++---- cmake/MongocxxUtil.cmake | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/cmake/BsoncxxUtil.cmake b/cmake/BsoncxxUtil.cmake index ec2b596d5d..1a96333dcc 100644 --- a/cmake/BsoncxxUtil.cmake +++ b/cmake/BsoncxxUtil.cmake @@ -82,10 +82,11 @@ function(bsoncxx_install BSONCXX_TARGET_LIST BSONCXX_PKG_DEP BSONCXX_BOOST_PKG_D @ONLY ) - export(EXPORT bsoncxx_targets - NAMESPACE mongo:: - FILE "${CMAKE_CURRENT_BINARY_DIR}/bsoncxx_targets.cmake" - ) + # CXX-2748 + # export(EXPORT bsoncxx_targets + # NAMESPACE mongo:: + # FILE "${CMAKE_CURRENT_BINARY_DIR}/bsoncxx_targets.cmake" + # ) install(EXPORT bsoncxx_targets NAMESPACE mongo:: diff --git a/cmake/MongocxxUtil.cmake b/cmake/MongocxxUtil.cmake index 43d406e015..363e808e9f 100644 --- a/cmake/MongocxxUtil.cmake +++ b/cmake/MongocxxUtil.cmake @@ -71,10 +71,11 @@ function(mongocxx_install MONGOCXX_TARGET_LIST MONGOCXX_PKG_DEP) @ONLY ) - export(EXPORT mongocxx_targets - NAMESPACE mongo:: - FILE "${CMAKE_CURRENT_BINARY_DIR}/mongocxx_targets.cmake" - ) + # CXX-2748 + # export(EXPORT mongocxx_targets + # NAMESPACE mongo:: + # FILE "${CMAKE_CURRENT_BINARY_DIR}/mongocxx_targets.cmake" + # ) install(EXPORT mongocxx_targets NAMESPACE mongo:: From b8f6dc1a0d0e45b61f72699e8952a6f2301df3ee Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Thu, 14 Sep 2023 14:36:04 -0500 Subject: [PATCH 02/12] Fix target of BSONCXX_STATIC compile definition for bsoncxx_add_library() --- cmake/BsoncxxUtil.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/BsoncxxUtil.cmake b/cmake/BsoncxxUtil.cmake index 1a96333dcc..aae1fbe12a 100644 --- a/cmake/BsoncxxUtil.cmake +++ b/cmake/BsoncxxUtil.cmake @@ -25,7 +25,7 @@ function(bsoncxx_add_library TARGET OUTPUT_NAME LINK_TYPE) endif() if(LINK_TYPE STREQUAL "STATIC") - target_compile_definitions(bsoncxx_static PUBLIC BSONCXX_STATIC) + target_compile_definitions(${TARGET} PUBLIC BSONCXX_STATIC) endif() if(BSONCXX_POLY_USE_MNMLSTC AND NOT BSONCXX_POLY_USE_SYSTEM_MNMLSTC) From d340670e63cfd5700755fd50fcc54b940feda067 Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Thu, 14 Sep 2023 16:55:23 -0500 Subject: [PATCH 03/12] Fix find_dependency() specification in CMake package config files --- src/bsoncxx/CMakeLists.txt | 18 ++++-------------- src/mongocxx/CMakeLists.txt | 18 ++++-------------- 2 files changed, 8 insertions(+), 28 deletions(-) diff --git a/src/bsoncxx/CMakeLists.txt b/src/bsoncxx/CMakeLists.txt index 32305fd82d..fe39749cc5 100644 --- a/src/bsoncxx/CMakeLists.txt +++ b/src/bsoncxx/CMakeLists.txt @@ -108,9 +108,7 @@ if(TARGET bson_shared OR TARGET bson_static) set(libbson_target bson_static) endif() - if(BSONCXX_BUILD_STATIC) - set(bsoncxx_pkg_dep "find_dependency(bson-1.0 REQUIRED)") - endif() + set(bsoncxx_pkg_dep "find_dependency(bson-${LIBBSON_REQUIRED_ABI_VERSION} REQUIRED)") else() # Attempt to find libbson by new package name (without lib). find_package(bson-${LIBBSON_REQUIRED_ABI_VERSION} ${LIBBSON_REQUIRED_VERSION} QUIET) @@ -122,10 +120,7 @@ else() else() set(libbson_target mongo::bson_static) endif() - - if(BSONCXX_BUILD_STATIC) - set(bsoncxx_pkg_dep "find_dependency(bson-1.0 REQUIRED)") - endif() + set(bsoncxx_pkg_dep "find_dependency(bson-${LIBBSON_REQUIRED_ABI_VERSION} REQUIRED)") else() # Require package of old libbson name (with lib). if(NOT BSONCXX_LINK_WITH_STATIC_MONGOC) @@ -134,18 +129,14 @@ else() set(libbson_target ${BSON_LIBRARIES}) set(libbson_include_directories ${BSON_INCLUDE_DIRS}) set(libbson_definitions ${BSON_DEFINITIONS}) - if(BSONCXX_BUILD_STATIC) - set(bsoncxx_pkg_dep "find_dependency(libbson-1.0 REQUIRED)") - endif() + set(bsoncxx_pkg_dep "find_dependency(libbson-${LIBBSON_REQUIRED_ABI_VERSION} REQUIRED)") else() find_package(libbson-static-${LIBBSON_REQUIRED_ABI_VERSION} ${LIBBSON_REQUIRED_VERSION} REQUIRED) message ("found libbson version ${BSON_STATIC_VERSION}") set(libbson_target ${BSON_STATIC_LIBRARIES}) set(libbson_include_directories ${BSON_STATIC_INCLUDE_DIRS}) set(libbson_definitions ${BSON_STATIC_DEFINITIONS}) - if(BSONCXX_BUILD_STATIC) - set(bsoncxx_pkg_dep "find_dependency(libbson-static-1.0 REQUIRED)") - endif() + set(bsoncxx_pkg_dep "find_dependency(libbson-static-${LIBBSON_REQUIRED_ABI_VERSION} REQUIRED)") endif() endif() endif() @@ -232,7 +223,6 @@ endif() if(BSONCXX_BUILD_STATIC) bsoncxx_install_deprecated_cmake(bsoncxx-static) list(APPEND bsoncxx_target_list bsoncxx_static) - set(bsoncxx_pkg_dep "find_dependency(bson-1.0 REQUIRED)") endif() if(BSONCXX_POLY_USE_BOOST) set(bsoncxx_boost_pkg_dep "find_dependency(Boost 1.56.0 REQUIRED)") diff --git a/src/mongocxx/CMakeLists.txt b/src/mongocxx/CMakeLists.txt index 45f6bfc1d0..5f95d74fac 100644 --- a/src/mongocxx/CMakeLists.txt +++ b/src/mongocxx/CMakeLists.txt @@ -42,9 +42,7 @@ if(TARGET mongoc_shared OR TARGET mongoc_static) set(libmongoc_target mongoc_static) endif() - if(MONGOCXX_BUILD_STATIC) - set(mongocxx_pkg_dep "find_dependency(mongoc-1.0 REQUIRED)") - endif() + set(mongocxx_pkg_dep "find_dependency(mongoc-${LIBMONGOC_REQUIRED_ABI_VERSION} REQUIRED)") else() # Attempt to find libmongoc by new package name (without lib). find_package(mongoc-${LIBMONGOC_REQUIRED_ABI_VERSION} ${LIBMONGOC_REQUIRED_VERSION} QUIET) @@ -56,10 +54,7 @@ else() else() set(libmongoc_target mongo::mongoc_static) endif() - - if(MONGOCXX_BUILD_STATIC) - set(mongocxx_pkg_dep "find_dependency(mongoc-1.0 REQUIRED)") - endif() + set(mongocxx_pkg_dep "find_dependency(mongoc-${LIBMONGOC_REQUIRED_ABI_VERSION} REQUIRED)") else() # Require package of old libmongoc name (with lib). if(NOT MONGOCXX_LINK_WITH_STATIC_MONGOC) @@ -67,17 +62,13 @@ else() message ("found libmongoc version ${MONGOC_VERSION}") set(libmongoc_target ${MONGOC_LIBRARIES}) set(libmongoc_definitions ${MONGOC_DEFINITIONS}) - if(MONGOCXX_BUILD_STATIC) - set(mongocxx_pkg_dep "find_dependency(libmongoc-1.0 REQUIRED)") - endif() + set(mongocxx_pkg_dep "find_dependency(libmongoc-${LIBMONGOC_REQUIRED_ABI_VERSION} REQUIRED)") else() find_package(libmongoc-static-${LIBMONGOC_REQUIRED_ABI_VERSION} ${LIBMONGOC_REQUIRED_VERSION} REQUIRED) message ("found libmongoc version ${MONGOC_STATIC_VERSION}") set(libmongoc_target ${MONGOC_STATIC_LIBRARIES}) set(libmongoc_definitions ${MONGOC_STATIC_DEFINITIONS}) - if(MONGOCXX_BUILD_STATIC) - set(mongocxx_pkg_dep "find_dependency(libmongoc-static-1.0 REQUIRED)") - endif() + set(mongocxx_pkg_dep "find_dependency(libmongoc-static-${LIBMONGOC_REQUIRED_ABI_VERSION} REQUIRED)") endif() endif() endif() @@ -245,7 +236,6 @@ endif() if(MONGOCXX_BUILD_STATIC) mongocxx_install_deprecated_cmake(mongocxx-static) list(APPEND mongocxx_target_list mongocxx_static) - set(mongocxx_pkg_dep "find_dependency(mongoc-1.0 REQUIRED)") endif() mongocxx_install("${mongocxx_target_list}" "${mongocxx_pkg_dep}") From 0d4834c8206f7dc53df00c8923d4f1cf8a15336a Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Thu, 14 Sep 2023 16:55:41 -0500 Subject: [PATCH 04/12] Fix include directive for libbson and libmongoc headers --- src/bsoncxx/private/libbson.hh | 2 +- src/mongocxx/private/libmongoc.hh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bsoncxx/private/libbson.hh b/src/bsoncxx/private/libbson.hh index 91ef8c38ab..276fd6958b 100644 --- a/src/bsoncxx/private/libbson.hh +++ b/src/bsoncxx/private/libbson.hh @@ -24,7 +24,7 @@ // TODO: CXX-1366 Disable MSVC warnings for libbson #endif -#include +#include #if defined(__clang__) #pragma clang diagnostic pop diff --git a/src/mongocxx/private/libmongoc.hh b/src/mongocxx/private/libmongoc.hh index e6888fdede..e24320f20c 100644 --- a/src/mongocxx/private/libmongoc.hh +++ b/src/mongocxx/private/libmongoc.hh @@ -24,7 +24,7 @@ // TODO: CXX-1366 Disable MSVC warnings for libmongoc #endif -#include +#include #if defined(__clang__) #pragma clang diagnostic pop From 9c4543440874d3122a0056347da6fbcf743a6d63 Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Thu, 14 Sep 2023 17:07:08 -0500 Subject: [PATCH 05/12] CXX-2749 Unconditionally use for mnmlstc/core headers --- src/bsoncxx/stdx/make_unique.hpp | 4 ---- src/bsoncxx/stdx/optional.hpp | 4 ---- src/bsoncxx/stdx/string_view.hpp | 4 ---- 3 files changed, 12 deletions(-) diff --git a/src/bsoncxx/stdx/make_unique.hpp b/src/bsoncxx/stdx/make_unique.hpp index fe8bb2d257..7bc90d50c4 100644 --- a/src/bsoncxx/stdx/make_unique.hpp +++ b/src/bsoncxx/stdx/make_unique.hpp @@ -18,11 +18,7 @@ #if defined(BSONCXX_POLY_USE_MNMLSTC) -#if defined(MONGO_CXX_DRIVER_COMPILING) || defined(BSONCXX_POLY_USE_SYSTEM_MNMLSTC) #include -#else -#include -#endif namespace bsoncxx { BSONCXX_INLINE_NAMESPACE_BEGIN diff --git a/src/bsoncxx/stdx/optional.hpp b/src/bsoncxx/stdx/optional.hpp index a62fd1b594..17b6806b21 100644 --- a/src/bsoncxx/stdx/optional.hpp +++ b/src/bsoncxx/stdx/optional.hpp @@ -18,11 +18,7 @@ #if defined(BSONCXX_POLY_USE_MNMLSTC) -#if defined(MONGO_CXX_DRIVER_COMPILING) || defined(BSONCXX_POLY_USE_SYSTEM_MNMLSTC) #include -#else -#include -#endif namespace bsoncxx { BSONCXX_INLINE_NAMESPACE_BEGIN diff --git a/src/bsoncxx/stdx/string_view.hpp b/src/bsoncxx/stdx/string_view.hpp index 581d346bdf..35a41177c4 100644 --- a/src/bsoncxx/stdx/string_view.hpp +++ b/src/bsoncxx/stdx/string_view.hpp @@ -18,11 +18,7 @@ #if defined(BSONCXX_POLY_USE_MNMLSTC) -#if defined(MONGO_CXX_DRIVER_COMPILING) || defined(BSONCXX_POLY_USE_SYSTEM_MNMLSTC) #include -#else -#include -#endif namespace bsoncxx { BSONCXX_INLINE_NAMESPACE_BEGIN From a5bb15107be297231dcb193f2fcd0d0ed3aa63f5 Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Fri, 15 Sep 2023 09:15:01 -0500 Subject: [PATCH 06/12] Address ENABLE_AUTOMATIC_INIT_OR_CLEANUP warnings --- .mci.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.mci.yml b/.mci.yml index b54c5d0d50..adb21903b5 100644 --- a/.mci.yml +++ b/.mci.yml @@ -1121,9 +1121,8 @@ tasks: . ./mongo-c-driver/.evergreen/scripts/find-cmake-version.sh export CMAKE CMAKE="$(find_cmake_version 3 25 3)" - cd build - $CMAKE .. - $CMAKE --build . -- -j $(nproc) + $CMAKE -S . -B build -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF + $CMAKE --build build ./hello_mongocxx - name: debian-package-build From e4567089c93175e7c5d4959e1f6b620dd89c4b98 Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Fri, 15 Sep 2023 09:34:40 -0500 Subject: [PATCH 07/12] Fix path to build/hello_mongocxx --- .mci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.mci.yml b/.mci.yml index adb21903b5..e2f490ae62 100644 --- a/.mci.yml +++ b/.mci.yml @@ -1123,7 +1123,7 @@ tasks: CMAKE="$(find_cmake_version 3 25 3)" $CMAKE -S . -B build -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF $CMAKE --build build - ./hello_mongocxx + ./build/hello_mongocxx - name: debian-package-build commands: From 8f15fce744ecba8e7fda7fbdd67860dc9f4dc501 Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Fri, 15 Sep 2023 17:06:37 -0500 Subject: [PATCH 08/12] Remove stray MONGOCXX project variable blocks --- CMakeLists.txt | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2340672f8c..f3ecddc46a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,16 +53,6 @@ if(TARGET mongoc_shared OR TARGET mongoc_static) # If these targets exist, then libmongoc has already been included as a project # sub-directory message (STATUS "Found libmongoc targets declared in current build scope; version not checked") - - if(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) From 22a7aeba856a086c9d06afb4955abf369257abb6 Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Mon, 18 Sep 2023 09:20:45 -0500 Subject: [PATCH 09/12] Remove build tree targets file code entirely --- cmake/BsoncxxUtil.cmake | 6 ------ cmake/MongocxxUtil.cmake | 6 ------ 2 files changed, 12 deletions(-) diff --git a/cmake/BsoncxxUtil.cmake b/cmake/BsoncxxUtil.cmake index aae1fbe12a..51dc26acc7 100644 --- a/cmake/BsoncxxUtil.cmake +++ b/cmake/BsoncxxUtil.cmake @@ -82,12 +82,6 @@ function(bsoncxx_install BSONCXX_TARGET_LIST BSONCXX_PKG_DEP BSONCXX_BOOST_PKG_D @ONLY ) - # CXX-2748 - # export(EXPORT bsoncxx_targets - # NAMESPACE mongo:: - # FILE "${CMAKE_CURRENT_BINARY_DIR}/bsoncxx_targets.cmake" - # ) - install(EXPORT bsoncxx_targets NAMESPACE mongo:: FILE bsoncxx_targets.cmake diff --git a/cmake/MongocxxUtil.cmake b/cmake/MongocxxUtil.cmake index 363e808e9f..457b1e8d89 100644 --- a/cmake/MongocxxUtil.cmake +++ b/cmake/MongocxxUtil.cmake @@ -71,12 +71,6 @@ function(mongocxx_install MONGOCXX_TARGET_LIST MONGOCXX_PKG_DEP) @ONLY ) - # CXX-2748 - # export(EXPORT mongocxx_targets - # NAMESPACE mongo:: - # FILE "${CMAKE_CURRENT_BINARY_DIR}/mongocxx_targets.cmake" - # ) - install(EXPORT mongocxx_targets NAMESPACE mongo:: FILE mongocxx_targets.cmake From 248afa7984926e2377f39ade490b130e4874c77f Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Mon, 18 Sep 2023 09:23:24 -0500 Subject: [PATCH 10/12] Update CHANGELOG with removal of build tree targets file --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 91fe4fcaa8..b876e65fdb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,3 +24,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Explicitly document that throwing an exception from an APM callback is undefined behavior. - Do not prematurely install mnmlstc/core headers during the CMake build step. + +### Removed +- Remove support for generation of a CMake build tree targets file. From 13ace6d562b52971cd495c861298cf54661c5d90 Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Mon, 18 Sep 2023 11:21:31 -0500 Subject: [PATCH 11/12] Tweak wording in CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b876e65fdb..4e7839a15d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,4 +26,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Do not prematurely install mnmlstc/core headers during the CMake build step. ### Removed -- Remove support for generation of a CMake build tree targets file. +- Remove support for exported targets from the CMake project build tree. From 5f01ab9c013d825d86aaac3c50e1164e4906f631 Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Mon, 18 Sep 2023 15:05:09 -0500 Subject: [PATCH 12/12] Document addition of find_dependency() in CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e7839a15d..120f5a79dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Explicitly document that throwing an exception from an APM callback is undefined behavior. - Do not prematurely install mnmlstc/core headers during the CMake build step. +- Require a C Driver CMake package is found via `find_dependency()` for all installed CXX Driver package configurations. ### Removed - Remove support for exported targets from the CMake project build tree.