Commit Graph

47 Commits

Author SHA1 Message Date
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
Craig Scott
10865c8e5f FetchContent: Hard-code a config for the sub-build
If the main project overrides CMAKE_CONFIGURATION_TYPES such
that there is no Debug configuration, some multi-config generators
can fail because they might assume Debug by default (Visual Studio
might do this). Always specify the configuration for multi-config
generators so that we don't rely on any such defaults.

Fixes: #23177
2022-05-13 15:56:17 +10:00
Craig Scott
29e31e2825 Packages: Integrate FetchContent and find_package()
Allow FetchContent_MakeAvailable() to try a call to
find_package() first, or redirect a find_package() call to
FetchContent_MakeAvailable(). The user can set variables
to control which of these are allowed or tried by default.

Fixes: #21687
2022-05-03 16:48:11 +10:00
Craig Scott
cbb87e0a2c ExternalProject: Add support for USES_TERMINAL_PATCH keyword
This brings the patch step into line with all the others which already
had their own `USES_TERMINAL_<step>` keyword. All steps (including
patch) already have their own `LOG_<step>` keyword too, so the lack of
`USES_TERMINAL_PATCH` was inconsistent.
2022-02-03 09:27:35 -05:00
Jukka Aho
ed9ac756e8 FetchContent: Fix typo in documentation 2021-12-15 16:45:27 +02:00
Craig Scott
1851aa49be FetchContent: Pass through networking-related CMAKE_... variables
CMAKE_TLS_VERIFY, CMAKE_TLS_CAINFO, CMAKE_NETRC and
CMAKE_NETRC_FILE are now passed through to the underlying
ExternalProject sub-build. Previously, they were silently ignored.

Fixes: #22144
2021-10-05 23:41:34 +11:00
Craig Scott
e802193a34 Help: Rework docs to prioritize FetchContent_MakeAvailable()
FetchContent_MakeAvailable() should be strongly preferred over
the direct use of FetchContent_Populate(). The latter was the only
method available before CMake 3.14, but the former is simpler and
offers more functionality. Restructure the docs and improve the
wording to steer the reader toward `FetchContent_MakeAvailable()`
as the preferred approach.

Also take the opportunity to pull out the variables that influence
behavior into their own section. They were easily missed when
buried in the docs for the FetchContent_Populate() command.
2021-08-23 21:47:03 +10:00
Arcturus Arcturus
5d32ce320b FetchContent: Use private local variables in FetchContent_MakeAvailable 2021-05-13 13:52:16 +01:00
Josef Angstenberger
15cc39ed7f Modules: Fix typos and spelling in documentation 2021-05-07 17:00:16 +02:00
Josef Angstenberger
dad5b9d845 Modules: Fix typos and spelling in comments 2021-05-07 17:00:15 +02:00
Brad King
03193a9e9a Merge topic 'ep-fc-revert-refactoring'
57d442e182 Revert ExternalProject and FetchContent refactoring

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5898
2021-03-10 11:37:15 -05:00
Craig Scott
57d442e182 Revert ExternalProject and FetchContent refactoring
Refactoring of the ExternalProject and FetchContent modules moved
the commands into CMake scripts. This broke custom commands that
used shell redirection or special build tool variables of the form
$(MakeVar). Undo the sequence of commits that performed this
refactoring and follow-up fixes associated with it.

The following commits are reverted by this change:

4f3d1abbb4 (ExternalProject: Refactor pre-configure steps to support
no-target uses, 2021-02-05)

17e5516e60 (FetchContent: Invoke steps directly and avoid a separate
sub-build, 2021-01-29)

bd876f3849 (FetchContent: Restore patch command support,
2021-02-18)

404cddb7bb (ExternalProject: Fix misuse of IS_NEWER_THAN in
timestamp checks, 2021-02-21)

b0da671243 (FetchContent: Don't update timestamps if files don't
change, 2021-02-18)

Fixes: #21892
2021-03-10 09:07:44 +11:00
Harmen Stoppels
24b467c043 Help: Prefer commit hashes in FetchContent examples for security reasons
Fixes: #21841
Co-Authored-By: Craig Scott <craig.scott@crascit.com>
2021-02-25 21:14:15 +11:00
Craig Scott
ebcb8896e3 Help: Add missing MD5= for URL_HASH in FetchContent example
Fixes: #21859
2021-02-25 21:14:15 +11:00
Craig Scott
17e5516e60 FetchContent: Invoke steps directly and avoid a separate sub-build
The cost of setting up and executing a separate sub-build to do the
download, update and patch steps required for FetchContent population
can be significant with some platforms and CMake generators. Avoid the
sub-build altogether by invoking the step scripts directly.

