diff --git a/CMakeLists.txt b/CMakeLists.txt index 522fcb3c..2e3d601d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -111,14 +111,14 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL Darwin) endif() if (NOT MSVC) - if(NOT CMAKE_CXX_FLAGS MATCHES "-std=") + if(NOT CMAKE_CXX_FLAGS MATCHES "-std=" AND NOT CXX_STANDARD AND NOT CMAKE_CXX_STANDARD) # use C++11 by default if supported check_cxx_compiler_flag("-std=c++11" COMPILER_SUPPORTS_CXX11) if(COMPILER_SUPPORTS_CXX11) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") endif() endif() - if(NOT CMAKE_C_FLAGS MATCHES "-std=") + if(NOT CMAKE_C_FLAGS MATCHES "-std=" AND NOT C_STANDARD AND NOT CMAKE_C_STANDARD) check_c_compiler_flag("-std=c11" COMPILER_SUPPORTS_C11) if(COMPILER_SUPPORTS_C11) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11")