diff --git a/CMakeLists.txt b/CMakeLists.txt index c988a8003..ccedec774 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -418,25 +418,26 @@ if(NOT (CMAKE_VERSION VERSION_LESS "3.1")) set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_EXTENSIONS OFF) else() + add_compile_options("$<$,C>:-std=gnu11>") if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT WIN32) if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.1.1") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + add_compile_options("$<$,CXX>:-std=c++11>") else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") + add_compile_options("$<$,CXX>:-std=c++14>") endif() endif() if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") if(OS_IS_MACOSX) if(CLANG_VERSION VERSION_LESS "600") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + add_compile_options("$<$,CXX>:-std=c++11>") else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") + add_compile_options("$<$,CXX>:-std=c++14>") endif() else() if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "3.5.0") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + add_compile_options("$<$,CXX>:-std=c++11>") else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") + add_compile_options("$<$,CXX>:-std=c++14>") endif() endif() endif() @@ -1860,7 +1861,8 @@ endif() if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT WIN32) # Add warning flags # For "-Wall" see https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html - add_compile_options(-Wall -Wextra) + set(cxx_warning_flags -Wall -Wextra) + add_compile_options("$<$,CXX>:${cxx_warning_flags}>") if(CMAKE_CROSSCOMPILING) add_compile_options(-Wno-psabi) endif()