Commit Graph

37 Commits

Author SHA1 Message Date
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
Brad King
1bdaad7573 ExternalProject: Optionally integrate 'make' job server with INSTALL_COMMAND
Add an `INSTALL_JOB_SERVER_AWARE` option to `ExternalProject_Add`.
When using an explicit `INSTALL_COMMAND`, the generated commands
won't use `$(MAKE)` thus failing to connect to the outer make's
job server.  Add an option enable explicit job server integration.

This is the install step's equivalent to the build step's
`BUILD_JOB_SERVER_AWARE` option added by commit bc43398e72
(ExternalProject: Enable Make Job Server with Explicit Build Command,
2023-08-09, v3.28.0-rc1~217^2).  It is useful when the external
project's installation is driven by its build system.  Note that with
Makefile generators, our default install command does use `$(MAKE)` to
connect to the outer make's job server.

Issue: #26398
2024-11-19 10:22:24 -05:00
Brad King
55778f5a16 ExternalProject: Enable all policies in internal scripts 2024-10-03 10:23:37 -04:00
Craig Scott
012d116260 Merge topic 'cmp0168-populate-nondeclare-regression'
cbb727ca6b FetchContent: Don't update verify script timestamp if it doesn't change
795e7b44f2 Help: file(CONFIGURE) only updates output file timestamp if it changes

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !9799
2024-09-08 18:32:40 -04:00
Craig Scott
cbb727ca6b
FetchContent: Don't update verify script timestamp if it doesn't change
Fixes: #26255
2024-09-06 15:53:48 +10:00
Craig Scott
31609421f2 Merge topic 'fetchcontent-updates-disconnected'
5df592ce31 FetchContent: Ensure can_fetch_default is set early enough
c233c51cb9 ExternalProject: Fix bad indenting for uses_terminal

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Acked-by: Silver Zachara <silver.zachara@gmail.com>
Merge-request: !9685
2024-07-27 18:28:19 -04:00
Craig Scott
5df592ce31
FetchContent: Ensure can_fetch_default is set early enough
The can_fetch_default variable needs to be set before the call to
_ep_write_gitupdate_script(). Move it to before that call and always
set the variable, even if arg_SCRIPT_FILE is not set. This makes the
generated git update script file easier to follow if someone tries to
follow what it is doing or wants to investigate problems and run it
manually.

Fixes: #26164
2024-07-26 11:23:58 +10:00
Craig Scott
c233c51cb9
ExternalProject: Fix bad indenting for uses_terminal 2024-07-26 10:58:19 +10:00
Brad King
777d5d6a81 Merge topic 'ep-svn-user-pass'
7e80415e79 ExternalProject: Reduce number of local variables for svn logic
e16f65be15 ExternalProject: Don't add SVN auth args if not set

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !9678
2024-07-23 09:53:28 -04:00
Craig Scott
cd379332c3
ExternalProject: Don't rely on *_disconnected vars being unset by caller 2024-07-20 12:30:50 +10:00
Craig Scott
7e80415e79
ExternalProject: Reduce number of local variables for svn logic
We still keep the svn_trust_cert and uses_terminal variables because they
improve the readability of if() conditions.
2024-07-20 12:19:17 +10:00
Craig Scott
e16f65be15
ExternalProject: Don't add SVN auth args if not set
In 462e583267 (ExternalProject: Switch download, update and patch to
use _EP_ vars, 2024-05-13), the svn_username and svn_password variables
were only updated appropriately in the svn download implementation, but
not in the svn update implementation. This was easily missed in part
because the old implementation was relying on behavior that differed
from the documentation for get_property(), and the new implementation
tried to keep the intermediate variables from the old implementation but
missed this subtle aspect.

Issue: #26152
Fixes: #26148
2024-07-20 11:58:33 +10:00
Craig Scott
8c878b2d2e
FetchContent: Fix command echo for DEBUG and TRACE log levels
Fixes: #26111
2024-07-04 21:10:34 +10:00
Craig Scott
a02eec4a9f
FetchContent,ExternalProject: Fix extra semicolons in step commands
The extra semicolons weren't ultimately causing any errors when
running the step commands, but they shouldn't be there.
2024-06-07 16:58:08 +10: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
Craig Scott
7bf15e49a8
ExternalProject: Fix misleading git update output
When re-running the build with the git download method,
and where GIT_TAG is set to a tag name that we already have
locally from the first run, the second run will skip the update
step if it is already at the requested tag. The message in this
case was previously printing the commit hash instead of the
tag name, which was wrong. This wasn't noticed before
because that output wasn't usually shown, but we now do
show that message after making message output log levels
more consistent between the steps.
2024-05-17 14:23:39 +10:00
Craig Scott
b2496bf14c
FetchContent: Populate directly without a sub-build
Fixes: #21703
2024-05-17 14:23:39 +10:00
Craig Scott
173daad58d
ExternalProject: Move more internal commands out of main file
The commands moved to shared_internal_commands.cmake
will soon be used directly by FetchContent, which cannot
always include the full ExternalProject.cmake file (e.g. it may
be used in CMake script mode).

Issue: #21703
2024-05-13 20:24:47 +10:00
xavisolesoft
6f77077feb ExternalProject: Retry download for error code 35
This error code indicates a TLS handshake failure, which we've
observed intermittently when downloading artifacts from GitHub.
2024-04-25 13:08:24 -04: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
54cb65b197
ExternalProject: Prevent URL list-splitting on special characters
If a URL contains special characters like parentheses and a few others,
they would previously have caused a foreach() call that iterates over the
URLs to parse those special characters as separate, unquoted arguments.
They would then have effectively split the list of URLs at unexpected places.
Prepare the arguments for the foreach() call by using use bracket syntax
to robustly handle any URLs that do have unescaped special characters.

