diff --git a/cmake/OpenCVUtils.cmake b/cmake/OpenCVUtils.cmake index 94f87d9a12..5886f4f3cb 100644 --- a/cmake/OpenCVUtils.cmake +++ b/cmake/OpenCVUtils.cmake @@ -353,23 +353,23 @@ function(ocv_target_include_directories target) #ocv_debug_message("ocv_target_include_directories(${target} ${ARGN})") _ocv_fix_target(target) set(__params "") - if(CV_GCC AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.0" AND - ";${ARGN};" MATCHES "/usr/include;") - return() # workaround for GCC 6.x bug - endif() - set(__params "") set(__system_params "") set(__var_name __params) foreach(dir ${ARGN}) if("${dir}" STREQUAL "SYSTEM") set(__var_name __system_params) else() - get_filename_component(__abs_dir "${dir}" ABSOLUTE) - ocv_is_opencv_directory(__is_opencv_dir "${dir}") - if(__is_opencv_dir) - list(APPEND ${__var_name} "${__abs_dir}") + if(CV_GCC AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.0" AND + dir MATCHES "/usr/include$") + # workaround for GCC 6.x bug else() - list(APPEND ${__var_name} "${dir}") + get_filename_component(__abs_dir "${dir}" ABSOLUTE) + ocv_is_opencv_directory(__is_opencv_dir "${dir}") + if(__is_opencv_dir) + list(APPEND ${__var_name} "${__abs_dir}") + else() + list(APPEND ${__var_name} "${dir}") + endif() endif() endif() endforeach()