Commit 91e10a31 authored by Alexander Alekhin's avatar Alexander Alekhin

cmake: ocv_target_include_directories() handle SYSTEM directories

parent 08086178
...@@ -171,28 +171,54 @@ function(ocv_target_include_directories target) ...@@ -171,28 +171,54 @@ function(ocv_target_include_directories target)
";${ARGN};" MATCHES "/usr/include;") ";${ARGN};" MATCHES "/usr/include;")
return() # workaround for GCC 6.x bug return() # workaround for GCC 6.x bug
endif() endif()
set(__params "")
set(__system_params "")
set(__var_name __params)
foreach(dir ${ARGN}) foreach(dir ${ARGN})
get_filename_component(__abs_dir "${dir}" ABSOLUTE) if("${dir}" STREQUAL "SYSTEM")
ocv_is_opencv_directory(__is_opencv_dir "${dir}") set(__var_name __system_params)
if(__is_opencv_dir)
list(APPEND __params "${__abs_dir}")
else() else()
list(APPEND __params "${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() endforeach()
if(HAVE_CUDA OR CMAKE_VERSION VERSION_LESS 2.8.11) if(HAVE_CUDA OR CMAKE_VERSION VERSION_LESS 2.8.11)
include_directories(${__params}) include_directories(${__params})
include_directories(SYSTEM ${__system_params})
else() else()
if(TARGET ${target}) if(TARGET ${target})
target_include_directories(${target} PRIVATE ${__params}) if(__params)
if(OPENCV_DEPENDANT_TARGETS_${target}) target_include_directories(${target} PRIVATE ${__params})
foreach(t ${OPENCV_DEPENDANT_TARGETS_${target}}) if(OPENCV_DEPENDANT_TARGETS_${target})
target_include_directories(${t} PRIVATE ${__params}) foreach(t ${OPENCV_DEPENDANT_TARGETS_${target}})
endforeach() target_include_directories(${t} PRIVATE ${__params})
endforeach()
endif()
endif()
if(__system_params)
target_include_directories(${target} SYSTEM PRIVATE ${__system_params})
if(OPENCV_DEPENDANT_TARGETS_${target})
foreach(t ${OPENCV_DEPENDANT_TARGETS_${target}})
target_include_directories(${t} SYSTEM PRIVATE ${__system_params})
endforeach()
endif()
endif() endif()
else() else()
set(__new_inc "${OCV_TARGET_INCLUDE_DIRS_${target}};${__params}") if(__params)
set(OCV_TARGET_INCLUDE_DIRS_${target} "${__new_inc}" CACHE INTERNAL "") set(__new_inc ${OCV_TARGET_INCLUDE_DIRS_${target}})
list(APPEND __new_inc ${__params})
set(OCV_TARGET_INCLUDE_DIRS_${target} "${__new_inc}" CACHE INTERNAL "")
endif()
if(__system_params)
set(__new_inc ${OCV_TARGET_INCLUDE_SYSTEM_DIRS_${target}})
list(APPEND __new_inc ${__system_params})
set(OCV_TARGET_INCLUDE_SYSTEM_DIRS_${target} "${__new_inc}" CACHE INTERNAL "")
endif()
endif() endif()
endif() endif()
endfunction() endfunction()
...@@ -1078,6 +1104,16 @@ function(_ocv_append_target_includes target) ...@@ -1078,6 +1104,16 @@ function(_ocv_append_target_includes target)
endif() endif()
unset(OCV_TARGET_INCLUDE_DIRS_${target} CACHE) unset(OCV_TARGET_INCLUDE_DIRS_${target} CACHE)
endif() endif()
if(DEFINED OCV_TARGET_INCLUDE_SYSTEM_DIRS_${target})
target_include_directories(${target} SYSTEM PRIVATE ${OCV_TARGET_INCLUDE_SYSTEM_DIRS_${target}})
if(OPENCV_DEPENDANT_TARGETS_${target})
foreach(t ${OPENCV_DEPENDANT_TARGETS_${target}})
target_include_directories(${t} SYSTEM PRIVATE ${OCV_TARGET_INCLUDE_SYSTEM_DIRS_${target}})
endforeach()
endif()
unset(OCV_TARGET_INCLUDE_SYSTEM_DIRS_${target} CACHE)
endif()
endfunction() endfunction()
function(ocv_add_executable target) function(ocv_add_executable target)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment