diff options
author | Brad King <brad.king@kitware.com> | 2017-07-10 14:30:17 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-07-12 19:09:16 (GMT) |
commit | fda50a08437d99aba753bc84d26ba535e06e7b06 (patch) | |
tree | 0db2d7f13562b36aa1261aefc033768e8b67bc1d | |
parent | 1fda77d45565c3a819e6149597c3a194d9ccd0bb (diff) | |
download | CMake-fda50a08437d99aba753bc84d26ba535e06e7b06.zip CMake-fda50a08437d99aba753bc84d26ba535e06e7b06.tar.gz CMake-fda50a08437d99aba753bc84d26ba535e06e7b06.tar.bz2 |
CMakePushCheckState: Fix cmake_push_check_state RESET argument
This option was added by commit v2.8.12~138^2 (Add
cmake_reset_check_state() macro, 2013-07-28) but has never worked.
Fix the implementation to refer to macro arguments properly (not as
normal variables).
Fixes: #17048
-rw-r--r-- | Modules/CMakePushCheckState.cmake | 2 | ||||
-rw-r--r-- | Tests/CMakeTests/PushCheckStateTest.cmake.in | 22 |
2 files changed, 23 insertions, 1 deletions
diff --git a/Modules/CMakePushCheckState.cmake b/Modules/CMakePushCheckState.cmake index 2a527d5..98eea05 100644 --- a/Modules/CMakePushCheckState.cmake +++ b/Modules/CMakePushCheckState.cmake @@ -62,7 +62,7 @@ macro(CMAKE_PUSH_CHECK_STATE) set(_CMAKE_REQUIRED_FLAGS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_FLAGS}) set(_CMAKE_REQUIRED_QUIET_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_QUIET}) - if (ARGC GREATER 0 AND ARGV0 STREQUAL "RESET") + if (${ARGC} GREATER 0 AND "${ARGV0}" STREQUAL "RESET") cmake_reset_check_state() endif() diff --git a/Tests/CMakeTests/PushCheckStateTest.cmake.in b/Tests/CMakeTests/PushCheckStateTest.cmake.in index b4c48f4..cbd879d 100644 --- a/Tests/CMakeTests/PushCheckStateTest.cmake.in +++ b/Tests/CMakeTests/PushCheckStateTest.cmake.in @@ -1,3 +1,4 @@ +cmake_minimum_required(VERSION 3.8) include(CMakePushCheckState) set(CMAKE_EXTRA_INCLUDE_FILES file1) @@ -26,6 +27,27 @@ set(CMAKE_REQUIRED_LIBRARIES lib3) set(CMAKE_REQUIRED_FLAGS flag3) set(CMAKE_REQUIRED_QUIET 3) +cmake_push_check_state(RESET) + +foreach(pair IN ITEMS + EXTRA_INCLUDE_FILES| + REQUIRED_INCLUDES| + REQUIRED_DEFINITIONS| + REQUIRED_LIBRARIES| + REQUIRED_FLAGS| + REQUIRED_QUIET| + ) + 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() + cmake_pop_check_state() foreach(pair IN ITEMS |