compile_flag: restore CMAKE_REQUIRED_FLAGS

This commit is contained in:
Danny Robson 2018-07-04 16:46:15 +10:00
parent 878a1f118f
commit 26319b51a1

View File

@ -21,6 +21,8 @@ macro (append_compile_flag _flag)
# you use the negation.
string (REGEX MATCH "^-Wno-(.+)$" compile_flag_inverse ${_flag})
set(_append_compile_flag_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
if ("x" STREQUAL "x${compile_flag_inverse}")
set(CMAKE_REQUIRED_FLAGS "${CMAKE_CXX_FLAGS} ${_flag}")
else ()
@ -29,6 +31,7 @@ macro (append_compile_flag _flag)
endif ()
check_cxx_source_compiles("int main(int,char**) { return 0; }" compile_flag_${_name})
set(CMAKE_REQUIRED_FLAGS "${_append_compile_flag_REQUIRED_FLAGS}")
endif ()
if (compile_flag_${_name})