diff --git a/CMakeLists.txt b/CMakeLists.txt index e636eeb..bc7553a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -95,23 +95,11 @@ macro(use_compilation_warning_as_error) if(MSVC) # Only enabled in debug because some old versions of VS STL generate # warnings when compiled in release configuration. - if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12.0) - add_compile_options($<$:/WX>) - else() - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /WX ") - endif() + add_compile_options($<$:/WX>) elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12.0) - add_compile_options(-Werror) - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") - endif() + add_compile_options(-Werror) if(JSONCPP_WITH_STRICT_ISO) - if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12.0) - add_compile_options(-pedantic-errors) - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic-errors") - endif() + add_compile_options(-pedantic-errors) endif() endif() endmacro() @@ -122,57 +110,29 @@ include_directories(${jsoncpp_SOURCE_DIR}/include) if(MSVC) # Only enabled in debug because some old versions of VS STL generate # unreachable code warning when compiled in release configuration. - if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12.0) - add_compile_options($<$:/W4>) - else() - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /W4 ") - endif() + add_compile_options($<$:/W4>) endif() if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") # using regular Clang or AppleClang - if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12.0) - add_compile_options(-Wall -Wconversion -Wshadow -Werror=conversion -Werror=sign-compare) - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wconversion -Wshadow -Werror=conversion -Werror=sign-compare") - endif() + add_compile_options(-Wall -Wconversion -Wshadow -Werror=conversion -Werror=sign-compare) elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") # using GCC - if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12.0) - add_compile_options(-Wall -Wconversion -Wshadow -Wextra) - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wconversion -Wshadow -Wextra") - endif() + add_compile_options(-Wall -Wconversion -Wshadow -Wextra) # not yet ready for -Wsign-conversion if(JSONCPP_WITH_STRICT_ISO) - if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12.0) - add_compile_options(-Wpedantic) - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wpedantic") - endif() + add_compile_options(-Wpedantic) endif() if(JSONCPP_WITH_WARNING_AS_ERROR) - if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12.0) - add_compile_options(-Werror=conversion) - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=conversion") - endif() + add_compile_options(-Werror=conversion) endif() elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") # using Intel compiler - if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12.0) - add_compile_options(-Wall -Wconversion -Wshadow -Wextra -Werror=conversion) - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wconversion -Wshadow -Wextra -Werror=conversion") - endif() + add_compile_options(-Wall -Wconversion -Wshadow -Wextra -Werror=conversion) if(JSONCPP_WITH_STRICT_ISO AND NOT JSONCPP_WITH_WARNING_AS_ERROR) - if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12.0) - add_compile_options(-Wpedantic) - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wpedantic") - endif() + add_compile_options(-Wpedantic) endif() endif() diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 2636e88..d252a50 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -10,7 +10,7 @@ set(EXAMPLES add_definitions(-D_GLIBCXX_USE_CXX11_ABI) if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra ") + add_compile_options(-Wall -Wextra) elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") add_definitions( -D_SCL_SECURE_NO_WARNINGS diff --git a/src/lib_json/CMakeLists.txt b/src/lib_json/CMakeLists.txt index f237720..caa9cc0 100644 --- a/src/lib_json/CMakeLists.txt +++ b/src/lib_json/CMakeLists.txt @@ -6,7 +6,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") #-Werror=* was introduced -after- GCC 4.1.2 if(GNUCXX_VERSION VERSION_GREATER 4.1.2) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=strict-aliasing") + add_compile_options("-Werror=strict-aliasing") endif() endif()