Merge topic 'add-CMAKE_EXTRA_INCLUDE_FILES-to-CMakePushCheckState'
fad5d59c
PushCheckStateTest: Update test to check CMAKE_EXTRA_INCLUDE_FILES72a862a5
CMakePushCheckState: Add support for CMAKE_EXTRA_INCLUDE_FILESa3468b78
PushCheckStateTest: Test all variables managed by the module85b2bb6c
PushCheckStateTest: Fix syntax warning
This commit is contained in:
commit
2d226ea895
|
@ -0,0 +1,5 @@
|
|||
CMakePushCheckState-CMAKE_EXTRA_INCLUDE_FILE
|
||||
--------------------------------------------
|
||||
|
||||
* The :module:`CMakePushCheckState` module now pushes/pops/resets the variable
|
||||
``CMAKE_EXTRA_INCLUDE_FILE`` used in :module:`CheckTypeSize`.
|
|
@ -8,8 +8,8 @@
|
|||
# CMAKE_POP_CHECK_STATE() and CMAKE_RESET_CHECK_STATE() These macros can
|
||||
# be used to save, restore and reset (i.e., clear contents) the state of
|
||||
# the variables CMAKE_REQUIRED_FLAGS, CMAKE_REQUIRED_DEFINITIONS,
|
||||
# CMAKE_REQUIRED_LIBRARIES and CMAKE_REQUIRED_INCLUDES used by the
|
||||
# various Check-files coming with CMake, like e.g.
|
||||
# CMAKE_REQUIRED_LIBRARIES, CMAKE_REQUIRED_INCLUDES and CMAKE_EXTRA_INCLUDE_FILES
|
||||
# used by the various Check-files coming with CMake, like e.g.
|
||||
# check_function_exists() etc. The variable contents are pushed on a
|
||||
# stack, pushing multiple times is supported. This is useful e.g. when
|
||||
# executing such tests in a Find-module, where they have to be set, but
|
||||
|
@ -49,6 +49,7 @@
|
|||
|
||||
macro(CMAKE_RESET_CHECK_STATE)
|
||||
|
||||
set(CMAKE_EXTRA_INCLUDE_FILES)
|
||||
set(CMAKE_REQUIRED_INCLUDES)
|
||||
set(CMAKE_REQUIRED_DEFINITIONS)
|
||||
set(CMAKE_REQUIRED_LIBRARIES)
|
||||
|
@ -65,6 +66,7 @@ macro(CMAKE_PUSH_CHECK_STATE)
|
|||
|
||||
math(EXPR _CMAKE_PUSH_CHECK_STATE_COUNTER "${_CMAKE_PUSH_CHECK_STATE_COUNTER}+1")
|
||||
|
||||
set(_CMAKE_EXTRA_INCLUDE_FILES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_EXTRA_INCLUDE_FILES})
|
||||
set(_CMAKE_REQUIRED_INCLUDES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_INCLUDES})
|
||||
set(_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_DEFINITIONS})
|
||||
set(_CMAKE_REQUIRED_LIBRARIES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_LIBRARIES})
|
||||
|
@ -82,6 +84,7 @@ macro(CMAKE_POP_CHECK_STATE)
|
|||
# don't pop more than we pushed
|
||||
if("${_CMAKE_PUSH_CHECK_STATE_COUNTER}" GREATER "0")
|
||||
|
||||
set(CMAKE_EXTRA_INCLUDE_FILES ${_CMAKE_EXTRA_INCLUDE_FILES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}})
|
||||
set(CMAKE_REQUIRED_INCLUDES ${_CMAKE_REQUIRED_INCLUDES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}})
|
||||
set(CMAKE_REQUIRED_DEFINITIONS ${_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}})
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${_CMAKE_REQUIRED_LIBRARIES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}})
|
||||
|
|
|
@ -1,29 +1,68 @@
|
|||
include(CMakePushCheckState)
|
||||
|
||||
set(CMAKE_EXTRA_INCLUDE_FILES file1)
|
||||
set(CMAKE_REQUIRED_INCLUDES dir1)
|
||||
set(CMAKE_REQUIRED_DEFINITIONS defs1 )
|
||||
set(CMAKE_REQUIRED_LIBRARIES lib1)
|
||||
set(CMAKE_REQUIRED_FLAGS flag1)
|
||||
set(CMAKE_REQUIRED_QUIET 1)
|
||||
|
||||
cmake_push_check_state()
|
||||
|
||||
set(CMAKE_EXTRA_INCLUDE_FILES file2)
|
||||
set(CMAKE_REQUIRED_INCLUDES dir2)
|
||||
set(CMAKE_REQUIRED_DEFINITIONS defs2)
|
||||
set(CMAKE_REQUIRED_LIBRARIES lib2)
|
||||
set(CMAKE_REQUIRED_FLAGS flag2)
|
||||
set(CMAKE_REQUIRED_QUIET 2)
|
||||
|
||||
cmake_push_check_state()
|
||||
|
||||
set(CMAKE_EXTRA_INCLUDE_FILES file3)
|
||||
set(CMAKE_REQUIRED_DEFINITIONS defs3)
|
||||
set(CMAKE_REQUIRED_INCLUDES dir3)
|
||||
set(CMAKE_REQUIRED_DEFINITIONS defs3)
|
||||
set(CMAKE_REQUIRED_LIBRARIES lib3)
|
||||
set(CMAKE_REQUIRED_FLAGS flag3)
|
||||
set(CMAKE_REQUIRED_QUIET 3)
|
||||
|
||||
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()
|
||||
foreach(pair IN ITEMS
|
||||
EXTRA_INCLUDE_FILES|file2
|
||||
REQUIRED_INCLUDES|dir2
|
||||
REQUIRED_DEFINITIONS|defs2
|
||||
REQUIRED_LIBRARIES|lib2
|
||||
REQUIRED_FLAGS|flag2
|
||||
REQUIRED_QUIET|2
|
||||
)
|
||||
string(REPLACE "|" ";" pair "${pair}")
|
||||
list(GET pair 0 var)
|
||||
list(GET pair 1 expected)
|
||||
if (NOT "${CMAKE_${var}}" STREQUAL "${expected}")
|
||||
set(fatal TRUE)
|
||||
message("ERROR: CMAKE_${var} is \"${CMAKE_${var}}\" (expected \"${expected}\")" )
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
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()
|
||||
|
||||
foreach(pair IN ITEMS
|
||||
EXTRA_INCLUDE_FILES|file1
|
||||
REQUIRED_INCLUDES|dir1
|
||||
REQUIRED_DEFINITIONS|defs1
|
||||
REQUIRED_LIBRARIES|lib1
|
||||
REQUIRED_FLAGS|flag1
|
||||
REQUIRED_QUIET|1
|
||||
)
|
||||
string(REPLACE "|" ";" pair "${pair}")
|
||||
list(GET pair 0 var)
|
||||
list(GET pair 1 expected)
|
||||
if (NOT "${CMAKE_${var}}" STREQUAL "${expected}")
|
||||
set(fatal TRUE)
|
||||
message("ERROR: CMAKE_${var} is \"${CMAKE_${var}}\" (expected \"${expected}\")" )
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(fatal)
|
||||
message(FATAL_ERROR "cmake_push_check_state() test failed")
|
||||
|
|
Loading…
Reference in New Issue