1# =================================================================================== 2# The OpenCV CMake configuration file 3# 4# ** File generated automatically, do not modify ** 5# 6# Usage from an external project: 7# In your CMakeLists.txt, add these lines: 8# 9# find_package(OpenCV REQUIRED) 10# include_directories(${OpenCV_INCLUDE_DIRS}) 11# target_link_libraries(MY_TARGET_NAME ${OpenCV_LIBS}) 12# 13# Or you can search for specific OpenCV modules: 14# 15# find_package(OpenCV REQUIRED core videoio) 16# 17# If the module is found then OPENCV_<MODULE>_FOUND is set to TRUE. 18# 19# This file will define the following variables: 20# - OpenCV_LIBS : The list of all imported targets for OpenCV modules. 21# - OpenCV_INCLUDE_DIRS : The OpenCV include directories. 22# - OpenCV_COMPUTE_CAPABILITIES : The version of compute capability. 23# - OpenCV_ANDROID_NATIVE_API_LEVEL : Minimum required level of Android API. 24# - OpenCV_VERSION : The version of this OpenCV build: "@OPENCV_VERSION_PLAIN@" 25# - OpenCV_VERSION_MAJOR : Major version part of OpenCV_VERSION: "@OPENCV_VERSION_MAJOR@" 26# - OpenCV_VERSION_MINOR : Minor version part of OpenCV_VERSION: "@OPENCV_VERSION_MINOR@" 27# - OpenCV_VERSION_PATCH : Patch version part of OpenCV_VERSION: "@OPENCV_VERSION_PATCH@" 28# - OpenCV_VERSION_STATUS : Development status of this build: "@OPENCV_VERSION_STATUS@" 29# 30# Advanced variables: 31# - OpenCV_SHARED : Use OpenCV as shared library 32# - OpenCV_CONFIG_PATH : Path to this OpenCVConfig.cmake 33# - OpenCV_INSTALL_PATH : OpenCV location (not set on Windows) 34# - OpenCV_LIB_COMPONENTS : Present OpenCV modules list 35# - OpenCV_USE_MANGLED_PATHS : Mangled OpenCV path flag 36# - OpenCV_MODULES_SUFFIX : The suffix for OpenCVModules-XXX.cmake file 37# 38# Deprecated variables: 39# - OpenCV_VERSION_TWEAK : Always "0" 40# 41# =================================================================================== 42 43# Search packages for host system instead of packages for target system. 44# in case of cross compilation thess macro should be defined by toolchain file 45 46if(NOT COMMAND find_host_package) 47 macro(find_host_package) 48 find_package(${ARGN}) 49 endmacro() 50endif() 51 52if(NOT COMMAND find_host_program) 53 macro(find_host_program) 54 find_program(${ARGN}) 55 endmacro() 56endif() 57 58if(NOT DEFINED OpenCV_MODULES_SUFFIX) 59 if(ANDROID) 60 string(REPLACE - _ OpenCV_MODULES_SUFFIX "_${ANDROID_NDK_ABI_NAME}") 61 else() 62 set(OpenCV_MODULES_SUFFIX "") 63 endif() 64endif() 65 66if("@USE_IPPICV@" STREQUAL "TRUE") # value is defined by package builder (use STREQUAL to comply new CMake policy CMP0012) 67 if(NOT TARGET ippicv) 68 if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/@INSTALL_PATH_RELATIVE_IPPICV@") 69 add_library(ippicv STATIC IMPORTED) 70 set_target_properties(ippicv PROPERTIES 71 IMPORTED_LINK_INTERFACE_LIBRARIES "" 72 IMPORTED_LOCATION "${CMAKE_CURRENT_LIST_DIR}/@INSTALL_PATH_RELATIVE_IPPICV@" 73 ) 74 endif() 75 endif() 76endif() 77 78if(NOT TARGET opencv_core) 79 # Extract directory name from full path of the file currently being processed. 80 # Note that CMake 2.8.3 introduced CMAKE_CURRENT_LIST_DIR. We reimplement it 81 # for older versions of CMake to support these as well. 82 if(CMAKE_VERSION VERSION_LESS "2.8.3") 83 get_filename_component(CMAKE_CURRENT_LIST_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) 84 endif() 85 86 include(${CMAKE_CURRENT_LIST_DIR}/OpenCVModules${OpenCV_MODULES_SUFFIX}.cmake) 87endif() 88 89# TODO All things below should be reviewed. What is about of moving this code into related modules (special vars/hooks/files) 90 91# Version Compute Capability from which OpenCV has been compiled is remembered 92set(OpenCV_COMPUTE_CAPABILITIES @OpenCV_CUDA_CC_CONFIGCMAKE@) 93 94set(OpenCV_CUDA_VERSION @OpenCV_CUDA_VERSION@) 95set(OpenCV_USE_CUBLAS @HAVE_CUBLAS@) 96set(OpenCV_USE_CUFFT @HAVE_CUFFT@) 97set(OpenCV_USE_NVCUVID @HAVE_NVCUVID@) 98 99# Android API level from which OpenCV has been compiled is remembered 100if(ANDROID) 101 set(OpenCV_ANDROID_NATIVE_API_LEVEL @OpenCV_ANDROID_NATIVE_API_LEVEL_CONFIGCMAKE@) 102else() 103 set(OpenCV_ANDROID_NATIVE_API_LEVEL 0) 104endif() 105 106# Some additional settings are required if OpenCV is built as static libs 107set(OpenCV_SHARED @BUILD_SHARED_LIBS@) 108 109# Enables mangled install paths, that help with side by side installs 110set(OpenCV_USE_MANGLED_PATHS @OpenCV_USE_MANGLED_PATHS_CONFIGCMAKE@) 111 112# Extract the directory where *this* file has been installed (determined at cmake run-time) 113get_filename_component(OpenCV_CONFIG_PATH "${CMAKE_CURRENT_LIST_FILE}" PATH CACHE) 114 115if(NOT WIN32 OR ANDROID) 116 if(ANDROID) 117 set(OpenCV_INSTALL_PATH "${OpenCV_CONFIG_PATH}/../../..") 118 else() 119 set(OpenCV_INSTALL_PATH "${OpenCV_CONFIG_PATH}/../..") 120 endif() 121 # Get the absolute path with no ../.. relative marks, to eliminate implicit linker warnings 122 if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} VERSION_LESS 2.8) 123 get_filename_component(OpenCV_INSTALL_PATH "${OpenCV_INSTALL_PATH}" ABSOLUTE) 124 else() 125 get_filename_component(OpenCV_INSTALL_PATH "${OpenCV_INSTALL_PATH}" REALPATH) 126 endif() 127endif() 128 129# ====================================================== 130# Include directories to add to the user project: 131# ====================================================== 132 133# Provide the include directories to the caller 134set(OpenCV_INCLUDE_DIRS @OpenCV_INCLUDE_DIRS_CONFIGCMAKE@) 135 136# ====================================================== 137# Link directories to add to the user project: 138# ====================================================== 139 140# Provide the libs directories to the caller 141set(OpenCV_LIB_DIR_OPT @OpenCV_LIB_DIRS_CONFIGCMAKE@ CACHE PATH "Path where release OpenCV libraries are located") 142set(OpenCV_LIB_DIR_DBG @OpenCV_LIB_DIRS_CONFIGCMAKE@ CACHE PATH "Path where debug OpenCV libraries are located") 143set(OpenCV_3RDPARTY_LIB_DIR_OPT @OpenCV_3RDPARTY_LIB_DIRS_CONFIGCMAKE@ CACHE PATH "Path where release 3rdparty OpenCV dependencies are located") 144set(OpenCV_3RDPARTY_LIB_DIR_DBG @OpenCV_3RDPARTY_LIB_DIRS_CONFIGCMAKE@ CACHE PATH "Path where debug 3rdparty OpenCV dependencies are located") 145mark_as_advanced(FORCE OpenCV_LIB_DIR_OPT OpenCV_LIB_DIR_DBG OpenCV_3RDPARTY_LIB_DIR_OPT OpenCV_3RDPARTY_LIB_DIR_DBG OpenCV_CONFIG_PATH) 146 147# ====================================================== 148# Version variables: 149# ====================================================== 150SET(OpenCV_VERSION @OPENCV_VERSION_PLAIN@) 151SET(OpenCV_VERSION_MAJOR @OPENCV_VERSION_MAJOR@) 152SET(OpenCV_VERSION_MINOR @OPENCV_VERSION_MINOR@) 153SET(OpenCV_VERSION_PATCH @OPENCV_VERSION_PATCH@) 154SET(OpenCV_VERSION_TWEAK 0) 155SET(OpenCV_VERSION_STATUS "@OPENCV_VERSION_STATUS@") 156 157# ==================================================================== 158# Link libraries: e.g. opencv_core;opencv_imgproc; etc... 159# ==================================================================== 160 161SET(OpenCV_LIB_COMPONENTS @OPENCV_MODULES_CONFIGCMAKE@) 162SET(OpenCV_WORLD_COMPONENTS @OPENCV_WORLD_MODULES@) 163 164# ============================================================== 165# Extra include directories, needed by OpenCV 2 new structure 166# ============================================================== 167SET(OpenCV2_INCLUDE_DIRS @OpenCV2_INCLUDE_DIRS_CONFIGCMAKE@) 168if(OpenCV2_INCLUDE_DIRS) 169 list(APPEND OpenCV_INCLUDE_DIRS ${OpenCV2_INCLUDE_DIRS}) 170 171 set(OpenCV_ADD_DEBUG_RELEASE @OpenCV_ADD_DEBUG_RELEASE_CONFIGCMAKE@) 172 if(OpenCV_ADD_DEBUG_RELEASE) 173 set(OpenCV_LIB_DIR_OPT "${OpenCV_LIB_DIR_OPT}/Release") 174 set(OpenCV_LIB_DIR_DBG "${OpenCV_LIB_DIR_DBG}/Debug") 175 set(OpenCV_3RDPARTY_LIB_DIR_OPT "${OpenCV_3RDPARTY_LIB_DIR_OPT}/Release") 176 set(OpenCV_3RDPARTY_LIB_DIR_DBG "${OpenCV_3RDPARTY_LIB_DIR_DBG}/Debug") 177 endif() 178endif() 179 180# ============================================================== 181# Check OpenCV availability 182# ============================================================== 183if(ANDROID AND OpenCV_ANDROID_NATIVE_API_LEVEL GREATER ANDROID_NATIVE_API_LEVEL) 184 message(FATAL_ERROR "Minimum required by OpenCV API level is android-${OpenCV_ANDROID_NATIVE_API_LEVEL}") 185 #always FATAL_ERROR because we can't say to the caller that OpenCV is not found 186 #http://www.mail-archive.com/cmake@cmake.org/msg37831.html 187 if(OpenCV_FIND_REQUIRED) 188 message(FATAL_ERROR "Minimum required by OpenCV API level is android-${OpenCV_ANDROID_NATIVE_API_LEVEL}") 189 elseif(NOT OpenCV_FIND_QUIETLY) 190 message(WARNING "Minimum required by OpenCV API level is android-${OpenCV_ANDROID_NATIVE_API_LEVEL}") 191 endif() 192 set(OpenCV_FOUND "OpenCV_FOUND-NOTFOUND") 193 return()#Android toolchain requires CMake > 2.6 194endif() 195 196# ============================================================== 197# Form list of modules (components) to find 198# ============================================================== 199if(NOT OpenCV_FIND_COMPONENTS) 200 set(OpenCV_FIND_COMPONENTS ${OpenCV_LIB_COMPONENTS}) 201 list(REMOVE_ITEM OpenCV_FIND_COMPONENTS opencv_java) 202 if(GTest_FOUND OR GTEST_FOUND) 203 list(REMOVE_ITEM OpenCV_FIND_COMPONENTS opencv_ts) 204 endif() 205endif() 206 207# expand short module names and see if requested components exist 208set(OpenCV_FIND_COMPONENTS_ "") 209foreach(__cvcomponent ${OpenCV_FIND_COMPONENTS}) 210 if(NOT __cvcomponent MATCHES "^opencv_") 211 set(__cvcomponent opencv_${__cvcomponent}) 212 endif() 213 list(FIND OpenCV_LIB_COMPONENTS ${__cvcomponent} __cvcomponentIdx) 214 if(__cvcomponentIdx LESS 0) 215 #requested component is not found... 216 if(OpenCV_FIND_REQUIRED) 217 message(FATAL_ERROR "${__cvcomponent} is required but was not found") 218 elseif(NOT OpenCV_FIND_QUIETLY) 219 message(WARNING "${__cvcomponent} is required but was not found") 220 endif() 221 #indicate that module is NOT found 222 string(TOUPPER "${__cvcomponent}" __cvcomponentUP) 223 set(${__cvcomponentUP}_FOUND "${__cvcomponentUP}_FOUND-NOTFOUND") 224 else() 225 list(APPEND OpenCV_FIND_COMPONENTS_ ${__cvcomponent}) 226 # Not using list(APPEND) here, because OpenCV_LIBS may not exist yet. 227 # Also not clearing OpenCV_LIBS anywhere, so that multiple calls 228 # to find_package(OpenCV) with different component lists add up. 229 set(OpenCV_LIBS ${OpenCV_LIBS} "${__cvcomponent}") 230 #indicate that module is found 231 string(TOUPPER "${__cvcomponent}" __cvcomponentUP) 232 set(${__cvcomponentUP}_FOUND 1) 233 endif() 234 if(OpenCV_SHARED AND ";${OpenCV_WORLD_COMPONENTS};" MATCHES ";${__cvcomponent};" AND NOT TARGET ${__cvcomponent}) 235 get_target_property(__implib_dbg opencv_world IMPORTED_IMPLIB_DEBUG) 236 get_target_property(__implib_release opencv_world IMPORTED_IMPLIB_RELEASE) 237 get_target_property(__location_dbg opencv_world IMPORTED_LOCATION_DEBUG) 238 get_target_property(__location_release opencv_world IMPORTED_LOCATION_RELEASE) 239 add_library(${__cvcomponent} SHARED IMPORTED) 240 if(__location_dbg) 241 set_property(TARGET ${__cvcomponent} APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) 242 set_target_properties(${__cvcomponent} PROPERTIES 243 IMPORTED_IMPLIB_DEBUG "${__implib_dbg}" 244 IMPORTED_LINK_INTERFACE_LIBRARIES_DEBUG "" 245 IMPORTED_LOCATION_DEBUG "${__location_dbg}" 246 ) 247 endif() 248 if(__location_release) 249 set_property(TARGET ${__cvcomponent} APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) 250 set_target_properties(${__cvcomponent} PROPERTIES 251 IMPORTED_IMPLIB_RELEASE "${__implib_release}" 252 IMPORTED_LINK_INTERFACE_LIBRARIES_RELEASE "" 253 IMPORTED_LOCATION_RELEASE "${__location_release}" 254 ) 255 endif() 256 endif() 257endforeach() 258set(OpenCV_FIND_COMPONENTS ${OpenCV_FIND_COMPONENTS_}) 259 260# ============================================================== 261# Resolve dependencies 262# ============================================================== 263if(OpenCV_USE_MANGLED_PATHS) 264 set(OpenCV_LIB_SUFFIX ".${OpenCV_VERSION_MAJOR}.${OpenCV_VERSION_MINOR}.${OpenCV_VERSION_PATCH}") 265else() 266 set(OpenCV_LIB_SUFFIX "") 267endif() 268 269foreach(__opttype OPT DBG) 270 SET(OpenCV_LIBS_${__opttype} "${OpenCV_LIBS}") 271 SET(OpenCV_EXTRA_LIBS_${__opttype} "") 272 273 # CUDA 274 if(OpenCV_CUDA_VERSION) 275 if(NOT CUDA_FOUND) 276 find_host_package(CUDA ${OpenCV_CUDA_VERSION} EXACT REQUIRED) 277 else() 278 if(NOT CUDA_VERSION_STRING VERSION_EQUAL OpenCV_CUDA_VERSION) 279 message(FATAL_ERROR "OpenCV static library was compiled with CUDA ${OpenCV_CUDA_VERSION} support. Please, use the same version or rebuild OpenCV with CUDA ${CUDA_VERSION_STRING}") 280 endif() 281 endif() 282 283 set(OpenCV_CUDA_LIBS_ABSPATH ${CUDA_LIBRARIES}) 284 285 if(${CUDA_VERSION} VERSION_LESS "5.5") 286 list(APPEND OpenCV_CUDA_LIBS_ABSPATH ${CUDA_npp_LIBRARY}) 287 else() 288 find_cuda_helper_libs(nppc) 289 find_cuda_helper_libs(nppi) 290 find_cuda_helper_libs(npps) 291 list(APPEND OpenCV_CUDA_LIBS_ABSPATH ${CUDA_nppc_LIBRARY} ${CUDA_nppi_LIBRARY} ${CUDA_npps_LIBRARY}) 292 endif() 293 294 if(OpenCV_USE_CUBLAS) 295 list(APPEND OpenCV_CUDA_LIBS_ABSPATH ${CUDA_CUBLAS_LIBRARIES}) 296 endif() 297 298 if(OpenCV_USE_CUFFT) 299 list(APPEND OpenCV_CUDA_LIBS_ABSPATH ${CUDA_CUFFT_LIBRARIES}) 300 endif() 301 302 if(OpenCV_USE_NVCUVID) 303 list(APPEND OpenCV_CUDA_LIBS_ABSPATH ${CUDA_nvcuvid_LIBRARIES}) 304 endif() 305 306 if(WIN32) 307 list(APPEND OpenCV_CUDA_LIBS_ABSPATH ${CUDA_nvcuvenc_LIBRARIES}) 308 endif() 309 310 set(OpenCV_CUDA_LIBS_RELPATH "") 311 foreach(l ${OpenCV_CUDA_LIBS_ABSPATH}) 312 get_filename_component(_tmp ${l} PATH) 313 if(NOT ${_tmp} MATCHES "-Wl.*") 314 list(APPEND OpenCV_CUDA_LIBS_RELPATH ${_tmp}) 315 endif() 316 endforeach() 317 318 list(REMOVE_DUPLICATES OpenCV_CUDA_LIBS_RELPATH) 319 link_directories(${OpenCV_CUDA_LIBS_RELPATH}) 320 endif() 321endforeach() 322 323# ============================================================== 324# Compatibility stuff 325# ============================================================== 326if(CMAKE_BUILD_TYPE MATCHES "Debug") 327 SET(OpenCV_LIB_DIR ${OpenCV_LIB_DIR_DBG} ${OpenCV_3RDPARTY_LIB_DIR_DBG}) 328else() 329 SET(OpenCV_LIB_DIR ${OpenCV_LIB_DIR_OPT} ${OpenCV_3RDPARTY_LIB_DIR_OPT}) 330endif() 331set(OpenCV_LIBRARIES ${OpenCV_LIBS}) 332 333if(CMAKE_CROSSCOMPILING AND OpenCV_SHARED AND (CMAKE_SYSTEM_NAME MATCHES "Linux")) 334 foreach(dir ${OpenCV_LIB_DIR}) 335 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath-link,${dir}") 336 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-rpath-link,${dir}") 337 set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-rpath-link,${dir}") 338 endforeach() 339endif() 340 341 342 343# 344# Some macroses for samples 345# 346macro(ocv_check_dependencies) 347 set(OCV_DEPENDENCIES_FOUND TRUE) 348 foreach(d ${ARGN}) 349 if(NOT TARGET ${d}) 350 message(WARNING "OpenCV: Can't resolve dependency: ${d}") 351 set(OCV_DEPENDENCIES_FOUND FALSE) 352 break() 353 endif() 354 endforeach() 355endmacro() 356 357# adds include directories in such way that directories from the OpenCV source tree go first 358function(ocv_include_directories) 359 set(__add_before "") 360 file(TO_CMAKE_PATH "${OpenCV_DIR}" __baseDir) 361 foreach(dir ${ARGN}) 362 get_filename_component(__abs_dir "${dir}" ABSOLUTE) 363 if("${__abs_dir}" MATCHES "^${__baseDir}") 364 list(APPEND __add_before "${dir}") 365 else() 366 include_directories(AFTER SYSTEM "${dir}") 367 endif() 368 endforeach() 369 include_directories(BEFORE ${__add_before}) 370endfunction() 371 372macro(ocv_include_modules) 373 include_directories(BEFORE "${OpenCV_INCLUDE_DIRS}") 374endmacro() 375 376macro(ocv_include_modules_recurse) 377 include_directories(BEFORE "${OpenCV_INCLUDE_DIRS}") 378endmacro() 379 380macro(ocv_target_link_libraries) 381 target_link_libraries(${ARGN}) 382endmacro() 383 384# remove all matching elements from the list 385macro(ocv_list_filterout lst regex) 386 foreach(item ${${lst}}) 387 if(item MATCHES "${regex}") 388 list(REMOVE_ITEM ${lst} "${item}") 389 endif() 390 endforeach() 391endmacro() 392