Add OpenCV_INCLUDE_DIRS to INTERFACE_INCLUDE_DIRECTORIES target property

With this fix there is no need to add includes by using
`include_directories(${OpenCV_INCLUDE_DIRS})`. Directory will be added by
command `target_link_libraries(... ${OpenCV_LIBS})` automatically.
This commit is contained in:
Ruslan Baratov 2015-06-17 13:44:11 +02:00
parent 01c3ed6157
commit f30bf39bd4

View File

@ -7,7 +7,7 @@
# In your CMakeLists.txt, add these lines:
#
# find_package(OpenCV REQUIRED)
# include_directories(${OpenCV_INCLUDE_DIRS})
# include_directories(${OpenCV_INCLUDE_DIRS}) # Not needed for CMake >= 2.8.11
# target_link_libraries(MY_TARGET_NAME ${OpenCV_LIBS})
#
# Or you can search for specific OpenCV modules:
@ -177,6 +177,20 @@ if(OpenCV2_INCLUDE_DIRS)
endif()
endif()
if(NOT CMAKE_VERSION VERSION_LESS "2.8.11")
# Target property INTERFACE_INCLUDE_DIRECTORIES available since 2.8.11:
# * http://www.cmake.org/cmake/help/v2.8.11/cmake.html#prop_tgt:INTERFACE_INCLUDE_DIRECTORIES
foreach(__component ${OpenCV_LIB_COMPONENTS})
if(TARGET ${__component})
set_target_properties(
${__component}
PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${OpenCV_INCLUDE_DIRS}"
)
endif()
endforeach()
endif()
# ==============================================================
# Check OpenCV availability
# ==============================================================