Commit Graph

365 Commits

Author SHA1 Message Date
Evan Wilde
e301cbffcc ExternalProject: Set environment variables
Add the ability to modify the environment of the various steps running
as part of an external project build. This specifically adds the ability
to set them on the configure , build , install, and test steps, as well
as exposing the `ENVIRONMENT_MODIFICATION` keyword arguments to
`ExternalProject_Add_Step`, allowing customization of the environment of
custom steps.

The values of the environment variable respect the `LIST_SEPARATOR`.

Fixes: #26963
2025-07-22 13:13:23 -04:00
Javier Martín
1cc85064ff ExternalProject: Remove explicit list of supported archive types
- Do not try to guess the flags to pass to "cmake -E tar" ("z" or not) based
  on the extension. It is not necessary, as the archive type is autodetected
  since we switched to libarchive.
- Add new tests for .tar.zst archives, which would fail without the change.

Fixes: #25062
2025-04-29 11:22:13 -04: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
Brad King
c283aafe62 CMP0057: Remove support for OLD behavior 2025-01-22 10:40:53 -05:00
Brad King
7a39d926e8 Merge topic 'remove-old-compatibility'
381c446ff7 VS: Remove support for appending a platform to the generator name
dc24d88062 Remove compatibility with CMake versions older than 3.1
90d814f024 CMP0054: Remove support for OLD behavior
292aaffb78 Source: Remove unused cmCommandArgument{Lexer,Parser}
1150fae89a CMP0053: Remove support for OLD behavior
f0b1ca4d70 CMP0052: Remove support for OLD behavior
e4fddc8e37 CMP0051: Remove support for OLD behavior

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10205
2025-01-21 09:43:10 -05:00
Brad King
90d814f024 CMP0054: Remove support for OLD behavior 2025-01-20 09:46:55 -05:00
Craig Scott
b1ff216656 ExternalProject: Preserve colons and semicolons in the path
The _ep_set_directories() function needs to ensure paths passed in
are in the expected CMake path form. The special character that
file(TO_CMAKE_PATH) interprets as a path separator must be
masked to prevent it splitting paths that contain that character
(semicolons on Windows, colons on other platforms).

Fixes: #26490
2025-01-19 22:43:59 +11:00
Brad King
bd176b430c Renumber post-3.31 development from 3.32 to 4.0
Issue: #26613
2025-01-16 09:18:21 -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
f5f80305ef ExternalProject: Ensure keywords requiring an argument have one
Issue: #21089
2024-08-30 15:19:58 +10:00
Craig Scott
2d653179dc Merge topic 'fetchcontent-direct'
7bf15e49a8 ExternalProject: Fix misleading git update output
b2496bf14c FetchContent: Populate directly without a sub-build
173daad58d ExternalProject: Move more internal commands out of main file
462e583267 ExternalProject: Switch download, update and patch to use _EP_ vars
0ccc8e340d ExternalProject: Provide ExternalProject_Add keywords through a macro
91e1015722 ExternalProject: Don't treat YES as a keyword
a1743ce1ef ExternalProject: Fix minor formatting error

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: scivision <michael@scivision.dev>
Merge-request: !9513
2024-05-18 05:05:03 -04:00
Brad King
26bbee30cc Merge topic 'ExternalProject-xcode-effective-platform'
0a3caf0878 ExternalProject: Restore support for Xcode with an effective platform

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !9517
2024-05-14 10:26:47 -04:00
Brad King
0a3caf0878 ExternalProject: Restore support for Xcode with an effective platform
Revert commit cabad8a37f (ExternalProject: Always use $<CONFIG> for
source files, 2023-02-02, v3.27.0-rc1~550^2~3) and restore
Xcode-specific behavior intentionally preserved by commit c111d440ce
(ExternalProject: Express per-config step stamp file paths using CONFIG
genex, 2022-06-08, v3.24.0-rc1~15^2).  Unfortunately we still do not
have a test case, so leave a comment to avoid reverting this.

Issue: #23645
Issue: #23652
2024-05-13 14:41:00 -04: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
Craig Scott
462e583267 ExternalProject: Switch download, update and patch to use _EP_ vars
This refactoring prepares for the download, update, and
patch steps being called directly from FetchContent instead
of always being in a sub-build. When there is no sub-build,
there will be no targets to read properties from. This commit
moves the information to _EP_... variables, which will always
be readable.

Issue: #21703
2024-05-13 20:24:47 +10:00
Craig Scott
0ccc8e340d ExternalProject: Provide ExternalProject_Add keywords through a macro
This allows things outside of ExternalProject to have access
to the list of supported keywords. This will be used by
FetchContent in an upcoming change.

