diff options
-rw-r--r-- | Tests/CMakeLists.txt | 15 | ||||
-rw-r--r-- | Tests/VariableUnusedViaUnset/CMakeLists.txt | 8 |
2 files changed, 23 insertions, 0 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 995a749..be0c27c 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1074,6 +1074,21 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BundleGeneratorTest") ENDIF(APPLE AND CTEST_TEST_CPACK) + ADD_TEST(WarnUnusedUnusedViaUnset ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/VariableUnusedViaUnset" + "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaUnset" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-noclean + --build-project WarnUnusedUnusedViaUnset + --build-options "--warn-unused-vars") + SET_TESTS_PROPERTIES(WarnUnusedUnusedViaUnset PROPERTIES + PASS_REGULAR_EXPRESSION ":7: warning: \\(unsetting\\) unused variable 'UNUSED_VARIABLE'") + SET_TESTS_PROPERTIES(WarnUnusedUnusedViaUnset PROPERTIES + FAIL_REGULAR_EXPRESSION ":5: warning: \\(unsetting\\) unused variable 'UNUSED_VARIABLE'") + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaUnset") + ADD_TEST(WarnUnusedCliUnused ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/VariableUsage" diff --git a/Tests/VariableUnusedViaUnset/CMakeLists.txt b/Tests/VariableUnusedViaUnset/CMakeLists.txt new file mode 100644 index 0000000..886508e --- /dev/null +++ b/Tests/VariableUnusedViaUnset/CMakeLists.txt @@ -0,0 +1,8 @@ +# NOTE: Changing lines in here changes the test results since the first +# instance shouldn't warn, but the second should and they have the same message + +# A warning should NOT ne issued for this line: +set(UNUSED_VARIABLE) +# Warning should occur here: +set(UNUSED_VARIABLE) +message(STATUS "${UNUSED_VARIABLE}") |