Refactored warning flag checks to use CheckCXXCompilerFlag module since Windows can compile without MSVC

This commit is contained in:
Jimmy Nguyen 2017-02-07 11:54:10 -08:00
parent 3d69faa498
commit 067fd4934b

View File

@ -18,13 +18,14 @@ target_compile_options(json11
PRIVATE -fPIC -fno-rtti -fno-exceptions -Wall)
# Set warning flags, which may vary per platform
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
target_compile_options(json11
PRIVATE /W4 /WX)
else()
target_compile_options(json11
PRIVATE -Wextra -Werror)
endif()
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)
if(${_flag_supported})
target_compile_options(json11 PRIVATE ${_warning_flag})
endif()
endforeach()
configure_file("json11.pc.in" "json11.pc" @ONLY)