diff options
author | Brad King <brad.king@kitware.com> | 2016-11-17 15:29:55 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-11-17 15:29:58 (GMT) |
commit | 25b6e7b710d7739cca44ed19bf45a190e72a6b82 (patch) | |
tree | 9699bdd712c12a0828a80ab6a01dfbb471c2ca53 /Tests/RunCMake/Configure | |
parent | 0e9634d2c90fd748774f9238219cb1661550f233 (diff) | |
download | CMake-25b6e7b710d7739cca44ed19bf45a190e72a6b82.zip CMake-25b6e7b710d7739cca44ed19bf45a190e72a6b82.tar.gz CMake-25b6e7b710d7739cca44ed19bf45a190e72a6b82.tar.bz2 |
Tolerate removed/replaced CMakeCache.txt with old CMakeFiles/
Users or scripts commonly remove or replace `CMakeCache.txt` without
also removing `CMakeFiles/`. In this case the information saved in the
cache from platform information initialization is missing, so we need to
re-initialize it. In such a case, remove the platform information
directory so that re-initialization will occur and restore needed
information to the cache.
Closes: #14820
Diffstat (limited to 'Tests/RunCMake/Configure')
-rw-r--r-- | Tests/RunCMake/Configure/RemoveCache-stdout.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/Configure/RemoveCache.cmake | 17 | ||||
-rw-r--r-- | Tests/RunCMake/Configure/RunCMakeTest.cmake | 9 |
3 files changed, 27 insertions, 0 deletions
diff --git a/Tests/RunCMake/Configure/RemoveCache-stdout.txt b/Tests/RunCMake/Configure/RemoveCache-stdout.txt new file mode 100644 index 0000000..73e7e5d --- /dev/null +++ b/Tests/RunCMake/Configure/RemoveCache-stdout.txt @@ -0,0 +1 @@ +-- The C compiler identification is diff --git a/Tests/RunCMake/Configure/RemoveCache.cmake b/Tests/RunCMake/Configure/RemoveCache.cmake new file mode 100644 index 0000000..304918f --- /dev/null +++ b/Tests/RunCMake/Configure/RemoveCache.cmake @@ -0,0 +1,17 @@ +enable_language(C) + +set(vars + CMAKE_EXECUTABLE_FORMAT + ) + +if(CMAKE_HOST_UNIX) + list(APPEND vars + CMAKE_UNAME + ) +endif() + +foreach(v IN LISTS vars) + if(NOT DEFINED ${v}) + message(SEND_ERROR "Variable '${v}' is not set!") + endif() +endforeach() diff --git a/Tests/RunCMake/Configure/RunCMakeTest.cmake b/Tests/RunCMake/Configure/RunCMakeTest.cmake index 91adb4e..4a135be 100644 --- a/Tests/RunCMake/Configure/RunCMakeTest.cmake +++ b/Tests/RunCMake/Configure/RunCMakeTest.cmake @@ -24,3 +24,12 @@ file(WRITE "${depend}" "2") run_cmake_command(RerunCMake-build2 ${CMAKE_COMMAND} --build .) unset(RunCMake_TEST_BINARY_DIR) unset(RunCMake_TEST_NO_CLEAN) + +# Use a single build tree for a few tests without cleaning. +set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/RemoveCache-build) +set(RunCMake_TEST_NO_CLEAN 1) +file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") +file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") +run_cmake(RemoveCache) +file(REMOVE "${RunCMake_TEST_BINARY_DIR}/CMakeCache.txt") +run_cmake(RemoveCache) |