diff --git a/cmake/OpenCVUtils.cmake b/cmake/OpenCVUtils.cmake index a2d23ff05d..c804fba29f 100644 --- a/cmake/OpenCVUtils.cmake +++ b/cmake/OpenCVUtils.cmake @@ -565,6 +565,24 @@ macro(ocv_append_build_options var_prefix pkg_prefix) endforeach() endmacro() +function(ocv_append_source_files_cxx_compiler_options files_var) + set(__flags "${ARGN}") + ocv_check_flag_support(CXX "${__flags}" __HAVE_COMPILER_OPTIONS_VAR "") + if(${__HAVE_COMPILER_OPTIONS_VAR}) + foreach(source ${${files_var}}) + if("${source}" MATCHES "\\.(cpp|cc|cxx)$") + get_source_file_property(flags "${source}" COMPILE_FLAGS) + if(flags) + set(flags "${flags} ${__flags}") + else() + set(flags "${__flags}") + endif() + set_source_files_properties("${source}" PROPERTIES COMPILE_FLAGS "${flags}") + endif() + endforeach() + endif() +endfunction() + # Usage is similar to CMake 'pkg_check_modules' command # It additionally controls HAVE_${define} and ${define}_${modname}_FOUND variables macro(ocv_check_modules define) diff --git a/modules/dnn/CMakeLists.txt b/modules/dnn/CMakeLists.txt index 9f77f7a1a9..fbcdd78308 100644 --- a/modules/dnn/CMakeLists.txt +++ b/modules/dnn/CMakeLists.txt @@ -87,6 +87,11 @@ if(WITH_INF_ENGINE AND HAVE_INF_ENGINE) endif() ocv_module_include_directories(${include_dirs}) +if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + ocv_append_source_files_cxx_compiler_options(fw_srcs "-Wno-suggest-override") # GCC +elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + ocv_append_source_files_cxx_compiler_options(fw_srcs "-Wno-inconsistent-missing-override") # Clang +endif() ocv_glob_module_sources(${sources_options} SOURCES ${fw_srcs}) ocv_create_module(${libs}) ocv_add_samples()