Commit Graph

12 Commits

Author SHA1 Message Date
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
51595e5f01 FetchContent: Relative SOURCE_DIR override cannot be a hard error
Fixes: #21624
2020-12-22 11:09:18 +11: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
Craig Scott
8dca6bd04b FetchContent: Preserve empty string arguments
Fixes: #20579
2020-05-23 23:42:43 +10:00
Craig Scott
0331092ce6 FetchContent: Add support for DOWNLOAD_NO_EXTRACT
Fixes: #20526
2020-04-03 22:05:55 +11:00
Craig Scott
a94355c7b7 FetchContent: Add new command FetchContent_MakeAvailable()
Relates: #18754
2019-01-26 16:49:15 +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
Craig Scott
1e56634faa FetchContent: Add tests 2017-10-17 08:10:19 +11:00