Commit Graph

298 Commits

Author SHA1 Message Date
Craig Scott
b4db306aff ExternalProject: Remove unused property docs
BRIEF_DOCS and FULL_DOCS became optional as of edb5059216
(define_property(): Make BRIEF_DOCS and FULL_DOCS optional,
2022-01-18). Remove these options from the define_property()
calls, since they served no useful purpose. The canonical
documentation of those properties is in the RST docs at the top of
the file.
2022-05-23 07:36:15 +10:00
Craig Scott
5c021c8355 ExternalProject: Replace SEND_ERROR with FATAL_ERROR
The one remaining SEND_ERROR is still needed because further messages
must be written before a final FATAL_ERROR on that code path.
2022-05-23 07:36:04 +10:00
Michael Durso Jr
b1c2cb0436 ExternalProject: Make SVN interactive with USES_TERMINAL_{DOWNLOAD,UPDATE}
ExternalProject_Add() supports USES_TERMINAL_* flags to enable user
input for different steps.  The Subversion download options ignored
these flags when checking out or updated a Subversion repo.

Fixes: #23348
2022-05-12 10:40:35 -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
Brad King
bc1fd4b606 Merge topic 'doc-list-semicolons'
8abd714176 Help: Clarify that ENVIRONMENT test properties take ;-separated lists
02cf404ace Help: Add advice for dealing with semicolons in lists
c4117d9116 ExternalProject: Document that LIST_SEPARATOR works for CMAKE_ARGS too

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Ben Boeckel <ben.boeckel@kitware.com>
Merge-request: !7066
2022-03-16 11:14:59 -04:00
Brad King
c4117d9116 ExternalProject: Document that LIST_SEPARATOR works for CMAKE_ARGS too
Since `CMAKE_ARGS` is used to construct the default `CONFIGURE_COMMAND`
for CMake-based external projects, the `LIST_SEPARATOR` option works for
it too.
2022-03-11 11:15:53 -05:00
Craig Scott
704e87ee8c Help: Clarify behavior of REBASE_CHECKOUT when switching branches
Issue: #23216
2022-02-21 18:28:16 +11: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
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
8feaa41ee9 ExternalProject: Ensure _ep_set_directories records cmake paths 2022-01-22 17:36:39 +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
d73fc5dd2a ExternalProject: Fix misuse of IS_NEWER_THAN in timestamp checks
This change was originally made in 404cddb7bb (ExternalProject:
Fix misuse of IS_NEWER_THAN in timestamp checks, 2021-02-21),
but was reverted by 57d442e182 (Revert ExternalProject and
FetchContent refactoring, 2021-03-10) due to regressions from
other changes. Reapply this fix on its own, since it is still valid.

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.
2022-01-08 20:51:44 +11:00
Felix Lelchuk
3caeee0c86 Help: Clarify CMAKE_INSTALL_MODE documentation
Fixes: #22869
Co-Authored-By: Craig Scott <craig.scott@crascit.com>
2021-11-24 08:30:38 +11:00
Craig Scott
2a82bd85b6 Help: Add documentation for CMAKE_TLS_CAINFO 2021-10-04 21:48:00 +11:00
Brad King
bd0ccb73f2 Merge topic 'git-config-version-check'
8a9753e427 ExternalProject: Only add git config setting with git 1.7.7 or later

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6145
2021-05-21 10:36:56 -04:00
Craig Scott
8a9753e427 ExternalProject: Only add git config setting with git 1.7.7 or later
1cb65e680d (ExternalProject: Prevent the noisy detached head
messages on checkout, 2021-01-17) unconditionally added the advice.detachedHead
git config setting, but it requires git 1.7.7 or later. Since it isn't fatal to not
have it, just noisier, only add it when it is supported.

Fixes: #22206
2021-05-20 22:39:04 +10:00
Craig Scott
cf3bc271d1 Help: Clarify details passed to ExternalProject configure and build
Fixes: #22116
2021-05-16 20:28:00 +10:00
Michael Hirsch
7398993f5b Help: Document CMAKE_TLS_VERIFY variable explicitly
Previously it was mentioned only in the `file` and `ExternalProject`
documentation.
2021-05-04 12:29:13 -04: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
b0da671243 FetchContent: Don't update timestamps if files don't change
The refactoring in 17e5516e60 (FetchContent: Invoke steps directly and
avoid a separate sub-build, 2021-01-29) uses a different way of writing
out the step scripts and updating time stamps when steps are executed.
That inadvertently always wrote out the scripts for custom commands,
even when the contents didn't change. This caused their timestamp to
always be updated, resulting in those steps always being seen as
out-of-date and needing to be re-executed.

The way timestamps were checked to determine whether to re-execute
a step also did not adequately account for file systems which only have
second-resolution timestamps. The IS_NEWER_THAN if condition also
returns true when timestamps are the same, so one needs to use the
negative form to get a true "is newer than" test.

