summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorSebastian Holtermann <sebholt@xwmw.org>2019-05-15 10:36:27 (GMT)
committerSebastian Holtermann <sebholt@xwmw.org>2019-05-15 13:28:37 (GMT)
commit4edc0ef359578ddaa7db0163e3a6097e12530c9b (patch)
treedf9b3e29e78bc5835037c2d63af61d15fb787217 /Tests
parent66efdbd21a46b63572f5de677ed126a68e524e7a (diff)
downloadCMake-4edc0ef359578ddaa7db0163e3a6097e12530c9b.zip
CMake-4edc0ef359578ddaa7db0163e3a6097e12530c9b.tar.gz
CMake-4edc0ef359578ddaa7db0163e3a6097e12530c9b.tar.bz2
Test: Improve WarnUnusedCliUnused to run on all generators
In the WarnUnusedCliUnused test, the whole CMakeCache.txt was removed in the clean stage to trigger the same CMake warning in re-builds. This technique worked only in the Makefile generators and the test was limited to these. Now only the variable of interest is removed from the cache by using a `unset(UNUSED_CLI_VARIABLE CACHE)` statement in the CMakeLists.txt file. This makes the WarnUnusedCliUnused test run on all generators
Diffstat (limited to 'Tests')
-rw-r--r--Tests/CMakeLists.txt29
-rw-r--r--Tests/WarnUnusedCliUnused/CMakeLists.txt8
2 files changed, 15 insertions, 22 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index d992986..852b00f 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -2525,24 +2525,17 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
FAIL_REGULAR_EXPRESSION "CMakeLists.txt:5 \\(set\\):")
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaUnset")
- if("${CMAKE_GENERATOR}" MATCHES "Makefile" AND NOT WIN32)
- # Ninja does not support ADDITIONAL_MAKE_CLEAN_FILES and therefore fails
- # this test. (See #13371)
- # Apparently Visual Studio does not support it either. As the MakeClean
- # test above is only run with the Makefiles generator, only run this
- # test with the Makefiles generator also.
- add_test(WarnUnusedCliUnused ${CMAKE_CTEST_COMMAND}
- --build-and-test
- "${CMake_SOURCE_DIR}/Tests/WarnUnusedCliUnused"
- "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUnused"
- ${build_generator_args}
- --build-project WarnUnusedCliUnused
- --build-options ${build_options}
- "-DUNUSED_CLI_VARIABLE=Unused")
- set_tests_properties(WarnUnusedCliUnused PROPERTIES
- PASS_REGULAR_EXPRESSION "CMake Warning:.*Manually-specified variables were not used by the project:.* UNUSED_CLI_VARIABLE")
- list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUnused")
- endif()
+ add_test(WarnUnusedCliUnused ${CMAKE_CTEST_COMMAND}
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/WarnUnusedCliUnused"
+ "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUnused"
+ ${build_generator_args}
+ --build-project WarnUnusedCliUnused
+ --build-options ${build_options}
+ "-DUNUSED_CLI_VARIABLE=Unused")
+ set_tests_properties(WarnUnusedCliUnused PROPERTIES
+ PASS_REGULAR_EXPRESSION "CMake Warning:.*Manually-specified variables were not used by the project:.* UNUSED_CLI_VARIABLE")
+ list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUnused")
add_test(WarnUnusedCliUsed ${CMAKE_CTEST_COMMAND}
--build-and-test
diff --git a/Tests/WarnUnusedCliUnused/CMakeLists.txt b/Tests/WarnUnusedCliUnused/CMakeLists.txt
index 7ed69bf..a149f04 100644
--- a/Tests/WarnUnusedCliUnused/CMakeLists.txt
+++ b/Tests/WarnUnusedCliUnused/CMakeLists.txt
@@ -1,9 +1,9 @@
-cmake_minimum_required(VERSION 2.8)
+cmake_minimum_required(VERSION 3.14)
project(WarnUnusedCliUnused)
-set_directory_properties(PROPERTIES
- ADDITIONAL_MAKE_CLEAN_FILES "${CMAKE_BINARY_DIR}/CMakeCache.txt"
-)
+# Remove UNUSED_CLI_VARIABLE from the cache to trigger the
+# CMake warning message on re-builds as well.
+unset(UNUSED_CLI_VARIABLE CACHE)
add_library(dummy empty.cpp)