diff options
author | Brad King <brad.king@kitware.com> | 2022-08-10 13:14:18 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-08-10 13:14:33 (GMT) |
commit | 3907c081469242a56efc330c2701a7dd05f956ec (patch) | |
tree | a5d3a112f68d826670c1bfe163d0fc71d5226fe0 /Tests | |
parent | 29115e706aec3007a1b651ceed936e94f69de858 (diff) | |
parent | 81fd0d6e265985213ec3d0c1db4b8a6f314481ea (diff) | |
download | CMake-3907c081469242a56efc330c2701a7dd05f956ec.zip CMake-3907c081469242a56efc330c2701a7dd05f956ec.tar.gz CMake-3907c081469242a56efc330c2701a7dd05f956ec.tar.bz2 |
Merge topic 'ExternalProject-BUILD_ALWAYS-install'
81fd0d6e26 ExternalProject: Fix install on BUILD_ALWAYS+BUILD_BYPRODUCTS with Ninja
d9e88721ad ExternalProject: Add test case for BUILD_ALWAYS
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7546
Diffstat (limited to 'Tests')
4 files changed, 50 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..2e5fc6f --- /dev/null +++ b/Tests/RunCMake/ExternalProject/BUILD_ALWAYS.cmake @@ -0,0 +1,20 @@ +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 + COMMAND "${CMAKE_COMMAND}" -E copy_if_different ${CMAKE_CURRENT_LIST_FILE} + "${CMAKE_CURRENT_BINARY_DIR}/byproduct.txt" + BUILD_BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/byproduct.txt" + 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) |