Previously, if no generator was set (e.g. population was being done in
script mode), a generator needed to be available on the default PATH.
Since we no longer use a sub-build, this restriction is also now gone.

Fixes: #21703
2021-02-05 07:33:38 +11:00
Craig Scott
315a200f0c FindGit: Cache the GIT_EXECUTABLE version for the current run
The git version should not change while CMake is running. When
using FetchContent with many dependencies, the repeated calls
to get the git version every time ExternalProject is used can be
measurable on some platforms. This commit queries that version
only once and then caches it in a global property for the rest of that
run. The git version can still safely change between runs because it
is not cached, only the GIT_EXECUTABLE location is cached.

Relates: #21703
2021-01-20 10:16:21 +11:00
Craig Scott
88eefaac04 Merge topic 'fc-relative-SOURCE_DIR'
51595e5f01 FetchContent: Relative SOURCE_DIR override cannot be a hard error

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5641
2020-12-22 15:49:37 -05:00
Craig Scott
51595e5f01 FetchContent: Relative SOURCE_DIR override cannot be a hard error
Fixes: #21624
2020-12-22 11:09:18 +11:00
Nikita Nemkin
8fea95319b Help: Add .. versionadded directives to module docs
Issue: #19715
2020-12-02 21:00:30 +05:00
Craig Scott
b030a6af88 FetchContent: Raise error if manually given source dir does not exist
Fixes: #21208
2020-10-03 18:46:08 +10:00
Craig Scott
b972e25276 FetchContent: Fix SOURCE_DIR, BUILD_DIR when disconnected or overridden
Fixes: #21123
2020-08-23 18:38:47 +10:00
Kitware Robot
496ec6036f Help: Add Sphinx 'versionadded' directives to each top-level document
Run the `Utilities/Sphinx/update_versions.py` script to add initial
markup to every top-level document and find module.

Issue: #19715
2020-07-06 10:23:20 -04:00
Craig Scott
1236590507 FetchContent: Pass through CMAKE_EP_GIT_REMOTE_UPDATE_STRATEGY if set
This was missed when the initial support was added in
commit 0aea435aa1 (ExternalProject: Provide choice of
git update strategies, 2020-02-12)
2020-05-29 12:10:32 -04:00
Craig Scott
8dca6bd04b FetchContent: Preserve empty string arguments
Fixes: #20579
2020-05-23 23:42:43 +10:00
Craig Scott
592085b94b FetchContent: Add support for SOURCE_SUBDIR
Fixes: #19875
2020-05-16 17:01:10 +10:00
Craig Scott
0331092ce6 FetchContent: Add support for DOWNLOAD_NO_EXTRACT
Fixes: #20526
2020-04-03 22:05:55 +11:00
Joachim Wuttke (o)
05e56b1897 Help: FetchContent, ExternalProject: Command sections -> subsections 2020-02-17 12:15:57 +01:00
Alex Turbov
24fdd51f45 Refactor: Replace CMAKE_CURRENT_LIST_DIR with CMAKE_CURRENT_FUNCTION_LIST_DIR
Some modules define an intermediate global scope visible variables
to access "resource" files from functions.
Now these variables could be eliminated.
2019-12-10 16:43:27 +02:00
Craig Scott
a94355c7b7 FetchContent: Add new command FetchContent_MakeAvailable()
Relates: #18754
2019-01-26 16:49:15 +11:00
Craig Scott
1a07e1b47d FetchContent: Trivial doc corrections 2019-01-20 17:21:51 +11:00
Craig Scott
2119c33b7e FetchContent: Give access to the terminal for download and update
A main scenario where this is needed is when a git operation
needs the password to a private key and asks for it on the
console. Without this change, such operations can appear to
hang indefinitely with no prompt if QUIET is in effect (which it
is by default).

Another scenario this addresses is when progress of a
download or update should be shown. Without this change,
all such progress is buffered with some generators and will
only be shown at the end, which defeats the purpose of logging
any progress to begin with.

Relates: #18238
2019-01-14 23:32:18 +11:00
Jean-Christophe Fillion-Robin
b551beb6fa FetchContent: Support use of the module before "project()" command
Co-authored-by: Craig Scott <craig.scott@crascit.com>
Co-authored-by: Brad King <brad.king@kitware.com>
2017-11-07 09:50:02 -05:00
Craig Scott
60e74d2f19 FetchContent: New module for populating content at configure time 2017-10-17 08:07:09 +11:00