The warning for policy CMP0174 can be triggered if a project mistakenly
specifies CONFIGURE_COMMAND, BUILD_COMMAND, INSTALL_COMMAND,
or TEST_COMMAND as keywords to FetchContent_Declare() and it passes
an empty string after the keyword. It shouldn't be specifying any of those
keywords, but doing so has always worked because FetchContent_Declare()
explicitly discards them. However, when a project specifies them, they get
used internally in contexts where the policy settings are those of the
FetchContent module itself. Those settings haven't been updated past
CMake 3.29, and CMP0174 came in with CMake 3.31.
Update the policy settings for FetchContent to avoid triggering the CMP0174
warning when a project erroneously specifies the prohibited keywords.
Fixes: #27157
This patch improves the wording of the documentation of the
EXCLUDE_FROM_ALL directory property, and makes the
add_subdirectory()- and fetchcontent-documentation refer to it.
The file(MAKE_DIRECTORY) implementation checks whether a path is
allowed to be written to before it checks if it already exists. For the
scenario where a SOURCE_DIR is an existing directory within the main
project's source directory, this triggers a fatal error if
CMAKE_DISABLE_SOURCE_CHANGES is set to true for ExternalProject,
and some FetchContent scenarios. Therefore, add an explicit check for
existence first to avoid making such error-triggering calls.
Fixes: #21872
FETCHCONTENT_FULLY_DISCONNECTED should only be set to true if
each dependency's source directory has already been populated.
Previously, this wasn't being checked, but now it is (subject to a new
policy).
Previously, FetchContent was relying on the policies of the
includer being compatible with the module. That made the
module vulnerable to subtle problems where policy settings
might lead to unexpected behavior.
With this change, we now specify the policies for as much of
the module as we can without breaking backward compatibility.
Only a few specific implementation details of the
FetchContent_MakeAvailable() macro have to remain uncontrolled
due to the way those parts can invoke user or project code which
may be relying on the includer's policy settings (intentionally or not).
In FetchContent_MakeAvailable(), the __fcprefix__ previously used
when pushing the value of CMAKE_EXPORT_FIND_PACKAGE_NAME
to the variable stack is not needed. The stack will never be empty
at that point, so pushing an empty value will be handled correctly.
By removing the __fcprefix__, we no longer need any temporary
variable when restoring CMAKE_EXPORT_FIND_PACKAGE_NAME.
But we need to ensure CMAKE_EXPORT_FIND_PACKAGE_NAME is
left undefined if it wasn't defined before, and pushing an empty
value doesn't let us distinguish between unset and set-but-empty.
Therefore, when CMAKE_EXPORT_FIND_PACKAGE_NAME is undefined,
push a specific value that can't be used by the project instead and
check for that when popping it again. This ensures we can robustly
distinguish the two cases and will always restore the right state.
Fixes: #25758
Add a `TLS_VERSION` option and honor `CMAKE_TLS_VERSION` variables.
Also map the version to Git options as we already do for `TLS_VERIFY`.
Issue: #25701
`ExternalProject_Add` treats all keyword arguments as multi-valued.
FetchContent re-orders some keyword arguments w.r.t. unparsed arguments.
Add an internal keyword argument to separate the keyword values from
following unparsed arguments.
This was exposed by commit 550f63447d (ExternalProject/FetchContent:
Support relative remote URLs, 2023-04-21, v3.27.0-rc1~156^2) by adding
`GIT_REPOSITORY` to the set of re-ordered keyword arguments. This
caused its value to absorb following unparsed arguments.
Fixes: #25029
When UPDATE_DISCONNECTED is true, create separate update_disconnected
and patch_disconnected targets which have ALWAYS set to false.
Make the configure step depend on patch_disconnected in this case too.
This ensures the configure, build, install and test steps are not
executed unnecessarily when updates are disconnected.
Make the update and patch commands depend on the details of those
steps. This ensures they are re-executed when any of those details
change, even if updates are disconnected.
Allow updates to occur even if UPDATE_DISCONNECTED is true, but don't
contact the remote in that case. If asked to update to a ref that isn't known
locally, that is now detected and causes a fatal error when updates are
disconnected. Previously, the build would have silently and erroneously
continued to use the old ref.
Fixes: #16419, #19703, #21146
Teach `ExternalProject_Add` and `FetchContent_Declare` to resolve
relative remote URLs provided via `GIT_REPOSITORY`. Add policy
CMP0150 to maintain compatibility.
Fixes: #24211
Co-Authored-By: Craig Scott <craig.scott@crascit.com>
There was a mix of ${} and @-@ substitutions in the CMakeLists.txt.in
file. It is sometimes useful to temporarily put ${} evaluations there while
working on issues, but they get replaced. Using @ONLY leaves them
untouched and uses a consistent substitution method for the whole file.
If we don't filter out SYSTEM from the arguments we pass
through to ExternalProject_Add(), it gets appended as a
list item to whatever arguments precede it because
ExternalProject_Add() doesn't recognize it as a keyword.
Fixes: #24201