summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-08-04 15:28:53 (GMT)
committerBrad King <brad.king@kitware.com>2022-08-09 12:27:03 (GMT)
commitd9e88721ad22f47196dfcdd1e05d153d28536bc9 (patch)
treee1114d4a6d55beb1616028de05dc682bb60a58e6
parent365613d98b86ffadfa7137eeb6754dc3ac1443bb (diff)
downloadCMake-d9e88721ad22f47196dfcdd1e05d153d28536bc9.zip
CMake-d9e88721ad22f47196dfcdd1e05d153d28536bc9.tar.gz
CMake-d9e88721ad22f47196dfcdd1e05d153d28536bc9.tar.bz2
ExternalProject: Add test case for BUILD_ALWAYS
We did not previously have a dedicated explicit test for this option. Issue: #23820
-rw-r--r--Tests/RunCMake/ExternalProject/BUILD_ALWAYS-build1-stdout.txt6
-rw-r--r--Tests/RunCMake/ExternalProject/BUILD_ALWAYS-build2-stdout.txt2
-rw-r--r--Tests/RunCMake/ExternalProject/BUILD_ALWAYS.cmake17
-rw-r--r--Tests/RunCMake/ExternalProject/RunCMakeTest.cmake22
4 files changed, 47 insertions, 0 deletions
diff --git a/Tests/RunCMake/ExternalProject/BUILD_ALWAYS-build1-stdout.txt b/Tests/RunCMake/ExternalProject/BUILD_ALWAYS-build1-stdout.txt
new file mode 100644
index 0000000..2c223f7
--- /dev/null
+++ b/Tests/RunCMake/ExternalProject/BUILD_ALWAYS-build1-stdout.txt
@@ -0,0 +1,6 @@
+.*-- once: configure
+.*-- once: build
+.*-- once: install
+.*-- always: configure
+.*-- always: build
+.*-- always: install
diff --git a/Tests/RunCMake/ExternalProject/BUILD_ALWAYS-build2-stdout.txt b/Tests/RunCMake/ExternalProject/BUILD_ALWAYS-build2-stdout.txt
new file mode 100644
index 0000000..d697490
--- /dev/null
+++ b/Tests/RunCMake/ExternalProject/BUILD_ALWAYS-build2-stdout.txt
@@ -0,0 +1,2 @@
+.*-- always: build
+.*-- always: install
diff --git a/Tests/RunCMake/ExternalProject/BUILD_ALWAYS.cmake b/Tests/RunCMake/ExternalProject/BUILD_ALWAYS.cmake
new file mode 100644
index 0000000..fdd3ad9
--- /dev/null
+++ b/Tests/RunCMake/ExternalProject/BUILD_ALWAYS.cmake
@@ -0,0 +1,17 @@
+include(ExternalProject)
+
+ExternalProject_Add(once
+ DOWNLOAD_COMMAND ""
+ CONFIGURE_COMMAND "${CMAKE_COMMAND}" -P ${CMAKE_CURRENT_BINARY_DIR}/once-configure.cmake
+ BUILD_COMMAND "${CMAKE_COMMAND}" -P ${CMAKE_CURRENT_BINARY_DIR}/once-build.cmake
+ INSTALL_COMMAND "${CMAKE_COMMAND}" -P ${CMAKE_CURRENT_BINARY_DIR}/once-install.cmake
+ )
+
+ExternalProject_Add(always
+ DEPENDS once
+ DOWNLOAD_COMMAND ""
+ CONFIGURE_COMMAND "${CMAKE_COMMAND}" -P ${CMAKE_CURRENT_BINARY_DIR}/always-configure.cmake
+ BUILD_COMMAND "${CMAKE_COMMAND}" -P ${CMAKE_CURRENT_BINARY_DIR}/always-build.cmake
+ BUILD_ALWAYS 1
+ INSTALL_COMMAND "${CMAKE_COMMAND}" -P ${CMAKE_CURRENT_BINARY_DIR}/always-install.cmake
+ )
diff --git a/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake b/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake
index 2588d6c..f152f5b 100644
--- a/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake
+++ b/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake
@@ -177,6 +177,28 @@ if(doSubstitutionTest)
__ep_test_with_build(Substitutions)
endif()
+function(__ep_test_BUILD_ALWAYS)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/BUILD_ALWAYS-build)
+ run_cmake(BUILD_ALWAYS)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ file(WRITE "${RunCMake_TEST_BINARY_DIR}/once-configure.cmake" [[message(STATUS "once: configure")]])
+ file(WRITE "${RunCMake_TEST_BINARY_DIR}/once-build.cmake" [[message(STATUS "once: build")]])
+ file(WRITE "${RunCMake_TEST_BINARY_DIR}/once-install.cmake" [[message(STATUS "once: install")]])
+ file(WRITE "${RunCMake_TEST_BINARY_DIR}/always-configure.cmake" [[message(STATUS "always: configure")]])
+ file(WRITE "${RunCMake_TEST_BINARY_DIR}/always-build.cmake" [[message(STATUS "always: build")]])
+ file(WRITE "${RunCMake_TEST_BINARY_DIR}/always-install.cmake" [[message(STATUS "always: install")]])
+ run_cmake_command(BUILD_ALWAYS-build1 ${CMAKE_COMMAND} --build . --target always)
+ file(WRITE "${RunCMake_TEST_BINARY_DIR}/once-configure.cmake" [[message(FATAL_ERROR "once: configure should not run again")]])
+ file(WRITE "${RunCMake_TEST_BINARY_DIR}/once-build.cmake" [[message(FATAL_ERROR "once: build should not run again")]])
+ file(WRITE "${RunCMake_TEST_BINARY_DIR}/once-install.cmake" [[message(FATAL_ERROR "once: install should not run again")]])
+ if(NOT RunCMake_GENERATOR MATCHES "^(Xcode|Visual Studio 9 )")
+ # The Xcode and VS 9 build systems decide to run this every time.
+ file(WRITE "${RunCMake_TEST_BINARY_DIR}/always-configure.cmake" [[message(FATAL_ERROR "always: configure should not run again")]])
+ endif()
+ run_cmake_command(BUILD_ALWAYS-build2 ${CMAKE_COMMAND} --build . --target always)
+endfunction()
+__ep_test_BUILD_ALWAYS()
+
function(__ep_test_CONFIGURE_HANDLED_BY_BUILD)
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CONFIGURE_HANDLED_BY_BUILD-build)
run_cmake(CONFIGURE_HANDLED_BY_BUILD)