Skip to content

Commit 25f3318

Browse files
authored
CXX-2748 Disable generation of built tree targets files (#1024)
* CXX-2748 Disable generation of build tree targets files * Fix target of BSONCXX_STATIC compile definition for bsoncxx_add_library() * Fix missing find_dependency() specification in CMake package config files * Fix include directive for libbson and libmongoc headers * CXX-2749 Unconditionally use <core/...> for mnmlstc/core headers * Address ENABLE_AUTOMATIC_INIT_OR_CLEANUP warnings
1 parent 08f57db commit 25f3318

File tree

12 files changed

+18
-67
lines changed

12 files changed

+18
-67
lines changed

.mci.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,10 +1119,9 @@ tasks:
11191119
export CMAKE
11201120
CMAKE="$(find_cmake_latest)"
11211121
command -v "$CMAKE"
1122-
cd build
1123-
$CMAKE ..
1124-
$CMAKE --build . -- -j $(nproc)
1125-
./hello_mongocxx
1122+
$CMAKE -S . -B build -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF
1123+
$CMAKE --build build
1124+
./build/hello_mongocxx
11261125
11271126
- name: debian-package-build
11281127
commands:

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2424
### Fixed
2525
- Explicitly document that throwing an exception from an APM callback is undefined behavior.
2626
- Do not prematurely install mnmlstc/core headers during the CMake build step.
27+
- Require a C Driver CMake package is found via `find_dependency()` for all installed CXX Driver package configurations.
28+
29+
### Removed
30+
- Remove support for exported targets from the CMake project build tree.

CMakeLists.txt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,6 @@ if(TARGET mongoc_shared OR TARGET mongoc_static)
5353
# If these targets exist, then libmongoc has already been included as a project
5454
# sub-directory
5555
message (STATUS "Found libmongoc targets declared in current build scope; version not checked")
56-
57-
if(NOT MONGOCXX_LINK_WITH_STATIC_MONGOC)
58-
set(libmongoc_target mongoc_shared)
59-
else()
60-
set(libmongoc_target mongoc_static)
61-
endif()
62-
63-
if(MONGOCXX_BUILD_STATIC)
64-
set(mongocxx_pkg_dep "find_dependency(mongoc-1.0 REQUIRED)")
65-
endif()
6656
else()
6757
find_package(mongoc-${LIBMONGOC_REQUIRED_ABI_VERSION} ${LIBMONGOC_REQUIRED_VERSION} QUIET)
6858
if(mongoc-${LIBMONGOC_REQUIRED_ABI_VERSION}_FOUND)

cmake/BsoncxxUtil.cmake

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function(bsoncxx_add_library TARGET OUTPUT_NAME LINK_TYPE)
2525
endif()
2626

2727
if(LINK_TYPE STREQUAL "STATIC")
28-
target_compile_definitions(bsoncxx_static PUBLIC BSONCXX_STATIC)
28+
target_compile_definitions(${TARGET} PUBLIC BSONCXX_STATIC)
2929
endif()
3030

3131
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
8282
@ONLY
8383
)
8484

85-
export(EXPORT bsoncxx_targets
86-
NAMESPACE mongo::
87-
FILE "${CMAKE_CURRENT_BINARY_DIR}/bsoncxx_targets.cmake"
88-
)
89-
9085
install(EXPORT bsoncxx_targets
9186
NAMESPACE mongo::
9287
FILE bsoncxx_targets.cmake

cmake/MongocxxUtil.cmake

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,6 @@ function(mongocxx_install MONGOCXX_TARGET_LIST MONGOCXX_PKG_DEP)
7171
@ONLY
7272
)
7373

