diff --git a/.mci.yml b/.mci.yml index 09271c532e..ae23fb9a18 100644 --- a/.mci.yml +++ b/.mci.yml @@ -1119,10 +1119,9 @@ tasks: export CMAKE CMAKE="$(find_cmake_latest)" command -v "$CMAKE" - cd build - $CMAKE .. - $CMAKE --build . -- -j $(nproc) - ./hello_mongocxx + $CMAKE -S . -B build -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF + $CMAKE --build build + ./build/hello_mongocxx - name: debian-package-build commands: diff --git a/CHANGELOG.md b/CHANGELOG.md index 91fe4fcaa8..120f5a79dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,3 +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. 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) diff --git a/cmake/BsoncxxUtil.cmake b/cmake/BsoncxxUtil.cmake index ec2b596d5d..51dc26acc7 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) @@ -82,11 +82,6 @@ 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" - ) - install(EXPORT bsoncxx_targets NAMESPACE mongo:: FILE bsoncxx_targets.cmake diff --git a/cmake/MongocxxUtil.cmake b/cmake/MongocxxUtil.cmake index 43d406e015..457b1e8d89 100644 --- a/cmake/MongocxxUtil.cmake +++ b/cmake/MongocxxUtil.cmake @@ -71,11 +71,6 @@ function(mongocxx_install MONGOCXX_TARGET_LIST MONGOCXX_PKG_DEP) @ONLY ) - export(EXPORT mongocxx_targets - NAMESPACE mongo:: - FILE "${CMAKE_CURRENT_BINARY_DIR}/mongocxx_targets.cmake" - ) - install(EXPORT mongocxx_targets NAMESPACE mongo:: FILE mongocxx_targets.cmake 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/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/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 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}") 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