Merge topic 'externalproject_download_dir'

b8b87489 ExternalProject: Support substituting <DOWNLOAD_DIR>

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1537
This commit is contained in:
Brad King
2017-12-07 13:14:27 +00:00
committed by Kitware Robot
5 changed files with 69 additions and 10 deletions

View File

@@ -0,0 +1,5 @@
ExternalProject
---------------
* The :module:`ExternalProject` module learnt to substitute ``<DOWNLOAD_DIR>``
in comments, commands, working directory and byproducts.

View File

@@ -714,8 +714,9 @@ control needed to implement such step-level capabilities.
The command line, comment, working directory and byproducts of every
standard and custom step are processed to replace the tokens
``<SOURCE_DIR>``, ``<SOURCE_SUBDIR>``, ``<BINARY_DIR>``, ``<INSTALL_DIR>``
and ``<TMP_DIR>`` with their corresponding property values defined in the
original call to :command:`ExternalProject_Add`.
``<TMP_DIR>``, ``<DOWNLOAD_DIR>`` and ``<DOWNLOADED_FILE>`` with their
corresponding property values defined in the original call to
:command:`ExternalProject_Add`.
.. command:: ExternalProject_Add_StepTargets
@@ -1665,7 +1666,7 @@ macro(_ep_replace_location_tags target_name)
set(vars ${ARGN})
foreach(var ${vars})
if(${var})
foreach(dir SOURCE_DIR SOURCE_SUBDIR BINARY_DIR INSTALL_DIR TMP_DIR DOWNLOADED_FILE)
foreach(dir SOURCE_DIR SOURCE_SUBDIR BINARY_DIR INSTALL_DIR TMP_DIR DOWNLOAD_DIR DOWNLOADED_FILE)
get_property(val TARGET ${target_name} PROPERTY _EP_${dir})
string(REPLACE "<${dir}>" "${val}" ${var} "${${var}}")
endforeach()

View File

@@ -15,10 +15,31 @@ run_cmake(UsesTerminal)
# Run both cmake and build steps. We always do a clean before the
# build to ensure that the download step re-runs each time.
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/MultiCommand-build)
set(RunCMake_TEST_NO_CLEAN 1)
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
run_cmake(MultiCommand)
run_cmake_command(MultiCommand-clean ${CMAKE_COMMAND} --build . --target clean)
run_cmake_command(MultiCommand-build ${CMAKE_COMMAND} --build .)
function(__ep_test_with_build testName)
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${testName}-build)
set(RunCMake_TEST_NO_CLEAN 1)
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
run_cmake(${testName})
run_cmake_command(${testName}-clean ${CMAKE_COMMAND} --build . --target clean)
run_cmake_command(${testName}-build ${CMAKE_COMMAND} --build .)
endfunction()
__ep_test_with_build(MultiCommand)
# We can't test the substitution when using the old MSYS due to
# make/sh mangling the paths (substitution is performed correctly,
# but the mangling means we can't reliably test the output).
# There is no such issue when using the newer MSYS though. Therefore,
# we need to bypass the substitution test if using old MSYS.
# See merge request 1537 for discussion.
set(doSubstitutionTest YES)
if(RunCMake_GENERATOR STREQUAL "MSYS Makefiles")
execute_process(COMMAND uname OUTPUT_VARIABLE uname)
if(uname MATCHES "^MINGW32_NT")
set(doSubstitutionTest NO)
endif()
endif()
if(doSubstitutionTest)
__ep_test_with_build(Substitutions)
endif()

View File

@@ -0,0 +1,7 @@
.*Download dir = .*/xxxx_dwn
.*Download file = .*/zzzz_tmp.txt
.*Source dir = .*/xxxx_src
.*Source subdir = /yyyy_subdir
.*Binary dir = .*/xxxx_bin
.*Install dir = .*/xxxx_install
.*Tmp dir = .*/xxxx_tmp

View File

@@ -0,0 +1,25 @@
include(ExternalProject)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/zzzz_tmp.txt "Dummy file")
file(MD5 ${CMAKE_CURRENT_BINARY_DIR}/zzzz_tmp.txt md5hash)
ExternalProject_Add(Subst
URL file://${CMAKE_CURRENT_BINARY_DIR}/zzzz_tmp.txt
URL_HASH MD5=${md5hash}
DOWNLOAD_NO_EXTRACT ON
DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR}/xxxx_dwn
SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/xxxx_src
SOURCE_SUBDIR yyyy_subdir
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/xxxx_bin
INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/xxxx_install
TMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/xxxx_tmp
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E echo "Download dir = <DOWNLOAD_DIR>"
COMMAND ${CMAKE_COMMAND} -E echo "Download file = <DOWNLOADED_FILE>"
COMMAND ${CMAKE_COMMAND} -E echo "Source dir = <SOURCE_DIR>"
COMMAND ${CMAKE_COMMAND} -E echo "Source subdir = <SOURCE_SUBDIR>"
COMMAND ${CMAKE_COMMAND} -E echo "Binary dir = <BINARY_DIR>"
COMMAND ${CMAKE_COMMAND} -E echo "Install dir = <INSTALL_DIR>"
COMMAND ${CMAKE_COMMAND} -E echo "Tmp dir = <TMP_DIR>"
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
)