Skip to content

CXX-3087 Replace single-argument FetchContent_Populate with FetchContent_MakeAvailable #1186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 6, 2024

Conversation

eramongodb
Copy link
Contributor

Resolves CXX-3087. Verified by this patch.

Addresses the following warning emitted by CMake 3.30 and newer for mongo-c-driver and EP_mnmlstc_core:

CMake Warning (dev) at /snap/cmake/1409/share/cmake-3.30/Modules/FetchContent.cmake:1953 (message):
  Calling FetchContent_Populate(mongo-c-driver) is deprecated, call
  FetchContent_MakeAvailable(mongo-c-driver) instead.  Policy CMP0169 can be
  set to OLD to allow FetchContent_Populate(mongo-c-driver) to be called
  directly for now, but the ability to call it with declared details will be
  removed completely in a future version.
Call Stack (most recent call first):
  cmake/FetchMongoC.cmake:24 (FetchContent_Populate)
  CMakeLists.txt:78 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.

This is caused by CMP0169:

Calling FetchContent_Populate() with a single argument (the name of a declared dependency) is deprecated. [...] The OLD behavior of this policy allows FetchContent_Populate() to be called with the name of a declared dependency. The NEW behavior halts with a fatal error in such cases.

This PR replaces such calls with FetchContent_MakeAvailable() accordingly.

This was straightforward for mongo-c-driver given it was (manually) implementing add_subdirectory() behavior, which is consistent with FetchContent_MakeAvailable()'s regular behavior, which internally calls add_subdirectory() on population.

EP_mnmlstc_core required a workaround due to the SOURCE_SUBDIR option only being supported in 3.18 and newer. Using SOURCE_SUBDIR to prevents the internal add_subdirectory() call is an officially supported pattern which is needed by FetchMnmlstcCore.cmake to prevent mnmlstc/core's configurations from leaking into the C Driver's configuration (see #1019 for details). This workaround can be removed once the minimum required CMake version is raised to 3.18 or newer.

@eramongodb eramongodb requested a review from kevinAlbs August 6, 2024 17:56
@eramongodb eramongodb self-assigned this Aug 6, 2024
@@ -12,6 +12,7 @@ FetchContent_Declare(
EP_mnmlstc_core

SOURCE_DIR "${core-src}"
SOURCE_SUBDIR ""
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
SOURCE_SUBDIR ""
SOURCE_SUBDIR "" # To prevent adding project to CMake.

@eramongodb eramongodb merged commit 2d30996 into mongodb:master Aug 6, 2024
1 check was pending
@eramongodb eramongodb deleted the cxx-3087 branch August 6, 2024 18:27
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