Issue: #25148
2024-01-28 09:24:37 +11:00
Craig Scott
aab6be9aad
ExternalProject: Catch empty REMOTE or LOCAL earlier
If we are given an empty string for URL, or we have a logic error that leads
to the file we download to being an empty string, we will now catch this at
CMake configure time instead of whenever the download is attempted at
build time.
2024-01-27 11:44:01 +11:00
Craig Scott
dcbc36572f
ExternalProject: Respect TLS_VERIFY for git update step
Git config options can be passed to git clone before or after the
"clone" keyword. If specified before, the config setting is only
applied to that command invocation. It acts to override the value
in the global or project defaults (the latter doesn't exist for clone).
When the config setting is passed after the "clone" keyword, it is
saved into the cloned repository's config and will persist for later
git operations. The existing implementation expected the latter
behavior, but put the config setting before the "clone" keyword
and therefore the setting was not persisting to the git update
step. Move it to after the "clone" keyword so that it will persist.

The submodule handling is different. There is no support for
doing a "git submodule update" with a "sticky" config setting.
Instead, you have to pass the setting with all such calls. The
existing implementation was doing this for the clone step, but
not the git update step. Add the config setting there as well
so that submodules also effectively have the sslVerify setting
persist to the update step too.

Fixes: #18948
2023-06-01 10:27:07 +10: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
Greg Thain
296d2bef06 ExternalProject: Also retry curl download on timeout error
Since commit f24e34975a (ExternalProject: retry download on recoverable
errors, 2020-08-08, v3.19.0-rc1~298^2~1) ExternalProject has a list of
curl errors which trigger a retry today: 6, 7, 8 and 15.

Add curl error 28.  It is a "timeout error", and should also trigger a
retry attempt at a download of an external project.  The complete list
of curl errors is https://curl.se/libcurl/c/libcurl-errors.html
2023-03-01 09:31:04 -05:00
Patrick Stewart
e07039cd26 ExternalProject: Explicitly run Git commands on intended directory
Add `--git-dir=.git` to cause git commands to fail instantly if the
`.git` folder has gone missing.

Fixes: #24007
2022-09-30 07:31:49 -04:00
Brad King
7b622f3e80 ExternalProject: Fix regression in stamp creation for Xcode+iOS
The change to `_ep_add_mkdir_command` in commit 5fbac2bb24
(ExternalProject: Move inline scripts to separate files, 2022-01-22,
v3.23.0-rc1~101^2) did not account for the possibility that
`CMAKE_CFG_INTDIR` is `$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)`
instead of just the configuration name.  Pass the value into the helper
script on the command line so that the native buildsystem placeholders
are evaluated.

Fixes: #23645
2022-06-21 18:26:22 -04:00
Kasper Laudrup
a283e58b51 ExternalProject: Add DOWNLOAD_EXTRACT_TIMESTAMP option and policy
Add the option to keep the current filestamps when extracting an
archive in ExternalProject_Add.

Enabling this option makes the behavior consistent with how
ExternalProject_Add is used when checking out code from revision
control instead of an archive.

Fixes: #22746
2022-05-05 09:01:54 +10:00
Craig Scott
dec997f04e ExternalProject: Remove extra quotes in for-each-ref update step
The --format=... argument to git for-each-ref was using a stray pair
of single quotes around the format string. These were then part of
the output, which caused it to never match the checkout_name.
The end result was that a REBASE_CHECKOUT always became a
CHECKOUT in all scenarios.

Fixes: #23216
2022-02-21 18:28:46 +11:00
Craig Scott
d3477eba06 ExternalProject: Rerun download on SOURCE_DIR change
Fixes: #21748
2022-02-01 22:31:29 +11:00
Craig Scott
5fbac2bb24 ExternalProject: Move inline scripts to separate files
This makes the scripts easier to work on, since the separate files
don't require the extra level of escaping that the inlined code did.
This also means the scripts can be rendered with appropriate
syntax highlighting in IDEs, etc.
2022-01-22 23:00:26 +11:00
Craig Scott
036517fe0b ExternalProject: Move existing step scripts to separate subdirectory
This is in preparation for moving more inline content to separate
scripts as well. Having them in a separate subdirectory is consistent
with other modules and will make them easier to find and work with.
2022-01-22 16:24:16 +11: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
Craig Scott
404cddb7bb ExternalProject: Fix misuse of IS_NEWER_THAN in timestamp checks
When using a file system which only has second resolution timestamps,
there is a reasonably high likelihood of timestamps being the same.
The IS_NEWER_THAN test returns true when timestamps are the same,
so don't redo downloads when they match exactly.
2021-02-22 11:02:20 -05: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
4f3d1abbb4 ExternalProject: Refactor pre-configure steps to support no-target uses
The mkdir, download, update and patch steps are used by
FetchContent during the configure phase of the main build. Because
these steps need a target, this has so far required a sub-build to be
set up. The changes here factor out the preparation of the scripts
from the creation of the targets, allowing future work to leverage these
steps without a sub-build (see #21703).

As part of the refactoring, some rationalisation of the stamp files,
repository info files and script names was done to make things more
consistent between download methods and step implementations.
Every download method now records its own specific repository info
in a file and that file is a dependency of the download step. The source
directory is also written to that file, so if the SOURCE_DIR changes, the
download will be retriggered (the existing implementation fails in this
scenario). Each download method now also has just one driver script
that implements the whole step (it may pull in other scripts to do its
task though). The patch step gained support for USES_TERMINAL as
a result of generalising the implementation for custom commands.

Fixes: #21748
2021-02-05 07:33:38 +11:00