Issue: #21703
2024-05-12 14:45:44 +10:00
Craig Scott
91e1015722 ExternalProject: Don't treat YES as a keyword
This ultimately won't change behavior, since YES should never be listed
in the "keywords" argument. The original code looks like a bug though,
since YES satisfies the criteria for being interpreted as a keyword, and
there is logic to short-circuit on TRUE and FALSE. Add YES to that
condition to avoid any potential confusion.
2024-05-12 14:45:43 +10:00
Craig Scott
a1743ce1ef ExternalProject: Fix minor formatting error 2024-05-12 14:45:43 +10:00
Brad King
0d250dd021 ExternalProject: Honor CMAKE_TLS_VERIFY environment variable
Issue: #23608
2024-03-30 09:22:05 -04:00
Brad King
e8404502b1 ExternalProject: Revise TLS_VERIFY wording to use TLS_VERSION pattern 2024-03-30 09:22:05 -04:00
Brad King
10def6c964 Merge topic 'ExternalProject-list-separator-docs-example'
5d33f41e23 ExternalProject: reword `LIST_SEPARATOR` to indicate what it *does*
611ffce98c ExternalProject: add an example of `LIST_SEPARATOR` usage

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !9376
2024-03-28 11:51:04 -04:00
Ben Boeckel
5d33f41e23 ExternalProject: reword LIST_SEPARATOR to indicate what it *does*
Also remove the (IMO) confusing suggestion to have ` ` as a separator as
it interferes with things like spaces in argument values (e.g., paths)
or generated arguments such as `-GUnix Makefiles`. The new example is
likely more common usage of the facility.
2024-03-28 10:36:31 -04:00
Ben Boeckel
611ffce98c ExternalProject: add an example of LIST_SEPARATOR usage 2024-03-28 10:36:31 -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
Brad King
f0a36b1a76 ExternalProject: Factor out helper to get NETRC options 2024-02-28 19:10:29 -05:00
Brad King
019960a52a ExternalProject: Factor out helper to get TLS_CAINFO option 2024-02-28 19:02:51 -05:00
Brad King
1afa6f359e ExternalProject: Factor out helper to get TLS_VERIFY option 2024-02-28 18:57:47 -05:00
Brad King
e39c37ab29 ExternalProject: Revise wording of TLS_VERIFY documentation 2024-02-28 09:41:01 -05:00
Brad King
fe5e6c27bd ExternalProject: Prepare for multiple git submodule config options 2024-02-28 09:33: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
e72791ecf6 ExternalProject: Update foreach() calls to use IN LISTS and IN ITEMS 2024-01-27 11:07:36 +11:00
Craig Scott
873b2ad2eb ExternalProject: Remove N^2 add_dependencies() calls
ExternalProject_Add_StepDependencies() contained a foreach() loop that
had another foreach() loop inside it iterating over the same set of values
(the dependencies). This resulted in add_dependencies() calls that added
the same dependencies to the step target N^2 times. A single call to
add_dependencies() with the list of dependencies provides the necessary
relationships without the N^2 behavior, and it removes the inner foreach()
loop.
2024-01-27 11:06:38 +11:00
Brad King
5dd4d3d4e3 Merge topic 'revert-ExternalProject-download-byproducts'
fd3c9876c6 ExternalProject: revert `BYPRODUCTS` for download outputs

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !9097
2024-01-04 11:35:11 -05:00
Ben Boeckel
fd3c9876c6 ExternalProject: revert BYPRODUCTS for download outputs
Xcode has been reported to not work at all with this when
ExternalProject projects share download files.

Revert commit 872daff159 (ExternalProject: declare byproducts for the
download step, 2023-09-21, v3.28.0-rc1~27^2) pending further
investigation.

Fixes: #25525
2024-01-03 14:18:35 -05:00
Brad King
cdd741ebf9 Merge branch 'backport-ci-fedora-39' into ci-fedora-39 2023-11-17 11:35:41 -05:00
Brad King
2744f14db1 codespell: Fix typos 2023-11-17 09:58:21 -05:00
William Sciaroni
6a81104413 FetchContent: Pass GHS Variables to subbuild
Fixes: #24244
2023-11-05 08:42:27 +11:00
William Sciaroni
9bac4bb88d ExternalProject: Fix INSTALL step for GHS generator
Fixes: #25267
2023-10-16 12:56:08 -05:00
Ben Boeckel
872daff159 ExternalProject: declare byproducts for the download step
This can surface a conflict where two projects download the same file
and get scheduled against each other.
2023-09-30 15:59:22 +10:00
Craig Scott
a1509658a0 ExternalProject: Ensure svn --trust-server-cert has dependent options
If the --trust-server-cert option is given to svn without the
--non-interactive option, the command fails with an error.
Previously, --non-interactive was always added, but
b1c2cb0436 (ExternalProject: Make SVN interactive with
USES_TERMINAL_{DOWNLOAD,UPDATE}, 2022-05-06) changed
the behavior to only add it if the relevant USES_TERMINAL_...
option was set to true.

Fixes: #25197
2023-08-21 09:23:02 +10:00
Chris Mahoney
bc43398e72 ExternalProject: Enable Make Job Server with Explicit Build Command
Introduces `BUILD_JOB_SERVER_AWARE` option to `ExternalProject_Add` and
`JOB_SERVER_AWARE` to `ExternalProject_Add_Step`. When using an explicit
`BUILD_COMMAND` or `COMMAND`, the generated commands won't use `$(MAKE)`
thus failing to connect to the outer make's job server. These new
options enable explicit job server integration.

Co-authored-by: Brad King <brad.king@kitware.com>

Fixes: #16273
2023-08-15 12:21:30 +00:00
scivision
c949a8742e ExternalProject: Add option subsection anchors for accessibility from TOC
Use RST subsections for each major step of `ExternalProject_Add()`.
This makes finding options easier with less scrolling.
For example, finding important Download vs. Test options etc.

Fixes: #25129
2023-07-31 11:21:10 -04: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
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
8fdce89f70 Help: Clarify default TLS_VERIFY behavior for git download method 2023-05-28 20:16:19 +10:00
Craig Scott
8cc45e150a ExternalProject: Make hg download method respect UPDATE_DISCONNECTED 2023-05-23 22:39:44 +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
Antonio Caggiano
3bf0830e44 ExternalProject: Avoid adding empty touch command on "ALWAYS" steps
The problem fixed by commit c0b749cf62 (ExternalProject: Always add a
command to a step, 2014-11-05, v3.2.0-rc1~402^2~3) may occur for an
empty `COMMAND ${touch}` too, so avoid specifying any `COMMAND` at all
if there is no touch command.
2023-05-10 09:56:31 -04:00