diff --git a/cmake/templates/OpenCVConfig.cmake.in b/cmake/templates/OpenCVConfig.cmake.in index e5904aba37..ee57ecda63 100644 --- a/cmake/templates/OpenCVConfig.cmake.in +++ b/cmake/templates/OpenCVConfig.cmake.in @@ -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 # ==============================================================