diff --git a/CMakeLists.txt b/CMakeLists.txt index 36a59872f..addbafe2b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -110,11 +110,11 @@ if(MSVC) add_definitions(-D_SCL_SECURE_NO_WARNINGS) endif() -if(CMAKE_COMPILER_IS_GNUCXX) - if(CMAKE_VERSION VERSION_LESS "3.0") +if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + include(CheckCXXCompilerFlag) + check_cxx_compiler_flag(-Wsuggest-override HAVE_GXX_SUGGEST_OVERRIDE) + if(HAVE_GXX_SUGGEST_OVERRIDE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsuggest-override") - else() - add_compile_options(-Wsuggest-override) endif() endif()