diff options
author | Brad King <brad.king@kitware.com> | 2017-12-07 13:14:27 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2017-12-07 13:14:34 (GMT) |
commit | e1a09cfbd1d1802b5fc4ae9b4918bb00ce468dcc (patch) | |
tree | 4c491fc06b058ce7c34b151eacf472fcc2c47a3b | |
parent | 79fde6a324545f6461020c957af1f63e5f2a72da (diff) | |
parent | b8b87489770bd29ffcfc4b2faec3f98bd089f3ff (diff) | |
download | CMake-e1a09cfbd1d1802b5fc4ae9b4918bb00ce468dcc.zip CMake-e1a09cfbd1d1802b5fc4ae9b4918bb00ce468dcc.tar.gz CMake-e1a09cfbd1d1802b5fc4ae9b4918bb00ce468dcc.tar.bz2 |
Merge topic 'externalproject_download_dir'
b8b87489 ExternalProject: Support substituting <DOWNLOAD_DIR>
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1537
-rw-r--r-- | Help/release/dev/ExternalProject-DOWNLOAD_DIR.rst | 5 | ||||
-rw-r--r-- | Modules/ExternalProject.cmake | 7 | ||||
-rw-r--r-- | Tests/RunCMake/ExternalProject/RunCMakeTest.cmake | 35 | ||||
-rw-r--r-- | Tests/RunCMake/ExternalProject/Substitutions-build-stdout.txt | 7 | ||||
-rw-r--r-- | Tests/RunCMake/ExternalProject/Substitutions.cmake | 25 |
5 files changed, 69 insertions, 10 deletions
diff --git a/Help/release/dev/ExternalProject-DOWNLOAD_DIR.rst b/Help/release/dev/ExternalProject-DOWNLOAD_DIR.rst new file mode 100644 index 0000000..823a14b --- /dev/null +++ b/Help/release/dev/ExternalProject-DOWNLOAD_DIR.rst @@ -0,0 +1,5 @@ +ExternalProject +--------------- + +* The :module:`ExternalProject` module learnt to substitute ``<DOWNLOAD_DIR>`` + in comments, commands, working directory and byproducts. diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 67aac4f..d284e27 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -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() diff --git a/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake b/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake index 994e2aa..09607f6 100644 --- a/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake +++ b/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake @@ -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() diff --git a/Tests/RunCMake/ExternalProject/Substitutions-build-stdout.txt b/Tests/RunCMake/ExternalProject/Substitutions-build-stdout.txt new file mode 100644 index 0000000..d6a823a --- /dev/null +++ b/Tests/RunCMake/ExternalProject/Substitutions-build-stdout.txt @@ -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 diff --git a/Tests/RunCMake/ExternalProject/Substitutions.cmake b/Tests/RunCMake/ExternalProject/Substitutions.cmake new file mode 100644 index 0000000..db79491 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/Substitutions.cmake @@ -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 "" +) |