Commit Graph

82 Commits

Author SHA1 Message Date
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
Craig Scott
b9175800a2 Merge topic 'fetchcontent-unset-wrong-nested-var'
d9a6e0ffc8 FetchContent: Fix unsetting wrong variable name after provider returns

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7663
2022-09-11 18:09:11 -04:00
Craig Scott
48b380c961 FetchContent: Ignore EXACT for redirected find_package() calls
When FetchContent_MakeAvailable() populates a dependency for which
find_package() integration is enabled, all future calls to find_package()
MUST succeed using the contents of the redirection directory. The
generated config version file was not handling calls where the EXACT
keyword was given, resulting in such calls rejecting the redirection
directory's contents and continuing its search. It is not allowed to do
that. Fix the generated file to also set PACKAGE_VERSION_EXACT to
true so that calls with EXACT now accept it, as was originally intended.

Fixes: #23950
2022-09-11 18:36:31 +10:00
Craig Scott
d9a6e0ffc8 FetchContent: Fix unsetting wrong variable name after provider returns
The unset() command was using __cmake_contentNameLower before that
variable was restored from the __cmake_fcCurrentVarsStack. That means
if there had been a nested call to FetchContent_MakeAvailable(), the wrong
variable name would have been cleared (the nested name instead of the
one from the current call). That would have left the variable set upon return,
blocking the dependency provider from seeing any further calls to
FetchContent_MakeAvailable() in the current variable scope or below for the
current dependency.
2022-09-10 18:23:21 +10:00
Brad King
08930f76ef Merge topic 'fetchcontent-extra'
629d106c5e Help: Fix typo in FetchContent example, extras should read extra

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: hinell <al.neodim@gmail.com>
Merge-request: !7657
2022-09-09 09:53:41 -04:00
Mathieu Malaterre
629d106c5e Help: Fix typo in FetchContent example, extras should read extra
Amends 29e31e2825 (Packages: Integrate FetchContent and
find_package(), 2022-04-28)
2022-09-09 20:08:32 +10:00
Craig Scott
c14494f19f Merge topic 'doc-fetchcontent-gtest-example'
daa2a6cda6 Help: Fix wrong casing of GTest in FetchContent integration example

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7644
2022-09-05 08:20:24 -04:00
Craig Scott
daa2a6cda6 Help: Fix wrong casing of GTest in FetchContent integration example 2022-09-04 17:18:09 +10:00
Harald Fernengel
b57681dc34 FetchContent: Fix protobuf example to avoid CMP0077 warning
The protobuf example would raise a "Policy CMP0077" warning and
protobuf tests would still be built, e.g. setting the variable is
ignored in latest CMake. Set an INTERNAL cache variable instead so
that CMP0077 warnings won't be triggered.
2022-08-13 09:44:45 +10:00
Craig Scott
2a9cc3e8e8 FetchContent: Disable header set verification for dependencies
The CMAKE_VERIFY_INTERFACE_HEADER_SETS variable is intended to
be under the control of the user. It doesn't discriminate between
header sets defined in the main project and those defined by
dependencies brought into the build directly via FetchContent.
Developers will usually only be interested in verifying the main project's
header sets, not those from dependencies.

Make the variable effectively only enable header set verification of the
main project by turning it off during FetchContent_MakeAvailable() calls.
The user still has variables like CMAKE_PROJECT_INCLUDE and
CMAKE_PROJECT_<projectName>_INCLUDE available to them if they
want to enable verification of all or specific dependencies respectively.

Fixes: #23808
2022-08-04 09:43:10 +10:00
Craig Scott
fd95769ccf FetchContent: Restore support for multiple URL values
In c2044fdf3f (FetchContent: Respect the CMP0135 policy setting,
2022-06-02), the URL keyword was wrongly assumed to only have
a single value. Multiple URL values are allowed if they are all
non-local. Rework the logic to remove that incorrect assumption
and handle both single and multi-value URL combinations.

Fixes: #23792
2022-07-29 20:58:08 +10:00
Craig Scott
5c7b6b29f9 FetchContent: Don't use if(... IN_LIST ...)
This avoids the need for changing policy settings, which would then
propagate through to projects brought into the build via FetchContent.
2022-06-29 07:54:06 +10:00
pigeon
641d97e03f FetchContent: Fix example code in documentation 2022-06-21 12:31:00 -04:00
Brad King
012eb49263 Merge topic 'fetchcontent-global-targets' into release-3.24
f19b48e0b8 FetchContent: Honor CMAKE_FIND_PACKAGE_TARGETS_GLOBAL
1305bade56 Help: Add missing version directive for find_package() GLOBAL keyword

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !7347
2022-06-11 06:13:57 -04:00
Craig Scott
f19b48e0b8 FetchContent: Honor CMAKE_FIND_PACKAGE_TARGETS_GLOBAL
Fixes: #23606
2022-06-10 21:49:38 +10:00
Craig Scott
92e93f5c9e Help: Overhaul and expand the Using Dependencies Guide
The guide previously only focused on the find_package() command,
with a bias towards libraries. FetchContent was not mentioned at all.
Reorganise and update the existing content. Add new sections to cover
providing dependencies with FetchContent and dependency providers.
Improve discoverability of the guide by mentioning it at the beginning
of the find_package(), FetchContent and dependency provider docs.
2022-06-09 22:55:11 +10:00
Craig Scott
c2044fdf3f FetchContent: Respect the CMP0135 policy setting
Fixes: #23560
2022-06-02 11:10:27 +10:00
Brad King
5dcf505f63 Merge topic 'dependency-providers'
2aa83fa15b Dependency providers: Add find_package and FetchContent support
8a28368feb FetchContent: Don't discard non-empty SOURCE_DIR and BINARY_DIR
8ce9bb8a0c FetchContent: Don't leak internal variables
74a6ddc339 cmFindPackageCommand: Handle Makefile variable definitions more robustly

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Gerhard Olsson <gerhard.nospam@gmail.com>
Merge-request: !7276
2022-05-25 07:24:48 -04:00
Craig Scott
2aa83fa15b Dependency providers: Add find_package and FetchContent support
Fixes: #22619
2022-05-25 08:46:18 +10:00
Craig Scott
8a28368feb FetchContent: Don't discard non-empty SOURCE_DIR and BINARY_DIR 2022-05-18 23:28:10 +10:00
Craig Scott
8ce9bb8a0c FetchContent: Don't leak internal variables 2022-05-18 23:25:42 +10:00
Craig Scott
82f3ceb26b FetchContent: Use Debug rather than Release for sub-build
The config used can be part of the path to the sub-build. On some
platforms, there are restrictions on the length of paths or file names.
Use Debug rather than Release because the former is shorter.
When CMAKE_CONFIGURATION_TYPES is left at its default, this also
makes the path the same as the previous default before 10865c8e5f
(FetchContent: Hard-code a config for the sub-build, 2022-05-01) .
2022-05-17 14:42:31 +10:00
Craig Scott
7a390edefb Merge topic 'fetchcontent-subbuild-config-type'
10865c8e5f FetchContent: Hard-code a config for the sub-build

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !7228
2022-05-16 07:33:35 -04:00