Skip to content

Conversation

@eramongodb
Copy link
Contributor

Resolves MONGOCRYPT-839. Prompted by the following CMake configuration error (among various other CMake compatibility warnings) on MacOS 14 arm64 (with CMake 4.1.0 -> libmongocrypt 1.13.0 -> mongo-c-driver 1.28.1):

CMake Error at cmake-build/_deps/embedded_mcd-src/src/libbson/CMakeLists.txt:37 (cmake_policy):
  Policy CMP0042 may not be set to OLD behavior because this version of CMake
  no longer supports it.  The policy was introduced in CMake version 3.0.0,
  and use of NEW behavior is now required.
  Please either update your CMakeLists.txt files to conform to the new
  behavior or use an older version of CMake that still supports the old
  behavior.  Run cmake --help-policy CMP0042 for more information.

mongodb/mongo-c-driver#1973 and mongodb/mongo-c-driver#2066 already addressed this issue on the C Driver's side (backported into the 1.30.3 release), which was inherited by libmongocrypt in #996 (in the 1.14.0 release). However, libmongocrypt can/should also be updated with similar CMake compatibility improvements, as CMake dropped support for versions older than 3.5 (in the 4.0 release) and deprecated supported for versions older than 3.10 (in the 3.31 release).

The minimum required CMake version was last updated from 3.5 to 3.12 in #522 to obtain FetchContent. However, this was not extended to the kms-message project, which is still set to 3.5. Given libmongocrypt uses FetchContent (thus add_subdirectory()) to obtain mongo-c-driver, and mongo-c-driver already raised its CMake minimum required version to 3.15 in mongodb/mongo-c-driver#1289 (1.24.0), and libmongocrypt currently depends on the 1.30.3 release, raising the minimum required CMake version for libmongocrypt to 3.15 should be safe (already in effect via mongo-c-driver's CMake configuration).

This PR proposes also setting the CMake maximum policy version to 4.0 for consistency with mongo-c-driver (see mongodb/mongo-c-driver#2066), forward-compatibility with CMake 4.0, and reduction of explicit calls to cmake_policy(). This addresses numerous CMake compatibility warnings and removes the need for explicit cmake_policy() calls. Some obsolete CMAKE_VERSION branches are also removed.

Copy link
Contributor

@kevinAlbs kevinAlbs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Suggest also removing the no-longer-needed check for CMP0091

@eramongodb eramongodb merged commit 6b5d382 into mongodb:master Aug 12, 2025
51 of 53 checks passed
@eramongodb eramongodb deleted the crypt-cmake-compat branch August 12, 2025 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants