diff options
author | Craig Scott <craig.scott@crascit.com> | 2021-01-29 12:22:45 (GMT) |
---|---|---|
committer | Craig Scott <craig.scott@crascit.com> | 2021-02-04 20:33:38 (GMT) |
commit | 17e5516e608ba5c9c1f2dfad3d64f8f90874f108 (patch) | |
tree | ae0f88a262c3734cda45ee1040aee303e131d13d /Modules/ExternalProject/extractfile.cmake.in | |
parent | 4f3d1abbb4dca3d1e6b019471fa5d8be296492e3 (diff) | |
download | CMake-17e5516e608ba5c9c1f2dfad3d64f8f90874f108.zip CMake-17e5516e608ba5c9c1f2dfad3d64f8f90874f108.tar.gz CMake-17e5516e608ba5c9c1f2dfad3d64f8f90874f108.tar.bz2 |
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
Diffstat (limited to 'Modules/ExternalProject/extractfile.cmake.in')
-rw-r--r-- | Modules/ExternalProject/extractfile.cmake.in | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/Modules/ExternalProject/extractfile.cmake.in b/Modules/ExternalProject/extractfile.cmake.in index d9e07f1..d46de73 100644 --- a/Modules/ExternalProject/extractfile.cmake.in +++ b/Modules/ExternalProject/extractfile.cmake.in @@ -3,17 +3,24 @@ cmake_minimum_required(VERSION 3.5) +set(quiet "@quiet@") +set(script_dir "@CMAKE_CURRENT_FUNCTION_LIST_DIR@/ExternalProject") +include(${script_dir}/captured_process_setup.cmake) + # Make file names absolute: # get_filename_component(filename "@filename@" ABSOLUTE) get_filename_component(directory "@directory@" ABSOLUTE) -message(STATUS "extracting... +_ep_message_quiet_capture(STATUS "extracting... src='${filename}' - dst='${directory}'") + dst='${directory}'" +) if(NOT EXISTS "${filename}") - message(FATAL_ERROR "File to extract does not exist: '${filename}'") + _ep_message_quiet_capture(FATAL_ERROR + "File to extract does not exist: '${filename}'" + ) endif() # Prepare a space for extracting: @@ -27,20 +34,23 @@ file(MAKE_DIRECTORY "${ut_dir}") # Extract it: # -message(STATUS "extracting... [tar @args@]") +_ep_message_quiet_capture(STATUS "extracting... [tar @args@]") execute_process(COMMAND ${CMAKE_COMMAND} -E tar @args@ ${filename} WORKING_DIRECTORY ${ut_dir} - RESULT_VARIABLE rv) + RESULT_VARIABLE rv + ${capture_output} +) +_ep_accumulate_captured_output() if(NOT rv EQUAL 0) - message(STATUS "extracting... [error clean up]") + _ep_message_quiet_capture(STATUS "extracting... [error clean up]") file(REMOVE_RECURSE "${ut_dir}") - message(FATAL_ERROR "Extract of '${filename}' failed") + _ep_message_quiet_capture(FATAL_ERROR "Extract of '${filename}' failed") endif() # Analyze what came out of the tar file: # -message(STATUS "extracting... [analysis]") +_ep_message_quiet_capture(STATUS "extracting... [analysis]") file(GLOB contents "${ut_dir}/*") list(REMOVE_ITEM contents "${ut_dir}/.DS_Store") list(LENGTH contents n) @@ -50,14 +60,14 @@ endif() # Move "the one" directory to the final directory: # -message(STATUS "extracting... [rename]") +_ep_message_quiet_capture(STATUS "extracting... [rename]") file(REMOVE_RECURSE ${directory}) get_filename_component(contents ${contents} ABSOLUTE) file(RENAME ${contents} ${directory}) # Clean up: # -message(STATUS "extracting... [clean up]") +_ep_message_quiet_capture(STATUS "extracting... [clean up]") file(REMOVE_RECURSE "${ut_dir}") -message(STATUS "extracting... done") +_ep_message_quiet_capture(STATUS "extracting... done") |