mirror of
https://github.com/opencv/opencv.git
synced 2025-06-18 16:11:50 +08:00
cmake: ocv_target_include_directories() handle SYSTEM directories
This commit is contained in:
parent
08086178bd
commit
91e10a3105
@ -171,29 +171,55 @@ 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})
|
||||||
|
if("${dir}" STREQUAL "SYSTEM")
|
||||||
|
set(__var_name __system_params)
|
||||||
|
else()
|
||||||
get_filename_component(__abs_dir "${dir}" ABSOLUTE)
|
get_filename_component(__abs_dir "${dir}" ABSOLUTE)
|
||||||
ocv_is_opencv_directory(__is_opencv_dir "${dir}")
|
ocv_is_opencv_directory(__is_opencv_dir "${dir}")
|
||||||
if(__is_opencv_dir)
|
if(__is_opencv_dir)
|
||||||
list(APPEND __params "${__abs_dir}")
|
list(APPEND ${__var_name} "${__abs_dir}")
|
||||||
else()
|
else()
|
||||||
list(APPEND __params "${dir}")
|
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})
|
||||||
|
if(__params)
|
||||||
target_include_directories(${target} PRIVATE ${__params})
|
target_include_directories(${target} PRIVATE ${__params})
|
||||||
if(OPENCV_DEPENDANT_TARGETS_${target})
|
if(OPENCV_DEPENDANT_TARGETS_${target})
|
||||||
foreach(t ${OPENCV_DEPENDANT_TARGETS_${target}})
|
foreach(t ${OPENCV_DEPENDANT_TARGETS_${target}})
|
||||||
target_include_directories(${t} PRIVATE ${__params})
|
target_include_directories(${t} PRIVATE ${__params})
|
||||||
endforeach()
|
endforeach()
|
||||||
endif()
|
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()
|
||||||
else()
|
else()
|
||||||
set(__new_inc "${OCV_TARGET_INCLUDE_DIRS_${target}};${__params}")
|
if(__params)
|
||||||
|
set(__new_inc ${OCV_TARGET_INCLUDE_DIRS_${target}})
|
||||||
|
list(APPEND __new_inc ${__params})
|
||||||
set(OCV_TARGET_INCLUDE_DIRS_${target} "${__new_inc}" CACHE INTERNAL "")
|
set(OCV_TARGET_INCLUDE_DIRS_${target} "${__new_inc}" CACHE INTERNAL "")
|
||||||
endif()
|
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()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user