Protect against literal interpretation (#137)

* Protect against literal interpretation

On msvc 2017 this seems to have been checking for existence of a flag called `_warning_flag`

* Stop checking for flag called "IN"

* Ensure compiler flag checks are not cached

Per the docs of CMake the call to CHECK_CXX_COMPILER_FLAG 
stores the result in an internal cache entry. In this loop we were 
basically skipping the "supported" check for all flags after the 
first one. Forcibly unsetting the variable before each check 
ensures that we actually check if each specific flag is supported
This commit is contained in:
Hamilton Turner 2019-04-15 19:06:48 -04:00 committed by Andrew Twyman
parent 4b30939ac9
commit 402bcde713

View File

@ -30,8 +30,9 @@ target_compile_options(json11
# Set warning flags, which may vary per platform
include(CheckCXXCompilerFlag)
set(_possible_warnings_flags /W4 /WX -Wextra -Werror)
foreach(_warning_flag in ${_possible_warnings_flags})
CHECK_CXX_COMPILER_FLAG(_warning_flag _flag_supported)
foreach(_warning_flag ${_possible_warnings_flags})
unset(_flag_supported)
CHECK_CXX_COMPILER_FLAG(${_warning_flag} _flag_supported)
if(${_flag_supported})
target_compile_options(json11 PRIVATE ${_warning_flag})
endif()