74-
export(EXPORT mongocxx_targets
75-
NAMESPACE mongo::
76-
FILE "${CMAKE_CURRENT_BINARY_DIR}/mongocxx_targets.cmake"
77-
)
78-
7974
install(EXPORT mongocxx_targets
8075
NAMESPACE mongo::
8176
FILE mongocxx_targets.cmake

src/bsoncxx/CMakeLists.txt

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,7 @@ if(TARGET bson_shared OR TARGET bson_static)
108108
set(libbson_target bson_static)
109109
endif()
110110

111-
if(BSONCXX_BUILD_STATIC)
112-
set(bsoncxx_pkg_dep "find_dependency(bson-1.0 REQUIRED)")
113-
endif()
111+
set(bsoncxx_pkg_dep "find_dependency(bson-${LIBBSON_REQUIRED_ABI_VERSION} REQUIRED)")
114112
else()
115113
# Attempt to find libbson by new package name (without lib).
116114
find_package(bson-${LIBBSON_REQUIRED_ABI_VERSION} ${LIBBSON_REQUIRED_VERSION} QUIET)
@@ -122,10 +120,7 @@ else()
122120
else()
123121
set(libbson_target mongo::bson_static)
124122
endif()
125-
126-
if(BSONCXX_BUILD_STATIC)
127-
set(bsoncxx_pkg_dep "find_dependency(bson-1.0 REQUIRED)")
128-
endif()
123+
set(bsoncxx_pkg_dep "find_dependency(bson-${LIBBSON_REQUIRED_ABI_VERSION} REQUIRED)")
129124
else()
130125
# Require package of old libbson name (with lib).
131126
if(NOT BSONCXX_LINK_WITH_STATIC_MONGOC)
@@ -134,18 +129,14 @@ else()
134129
set(libbson_target ${BSON_LIBRARIES})
135130
set(libbson_include_directories ${BSON_INCLUDE_DIRS})
136131
set(libbson_definitions ${BSON_DEFINITIONS})
137-
if(BSONCXX_BUILD_STATIC)
138-
set(bsoncxx_pkg_dep "find_dependency(libbson-1.0 REQUIRED)")
139-
endif()
132+
set(bsoncxx_pkg_dep "find_dependency(libbson-${LIBBSON_REQUIRED_ABI_VERSION} REQUIRED)")
140133
else()
141134
find_package(libbson-static-${LIBBSON_REQUIRED_ABI_VERSION} ${LIBBSON_REQUIRED_VERSION} REQUIRED)
142135
message ("found libbson version ${BSON_STATIC_VERSION}")
143136
set(libbson_target ${BSON_STATIC_LIBRARIES})
144137
set(libbson_include_directories ${BSON_STATIC_INCLUDE_DIRS})
145138
set(libbson_definitions ${BSON_STATIC_DEFINITIONS})
146-
if(BSONCXX_BUILD_STATIC)
147-
set(bsoncxx_pkg_dep "find_dependency(libbson-static-1.0 REQUIRED)")
148-
endif()
139+
set(bsoncxx_pkg_dep "find_dependency(libbson-static-${LIBBSON_REQUIRED_ABI_VERSION} REQUIRED)")
149140
endif()
150141
endif()
151142
endif()
@@ -232,7 +223,6 @@ endif()
232223
if(BSONCXX_BUILD_STATIC)
233224
bsoncxx_install_deprecated_cmake(bsoncxx-static)
234225
list(APPEND bsoncxx_target_list bsoncxx_static)
235-
set(bsoncxx_pkg_dep "find_dependency(bson-1.0 REQUIRED)")
236226
endif()
237227
if(BSONCXX_POLY_USE_BOOST)
238228
set(bsoncxx_boost_pkg_dep "find_dependency(Boost 1.56.0 REQUIRED)")

src/bsoncxx/private/libbson.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
// TODO: CXX-1366 Disable MSVC warnings for libbson
2525
#endif
2626

27-
#include <bson.h>
27+
#include <bson/bson.h>
2828

2929
#if defined(__clang__)
3030
#pragma clang diagnostic pop

src/bsoncxx/stdx/make_unique.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,7 @@
1818

1919
#if defined(BSONCXX_POLY_USE_MNMLSTC)
2020

21-
#if defined(MONGO_CXX_DRIVER_COMPILING) || defined(BSONCXX_POLY_USE_SYSTEM_MNMLSTC)
2221
#include <core/memory.hpp>
23-
#else
24-
#include <bsoncxx/third_party/mnmlstc/core/memory.hpp>
25-
#endif
2622

2723
namespace bsoncxx {
2824
BSONCXX_INLINE_NAMESPACE_BEGIN

src/bsoncxx/stdx/optional.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,7 @@
1818

1919
#if defined(BSONCXX_POLY_USE_MNMLSTC)
2020

21-
#if defined(MONGO_CXX_DRIVER_COMPILING) || defined(BSONCXX_POLY_USE_SYSTEM_MNMLSTC)
2221
#include <core/optional.hpp>
23-
#else
24-
#include <bsoncxx/third_party/mnmlstc/core/optional.hpp>
25-
#endif
2622

2723
namespace bsoncxx {
2824
BSONCXX_INLINE_NAMESPACE_BEGIN

src/bsoncxx/stdx/string_view.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,7 @@
1818

1919
#if defined(BSONCXX_POLY_USE_MNMLSTC)
2020

21-
#if defined(MONGO_CXX_DRIVER_COMPILING) || defined(BSONCXX_POLY_USE_SYSTEM_MNMLSTC)
2221
#include <core/string.hpp>
23-
#else
24-
#include <bsoncxx/third_party/mnmlstc/core/string.hpp>
25-
#endif
2622

2723
namespace bsoncxx {
2824
BSONCXX_INLINE_NAMESPACE_BEGIN

src/mongocxx/CMakeLists.txt

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ if(TARGET mongoc_shared OR TARGET mongoc_static)
4242
set(libmongoc_target mongoc_static)
4343
endif()
4444

45-
if(MONGOCXX_BUILD_STATIC)
46-
set(mongocxx_pkg_dep "find_dependency(mongoc-1.0 REQUIRED)")
47-
endif()
45+
set(mongocxx_pkg_dep "find_dependency(mongoc-${LIBMONGOC_REQUIRED_ABI_VERSION} REQUIRED)")
4846
else()
4947
# Attempt to find libmongoc by new package name (without lib).
5048
find_package(mongoc-${LIBMONGOC_REQUIRED_ABI_VERSION} ${LIBMONGOC_REQUIRED_VERSION} QUIET)
@@ -56,28 +54,21 @@ else()
5654
else()
5755
set(libmongoc_target mongo::mongoc_static)
5856
endif()
59-
60-
if(MONGOCXX_BUILD_STATIC)
61-
set(mongocxx_pkg_dep "find_dependency(mongoc-1.0 REQUIRED)")
62-
endif()
57+
set(mongocxx_pkg_dep "find_dependency(mongoc-${LIBMONGOC_REQUIRED_ABI_VERSION} REQUIRED)")
6358
else()
6459
# Require package of old libmongoc name (with lib).
6560
if(NOT MONGOCXX_LINK_WITH_STATIC_MONGOC)
6661
find_package(libmongoc-${LIBMONGOC_REQUIRED_ABI_VERSION} ${LIBMONGOC_REQUIRED_VERSION} REQUIRED)
6762
message ("found libmongoc version ${MONGOC_VERSION}")
6863
set(libmongoc_target ${MONGOC_LIBRARIES})
6964
set(libmongoc_definitions ${MONGOC_DEFINITIONS})
70-
if(MONGOCXX_BUILD_STATIC)
71-
set(mongocxx_pkg_dep "find_dependency(libmongoc-1.0 REQUIRED)")
72-
endif()
65+
set(mongocxx_pkg_dep "find_dependency(libmongoc-${LIBMONGOC_REQUIRED_ABI_VERSION} REQUIRED)")
7366
else()
7467
find_package(libmongoc-static-${LIBMONGOC_REQUIRED_ABI_VERSION} ${LIBMONGOC_REQUIRED_VERSION} REQUIRED)
7568
message ("found libmongoc version ${MONGOC_STATIC_VERSION}")
7669
set(libmongoc_target ${MONGOC_STATIC_LIBRARIES})
7770
set(libmongoc_definitions ${MONGOC_STATIC_DEFINITIONS})
78-
if(MONGOCXX_BUILD_STATIC)
79-
set(mongocxx_pkg_dep "find_dependency(libmongoc-static-1.0 REQUIRED)")
80-
endif()
71+
set(mongocxx_pkg_dep "find_dependency(libmongoc-static-${LIBMONGOC_REQUIRED_ABI_VERSION} REQUIRED)")
8172
endif()
8273
endif()
8374
endif()
@@ -245,7 +236,6 @@ endif()
245236
if(MONGOCXX_BUILD_STATIC)
246237
mongocxx_install_deprecated_cmake(mongocxx-static)
247238
list(APPEND mongocxx_target_list mongocxx_static)
248-
set(mongocxx_pkg_dep "find_dependency(mongoc-1.0 REQUIRED)")
249239
endif()
250240
mongocxx_install("${mongocxx_target_list}" "${mongocxx_pkg_dep}")
251241

src/mongocxx/private/libmongoc.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
// TODO: CXX-1366 Disable MSVC warnings for libmongoc
2525
#endif
2626

27-
#include <mongoc.h>
27+
#include <mongoc/mongoc.h>
2828

2929
#if defined(__clang__)
3030
#pragma clang diagnostic pop

0 commit comments

Comments
 (0)