From 067fd4934bc7321b7ab1ce1d9fd80d472729f973 Mon Sep 17 00:00:00 2001 From: Jimmy Nguyen Date: Tue, 7 Feb 2017 11:54:10 -0800 Subject: [PATCH] Refactored warning flag checks to use `CheckCXXCompilerFlag` module since Windows can compile without MSVC --- CMakeLists.txt | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0497b47..ed4c2f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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)