diff options
author | Brad King <brad.king@kitware.com> | 2022-03-21 19:09:23 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2022-03-22 13:27:47 (GMT) |
commit | 9f1471739d83c9e61b6700a0c369b7f7bbb19071 (patch) | |
tree | 2fb485885eb07f35342bc17485d27946bc819f92 /Tests/RunCMake/CommandLine/Fresh.cmake | |
parent | 7e642a6fa0884cf683a1a50dd5cab93acd1e3950 (diff) | |
download | CMake-9f1471739d83c9e61b6700a0c369b7f7bbb19071.zip CMake-9f1471739d83c9e61b6700a0c369b7f7bbb19071.tar.gz CMake-9f1471739d83c9e61b6700a0c369b7f7bbb19071.tar.bz2 |
cmake: Add --fresh option to clear the cache and start from scratch
Simplify the workflow to re-run CMake from scratch as if a build tree
were never before processed, regardless of whether it has been.
Fixes: #23119
Diffstat (limited to 'Tests/RunCMake/CommandLine/Fresh.cmake')
-rw-r--r-- | Tests/RunCMake/CommandLine/Fresh.cmake | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Tests/RunCMake/CommandLine/Fresh.cmake b/Tests/RunCMake/CommandLine/Fresh.cmake new file mode 100644 index 0000000..9b1695c --- /dev/null +++ b/Tests/RunCMake/CommandLine/Fresh.cmake @@ -0,0 +1,18 @@ +message(STATUS "CMAKE_SOURCE_DIR='${CMAKE_SOURCE_DIR}'") +message(STATUS "CMAKE_BINARY_DIR='${CMAKE_BINARY_DIR}'") +message(STATUS "OLD CACHED_VAR_1='${CACHED_VAR_1}'") +set(CACHED_VAR_1 "CACHED-VALUE-1" CACHE STRING "") +message(STATUS "NEW CACHED_VAR_1='${CACHED_VAR_1}'") +set(kept "${CMAKE_BINARY_DIR}/kept") +set(removed "${CMAKE_BINARY_DIR}/CMakeFiles/removed") +if(FIRST) + file(WRITE "${kept}" "") + file(WRITE "${removed}" "") +else() + if(NOT EXISTS "${kept}") + message(FATAL_ERROR "File was not kept:\n ${kept}") + endif() + if(EXISTS "${removed}") + message(FATAL_ERROR "File was not removed:\n ${removed}") + endif() +endif() |