Skip to content

Commit 6d8de05

Browse files
authored
MONGOCRYPT-839 address CMP0169 for CMake 3.30 and newer (#1053)
1 parent 5002117 commit 6d8de05

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
### Changed
66

77
- Set CMake minimum required version to `3.15...4.0` (with maximum policy version set to `4.0`).
8+
- `FetchContent_MakeAvailable()` is used to populate dependencies instead of `FetchContent_Populate()`.
9+
- This applies to MongoDB C Driver when `MONGOCRYPT_MONGOC_DIR` is not set to `USE-SYSTEM`.
10+
- This applies to IntelDFP when `MONGOCRYPT_DFP_DIR` is not set to `USE-SYSTEM`.
11+
- Note: `FetchContent_Populate()` is still used for CMake versions prior to 3.18 to avoid `add_subdirectory()` behavior.
812

913
## 1.15.0
1014

cmake/FetchMongoC.cmake

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,18 @@ FetchContent_Declare (
2727
embedded_mcd
2828
URL "https://github.com/mongodb/mongo-c-driver/archive/refs/tags/${MONGOC_FETCH_TAG_FOR_LIBBSON}.tar.gz"
2929
PATCH_COMMAND ${patch_command} --verbose
30+
SOURCE_SUBDIR "NO_ADD_SUBDIRECTORY" # add_subdirectory() is handled by ImportBSON.cmake.
3031
)
3132
# Populate it:
3233
FetchContent_GetProperties (embedded_mcd)
3334
if (NOT embedded_mcd_POPULATED)
3435
message (STATUS "Downloading mongo-c-driver ${MONGOC_FETCH_TAG_FOR_LIBBSON} for libbson")
35-
FetchContent_Populate (embedded_mcd)
36+
if("${CMAKE_VERSION}" VERSION_LESS "3.18.0")
37+
# SOURCE_SUBDIR is not yet supported.
38+
FetchContent_Populate(embedded_mcd)
39+
else()
40+
FetchContent_MakeAvailable(embedded_mcd)
41+
endif()
3642
endif ()
3743
# Store the directory path to the external mongoc project:
3844
get_filename_component (MONGOCRYPT_MONGOC_DIR "${embedded_mcd_SOURCE_DIR}" ABSOLUTE)

cmake/IntelDFP.cmake

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,18 @@ FetchContent_Declare (
4444
URL "${_default_url}"
4545
${_hash_arg}
4646
PATCH_COMMAND ${patch_command} --verbose
47+
SOURCE_SUBDIR "NO_ADD_SUBDIRECTORY" # Targets are manually defined below.
4748
)
4849

4950
FetchContent_GetProperties (intel_dfp)
5051
if (NOT intel_dfp_POPULATED)
5152
message (STATUS "Obtaining Intel Decimal FP library: ${INTEL_DFP_LIBRARY_URL}")
52-
FetchContent_Populate (intel_dfp)
53+
if("${CMAKE_VERSION}" VERSION_LESS "3.18.0")
54+
# SOURCE_SUBDIR is not yet supported.
55+
FetchContent_Populate(intel_dfp)
56+
else()
57+
FetchContent_MakeAvailable(intel_dfp)
58+
endif()
5359
endif ()
5460

5561
# This list of sources was generated by copying the MongoDB server and removing any unnecessary.

0 commit comments

Comments
 (0)