Skip to content

Commit

Permalink
Protect against literal interpretation (dropbox#137)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
hamiltont authored and artwyman committed Apr 15, 2019
1 parent 4b30939 commit 402bcde
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 402bcde

Please sign in to comment.