ExternalProject is not susceptible to this problem because it uses
file(GENERATE) to write out the script files and that only updates the file's
timestamp if the contents change. It also mostly leaves timestamp
checking to the build tool.
2021-02-22 11:02:20 -05:00
Craig Scott
bd876f3849 FetchContent: Restore patch command support
The refactoring in 17e5516e60 (FetchContent: Invoke steps directly and
avoid a separate sub-build, 2021-01-29) contained a typo which resulted
in any PATCH_COMMAND being ignored. Fix the typo and add a test case
that would have caught the regression.
2021-02-18 09:40:39 +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
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
Craig Scott
23aab9ecce ExternalProject: Avoid scanning docs for keywords, use include_guard()
The previous implementation was scanning the documentation in
the file at runtime to determine the set of supported keywords for
each public function. This was fragile, made it difficult to restructure
the documentation and was sometimes observable in runtime
performance measurements. Change to a more conventional
approach where supported keywords are explicitly listed in the
code.

The internal _ExternalProject_SELF variable is no longer needed.
CMake now provides CMAKE_CURRENT_FUNCTION_LIST_DIR which
can be used for the same purpose and avoids having to set a
variable when the module is read. This also removes the
requirement that the module must be included by the current or a
parent scope. It is now enough that the module has been included
once somewhere before calling any of its functions. 

The above changes combined mean that the module can now use
include_guard() and avoid having to re-parse the very long file every
time.
2021-01-30 00:12:23 +11:00
Craig Scott
1cb65e680d ExternalProject: Prevent the noisy detached head messages on checkout
When checking out a specific commit by its git hash, git will output
a very noisy message about checking out a detached HEAD. This
is not particularly helpful for us here and makes the output overall
quite verbose. Add a git config setting to prevent it.
2021-01-28 09:32:35 -05:00
Brad King
c69567e56a Merge topic 'FindGit-cache-version'
76fdeb6d13 Tests: FindGit already provides the git version, re-use it
315a200f0c FindGit: Cache the GIT_EXECUTABLE version for the current run

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5712
2021-01-21 09:27:04 -05: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
ac4a8002a5 ExternalProject: Don't git stash ignored files
The change to the binary gitrepo.tgz file adds a commit which
adds a .gitignore file.

Fixes: #21278
2021-01-16 18:12:00 +11:00
Brad King
438ed46c13 Merge topic 'ExternalProject-configure-handled-by-build'
7155e358c9 ExternalProject: Add CONFIGURE_HANDLED_BY_BUILD option

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5626
2021-01-13 09:21:47 -05:00
Daan De Meyer
7155e358c9 ExternalProject: Add CONFIGURE_HANDLED_BY_BUILD option
Fixes #21592.
2021-01-12 08:50:02 +01:00
Daan De Meyer
850de767e9 ExternalProject: Silence step succeeded message when using Ninja
When doing an ExternalProject superbuild with all output logged to
files, the output currently looks as follows:

```
[652/904] Performing install step for 'plasma-framework'
-- plasma-framework install command succeeded.  See also /root/build/kde/frameworks/plasma-framework/log/plasma-framework-install-*.log
[658/904] Performing build step for 'khtml'
-- khtml build command succeeded.  See also /root/build/kde/frameworks/khtml/log/khtml-build-*.log
[659/904] Performing install step for 'khtml'
-- khtml install command succeeded.  See also /root/build/kde/frameworks/khtml/log/khtml-install-*.log
[661/904] Performing configure step for 'krunner'
-- krunner configure command succeeded.  See also /root/build/kde/frameworks/krunner/log/krunner-configure-*.log
[661/904] Performing build step for 'krunner'
```

More specifically, because a success line is printed for every
succeeded step, we lose the advantage of Ninja's progress bar
which will now also print a new line instead of updating the same
link as happens when using Ninja in a normal CMake project.

By silencing the success message when using the Ninja generator,
Ninja's progress bar works as expected and updates inline instead
of printing a new line for each progress update.

With this change, the above output is reduced to a single line
progress bar:

```
[661/904] Performing build step for 'krunner'
```
2020-12-17 17:32:57 +00:00
Nikita Nemkin
8fea95319b Help: Add .. versionadded directives to module docs
Issue: #19715
2020-12-02 21:00:30 +05:00
Brad King
b8ecd4df5f ExternalProject: Use CMP0114 NEW behavior with Xcode "new build system"
The ExternalProject module cannot be implemented in the Xcode "new build
system" without using CMP0114's NEW behavior.  When configuring for that
build system, warn if the policy is not set to NEW and use NEW behavior
anyway.
2020-09-18 13:46:45 -04:00
Brad King
b4fc4da903 ExternalProject: Add policy CMP0114 to refine step target dependencies
`ExternalProject_Add_StepTargets` and `INDEPENDENT_STEP_TARGETS` have
some limitations and lack some sanity checks.  They can cause confusing
build systems to be generated.  The basic problems are:

* The notion of step independence is attached to the step target
  rather than the step itself.

* The custom commands implementing the steps are duplicated in the
  step targets and the primary targets.  This can cause races.
  It is also incompatible with the Xcode "new build system".

Fix this by introducing policy CMP0114 to change the way step target
dependencies are handled.  Define independence from external
dependencies as a property of each individual step regardless of whether
there is a target for it.  Add dependencies among the primary target and
the step targets such that each custom command only appears in one
target.  When some steps are disconnected from the primary target, add
step targets for the steps commonly depended upon so that there is a
place to hold their custom commands uniquely.

Fixes: #18663
2020-09-14 10:48:16 -04:00
Brad King
b637ef494c ExternalProject: Factor out an internal helper to add a step target 2020-09-10 18:14:23 -04:00
Brad King
fed08ce4cf Merge topic 'ExternalProject-retry-only-recoverable'
116b06870d ExternalProject: add INACTIVITY_TIMEOUT argument
f24e34975a ExternalProject: retry download on recoverable errors

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5034
2020-08-19 11:47:34 -04:00
Craig Scott
715324742f ExternalProject: Stop configure target from always appearing out-of-date
When updates are disconnected, don't depend on skip-update because that
target is always considered out of date. Depend directly on the patch target
instead because it already depends on the appropriate target regardless of
whether updates are disconnected or not. This in turn means nothing depends
on the skip-update target, so it has also been removed.

Relates: #21086
2020-08-18 23:27:47 +10:00
Craig Scott
c0b7198ad9 ExternalProject: Stop patch target from always appearing out-of-date
The skip-update target is always considered out-of-date. The change in
7249ba9677 (ExternalProject: Enforce that patch depends on update, 2020-04-03)
made the patch target depend on skip-update, which in turn made it
always out of date too. The patch command should only be re-run if the download
needs to be performed again where updates are disconnected.

Fixes: #21086
2020-08-18 23:21:36 +10:00
Thomas Bernard
116b06870d ExternalProject: add INACTIVITY_TIMEOUT argument
In order to abort transfers on slow connections the ExternalProject
command support passing the INACTIVITY_TIMEOUT argument.

Fixes: #20992
2020-08-18 09:16:18 -04:00
Nate Avers
8dbefc3ca6 ExternalProject: omit --no-checkout from git clone when using git 2.20.x.
The optimization from commit 627fc5b44f (ExternalProject: Avoid
unnecessary checkout on clone, 2019-07-29, v3.16.0-rc1~325^2) triggers a
bug in the Git 2.20.x series that is not in older or newer versions.
Drop the optimization for that specific range of Git versions.

Fixes: #21009
2020-07-24 09:39:06 -04:00
Brad King
eb705b9531 Update links to gitlab.kitware.com repos to add -/
GitLab now uses a `/-/` component between the `group/project` part of
the URL and the `{issues,merge_requests,tree}` part so that it can
support `group/subgroup/project` with arbitrary depth.
2020-05-26 11:38:01 -04:00
Craig Scott
800e29ab8f Merge topic 'fetchcontent-externalproject-empty-args'
8dca6bd04b FetchContent: Preserve empty string arguments
cbf2daeed0 ExternalProject: Preserve empty string arguments

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4729
2020-05-25 17:20:48 -04:00
Craig Scott
cbf2daeed0 ExternalProject: Preserve empty string arguments 2020-05-23 23:41:53 +10:00
Craig Scott
0aea435aa1 ExternalProject: Provide choice of git update strategies
Fixes: #16528

Co-Authored-By: Michael Wake <macwake@gmail.com>
2020-05-23 22:27:38 +10:00
Craig Scott
ea410414c5 ExternalProject: factor out gitupdate step to separate file
The refactoring exposed that the original implementation
was referring to an undefined variable src_name, which was
previously only used in error messages. This has been fixed
as part of the refactoring work.

Fixes: #20336
2020-05-23 11:01:59 +10:00
Brad King
0d8aec412a Merge topic 'fix-cache-args-file-to-dep-list'
0199dd9f1b ExternalProject: expose _ep_cache_args_script to the caller

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4710
2020-05-13 12:12:28 -04:00
Ben Boeckel
0199dd9f1b ExternalProject: expose _ep_cache_args_script to the caller
This is needed so that the caller can add a dependency on the cache
file.

Fixes: #20668
2020-05-12 10:34:23 -04:00
Vyacheslav Yurkov
e5b33871ed ExternalProject: Fix step dependency on mkdir step
When looking at `list(FIND)` result, zero index is ignored due to
incorrect error handling, and users can't set dependencies on mkdir
step.

Fixes: #20605
2020-04-20 18:49:17 +02:00
Craig Scott
7249ba9677 ExternalProject: Enforce that patch depends on update
Fixes: #17229
2020-04-03 22:48:44 +11:00