diff options
author | Alex Neundorf <neundorf@kde.org> | 2011-07-07 20:07:16 (GMT) |
---|---|---|
committer | Alex Neundorf <neundorf@kde.org> | 2011-07-07 20:09:44 (GMT) |
commit | 1325260a664577a1356f3034ed5f110d45f6a6d8 (patch) | |
tree | f7cc3611e0689c175dc9f66f34078a2c707c660f /Tests/CMakeTests | |
parent | a8e0287d86aa2450b5cbe0792180587bb1d48b7e (diff) | |
download | CMake-1325260a664577a1356f3034ed5f110d45f6a6d8.zip CMake-1325260a664577a1356f3034ed5f110d45f6a6d8.tar.gz CMake-1325260a664577a1356f3034ed5f110d45f6a6d8.tar.bz2 |
Add macros cmake_push/pop_check_state() as discussed on the list.
This patch adds two macros cmake_push_check_state() and
cmake_pop_check_state(), which can be used to save and restore
the contents of the CMAKE_REQUIRED_xxx variables.
Alex
Diffstat (limited to 'Tests/CMakeTests')
-rw-r--r-- | Tests/CMakeTests/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/CMakeTests/PushCheckStateTest.cmake.in | 30 |
2 files changed, 31 insertions, 0 deletions
diff --git a/Tests/CMakeTests/CMakeLists.txt b/Tests/CMakeTests/CMakeLists.txt index 5cb50c9..fc1426e 100644 --- a/Tests/CMakeTests/CMakeLists.txt +++ b/Tests/CMakeTests/CMakeLists.txt @@ -28,6 +28,7 @@ AddCMakeTest(Math "") AddCMakeTest(CMakeMinimumRequired "") AddCMakeTest(CompilerIdVendor "") AddCMakeTest(ProcessorCount "") +AddCMakeTest(PushCheckState "") AddCMakeTest(FileDownload "") set_property(TEST CMake.FileDownload PROPERTY diff --git a/Tests/CMakeTests/PushCheckStateTest.cmake.in b/Tests/CMakeTests/PushCheckStateTest.cmake.in new file mode 100644 index 0000000..e707b9a --- /dev/null +++ b/Tests/CMakeTests/PushCheckStateTest.cmake.in @@ -0,0 +1,30 @@ +include(CMakePushCheckState) + +set(CMAKE_REQUIRED_DEFINITIONS defs1 ) + +cmake_push_check_state() + +set(CMAKE_REQUIRED_DEFINITIONS defs2) + +cmake_push_check_state() + +set(CMAKE_REQUIRED_DEFINITIONS defs3) + +cmake_pop_check_state() + +if (NOT "${CMAKE_REQUIRED_DEFINITIONS}" STREQUAL "defs2") + set(fatal TRUE) + message("ERROR: "CMAKE_REQUIRED_DEFINITIONS is \"${CMAKE_REQUIRED_DEFINITIONS}\" (expected \"defs2\")" ) +endif() + +cmake_pop_check_state() + +if (NOT "${CMAKE_REQUIRED_DEFINITIONS}" STREQUAL "defs1") + set(fatal TRUE) + message("ERROR: "CMAKE_REQUIRED_DEFINITIONS is \"${CMAKE_REQUIRED_DEFINITIONS}\" (expected \"defs1\")" ) +endif() + + +if(fatal) + message(FATAL_ERROR "cmake_push_check_state() test failed") +endif() |