summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorCraig Scott <craig.scott@crascit.com>2017-11-29 21:32:26 (GMT)
committerCraig Scott <craig.scott@crascit.com>2017-12-06 20:22:02 (GMT)
commitb8b87489770bd29ffcfc4b2faec3f98bd089f3ff (patch)
tree661f6bf94c784e92ac610febe9ec7e6331192cc4 /Tests
parentb311b8751819ec881824c61ef8de03387ff40c3f (diff)
downloadCMake-b8b87489770bd29ffcfc4b2faec3f98bd089f3ff.zip
CMake-b8b87489770bd29ffcfc4b2faec3f98bd089f3ff.tar.gz
CMake-b8b87489770bd29ffcfc4b2faec3f98bd089f3ff.tar.bz2
ExternalProject: Support substituting <DOWNLOAD_DIR>
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/ExternalProject/RunCMakeTest.cmake35
-rw-r--r--Tests/RunCMake/ExternalProject/Substitutions-build-stdout.txt7
-rw-r--r--Tests/RunCMake/ExternalProject/Substitutions.cmake25
3 files changed, 60 insertions, 7 deletions
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 ""
+)