CMake/Tests/CMakeTests/PushCheckStateTest.cmake.in
Alex Neundorf 1325260a66 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
2011-07-07 22:09:44 +02:00

31 lines
715 B
CMake

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()