Commit Graph

104 Commits

Author SHA1 Message Date
Peter Kokot
fe72a5dba2 FindGit: Add Git_VERSION
This deprecates the GIT_VERSION_STRING result variable.

Issue: #27088
Fixes: #26868
2025-09-14 21:08:16 +02:00
Craig Scott
20c751bdcb FetchContent: Update policy settings to CMake 4.1
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
2025-09-05 15:26:05 +10:00
Craig Scott
60b8114ea9 Help: Stronger wording for prohibited keywords in FetchContent_Declare()
Issue: #27157
2025-09-05 15:26:04 +10:00
Peter Kokot
1d0b46111e Help: Add remaining intro code blocks to modules
This is a follow-up to add intro code blocks to all remaining utility
and find modules.

Fixes: #26555
2025-08-18 11:52:56 +02:00
Kitware Robot
1772622772 LICENSE: Replace references to Copyright.txt with LICENSE.rst
```
git grep -lz 'Copyright.txt or https://cmake.org/licensing ' |
  while IFS= read -r -d $'\0' f ; do
    sed -i '/Copyright.txt or https:\/\/cmake.org\/licensing / {
              s/Copyright.txt/LICENSE.rst/
            }' "$f" ; done
```
2025-03-03 10:43:35 -05:00
Craig Scott
9299cbbdb4 FetchContent: Force cmake --fresh to re-execute direct population steps
Issue: #25468
2024-06-07 18:12:12 +10:00
Craig Scott
11b684c449 FetchContent: Fix typos in stamp/step file names
The exact file names don't technically matter, but the wrong
names are confusing and misleading.
2024-06-07 16:59:20 +10:00
Brad King
97328b05c3 Merge topic 'doc-add_subdirectory-EXCLUDE_FROM_ALL' into release-3.30
2449c04d8d Help: improve docs for the EXCLUDE_FROM_ALL directory property

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !9497
2024-06-06 08:41:58 -04:00
Alex Neundorf
2449c04d8d Help: improve docs for the EXCLUDE_FROM_ALL directory property
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.
2024-06-04 16:58:54 +02:00
Craig Scott
0cc1b550dd ExternalProject,FetchContent: Avoid CMAKE_DISABLE_SOURCE_CHANGES error
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
2024-05-31 18:01:27 +10:00
Brad King
679a3d9e6c Merge topic 'enforce-fc-fully-disconnected-requirements'
f588421b58 FetchContent: Enforce FETCHCONTENT_FULLY_DISCONNECTED requirements

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !9556
2024-05-30 10:13:29 -04:00
Brad King
54c9185b33 Merge topic 'deprecate-fetchcontent_populate'
4370fcf750 FetchContent: Deprecate FetchContent_Populate(depName)
bc70b458ad Help: Minor grammar improvements for FetchContent

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !9552
2024-05-29 08:41:57 -04:00
Craig Scott
f588421b58 FetchContent: Enforce FETCHCONTENT_FULLY_DISCONNECTED requirements
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).
2024-05-29 20:39:17 +10:00
Craig Scott
4370fcf750 FetchContent: Deprecate FetchContent_Populate(depName)
Projects should use FetchContent_MakeAvailable(depName)
instead. Policy CMP0169 provides backward compatibility.
2024-05-29 18:52:24 +10:00
Craig Scott
46d00d425c Merge topic 'fetchcontent_policies_block'
a837f15ebf FetchContent: Set policies for most commands

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !9551
2024-05-28 06:43:32 -04:00
Craig Scott
a837f15ebf FetchContent: Set policies for most commands
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).
2024-05-27 20:52:16 +10:00
Craig Scott
bc70b458ad Help: Minor grammar improvements for FetchContent 2024-05-27 08:24:10 +10:00
Craig Scott
2efceb290e FetchContent: Make FetchContent_Populate() honor CMP0168 2024-05-25 19:01:10 +10:00
Craig Scott
b2496bf14c FetchContent: Populate directly without a sub-build
Fixes: #21703
2024-05-17 14:23:39 +10:00
Brad King
11f6df1c19 Merge topic 'fc-MakeAvailable-leak-var'
2b68048bdb FetchContent: Don't leak temporary variable and restore var robustly

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !9338
2024-03-14 11:44:01 -04:00
Craig Scott
2b68048bdb FetchContent: Don't leak temporary variable and restore var robustly
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
2024-03-13 17:27:18 +11:00
Brad King
2ef3bd9186 ExternalProject: Add TLS version options for https connections
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
2024-02-28 19:11:29 -05:00
Craig Scott
50e8791f92 Merge topic 'fc-provider-find-package-args'
0415304970 FetchContent: Fix FIND_PACKAGE_ARGS not being passed to dep providers

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !9080
2023-12-17 15:43:00 -05:00
Craig Scott
18c514a86d Help: Add note not to use FETCHCONTENT_FULLY_DISCONNECTED on first run
Fixes: #25481
2023-12-16 20:36:26 +11:00
Craig Scott
0415304970 FetchContent: Fix FIND_PACKAGE_ARGS not being passed to dep providers
Fixes: #25504
2023-12-16 16:42:00 +11:00
Brad King
092438e9f6 Merge topic 'doc-fetchcontent-bad-ref'
bd50e8a058 Help: Fix malformed cross-reference in FetchContent docs

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !9047
2023-12-07 09:02:14 -05:00
Craig Scott
bd50e8a058 Help: Fix malformed cross-reference in FetchContent docs 2023-12-07 17:04:25 +11:00
Brad King
25fcc7e3de Merge topic 'FetchContent-find_package-args'
42dbdf8914 FetchContent: Fix syntax to forward FIND_PACKAGE_ARGS arguments correctly

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !8967
2023-11-17 08:19:35 -05:00
Brad King
105ac2670b Merge topic 'doc-find_package-advice'
d007d304ff Help: FetchContent FIND_PACKAGE_ARGS REQUIRED usually inappropriate
6341267780 Help: Note ways CMAKE_..._FIND_PACKAGE_... vars can break projects

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !8951
2023-11-15 08:38:54 -05:00
Adam Šulc
42dbdf8914 FetchContent: Fix syntax to forward FIND_PACKAGE_ARGS arguments correctly
Previously we incorrectly mixed list operations with string operations.
2023-11-15 08:22:19 -05:00
Kyle Edwards
0ad8fc5a63 FetchContent: Set CMAKE_EXPORT_FIND_PACKAGE_NAME 2023-11-13 11:07:53 -05:00
Craig Scott
d007d304ff Help: FetchContent FIND_PACKAGE_ARGS REQUIRED usually inappropriate 2023-11-07 21:38:10 +08:00
William Sciaroni
6a81104413 FetchContent: Pass GHS Variables to subbuild
Fixes: #24244
2023-11-05 08:42:27 +11:00
Steven Stallion
5f77807f1c FetchContent: Add support for EXCLUDE_FROM_ALL
Fixes: #20167
2023-09-26 08:56:44 +10:00
Brad King
9ede4cab2b FetchContent: Protect ExternalProject keywords from unknown arguments
`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
2023-06-29 09:49:51 -04:00
Craig Scott
1512dc43cb ExternalProject: Avoid reconfigure when updates are disconnected
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
2023-05-23 22:39:44 +10:00
Chris Wright
550f63447d ExternalProject/FetchContent: Support relative remote URLs
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>
2023-04-26 16:30:36 +08:00
Craig Scott
57f09a818c Merge topic 'fetchcontent-reject-CMAKE_TOOLCHAIN_FILE-env-var'
c15674a9cb FetchContent: Reject CMAKE_TOOLCHAIN_FILE env var in sub-build
31ef93f19f FetchContent: Only use @-@ replacements for sub-build CMakeLists.txt

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !8248
2023-02-25 17:16:37 -05:00
Craig Scott
31ef93f19f FetchContent: Only use @-@ replacements for sub-build CMakeLists.txt
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.
2023-02-24 17:07:01 +11:00
Máté Ferenc Nagy-Egri
9af0e67ee5 FetchContent: Relay CMAKE_GENERATOR_INSTANCE
If set, relay `CMAKE_GENERATOR_INSTANCE`.  It may affect compiler
detection in the subbuild folder.

Fixes: #24404
2023-02-23 17:07:50 -05:00
Eisuke Kawashima
6d48f48d5d FetchContent: Bump documented example Catch2 to v3.0.1
The previous Catch2 v2.13.4 does not compile on some platforms [1].

[1] https://github.com/catchorg/Catch2/issues/2326
2023-02-07 10:54:25 -05:00
Craig Scott
c1294454e5 Merge topic 'doc-SYSTEM'
dfab263825 Help: Clarify and update SYSTEM-related docs

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !8027
2022-12-19 15:57:22 -05:00
Craig Scott
dfab263825 Help: Clarify and update SYSTEM-related docs 2022-12-17 20:51:25 +11:00
Craig Scott
d09dc11911 Merge topic 'FetchContent-SYSTEM'
4b85141f83 FetchContent: Don't pass SYSTEM through to sub-build

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7977
2022-12-05 06:23:28 -05:00
Craig Scott
4b85141f83 FetchContent: Don't pass SYSTEM through to sub-build
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
2022-12-02 18:41:18 +11:00
Alex Turbov
1d3630203c Help: Use captions for code snippets in the FetchContent module
Instead of "manually" added captions use the Sphinx option of
`code-block` directive.
2022-11-07 22:55:06 +04:00
Alex Turbov
029210730a Help: Use role :program:
When mention execitable names use Sphinx semantic role `:program`
instead of ``executable`` or **executable**.
2022-11-06 04:28:21 +04:00
Brad King
50b668ddc8 Merge topic 'add_subdirectory_system'
2eb30a7036 add_subdirectory: Add SYSTEM option

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7399
2022-09-27 10:28:49 -04:00
Da Quexian
2eb30a7036 add_subdirectory: Add SYSTEM option
Fixes: #22401
Signed-off-by: Da Quexian <daquexian566@gmail.com>
2022-09-26 10:56:54 -04:00
Brad King
64f4bb5728 Merge topic 'fetchcontent-redirect-version-exact'
48b380c961 FetchContent: Ignore EXACT for redirected find_package() calls

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7665
2022-09-12 09:38:07 -04:00