1 # ===================================================================================
2 # The OpenCV CMake configuration file
4 # ** File generated automatically, do not modify **
6 # Usage from an external project:
7 # In your CMakeLists.txt, add these lines:
9 # FIND_PACKAGE(OpenCV REQUIRED)
10 # TARGET_LINK_LIBRARIES(MY_TARGET_NAME ${OpenCV_LIBS})
12 # Or you can search for specific OpenCV modules:
14 # FIND_PACKAGE(OpenCV REQUIRED core highgui)
16 # If the module is found then OPENCV_<MODULE>_FOUND is set to TRUE.
18 # This file will define the following variables:
19 # - OpenCV_LIBS : The list of all imported targets for OpenCV modules.
20 # - OpenCV_INCLUDE_DIRS : The OpenCV include directories.
21 # - OpenCV_COMPUTE_CAPABILITIES : The version of compute capability
22 # - OpenCV_ANDROID_NATIVE_API_LEVEL : Minimum required level of Android API
23 # - OpenCV_VERSION : The version of this OpenCV build: "@OPENCV_VERSION_PLAIN@"
24 # - OpenCV_VERSION_MAJOR : Major version part of OpenCV_VERSION: "@OPENCV_VERSION_MAJOR@"
25 # - OpenCV_VERSION_MINOR : Minor version part of OpenCV_VERSION: "@OPENCV_VERSION_MINOR@"
26 # - OpenCV_VERSION_PATCH : Patch version part of OpenCV_VERSION: "@OPENCV_VERSION_PATCH@"
27 # - OpenCV_VERSION_TWEAK : Tweak version part of OpenCV_VERSION: "@OPENCV_VERSION_TWEAK@"
28 # - OpenCV_VERSION_STATUS : Development status of this build: "@OPENCV_VERSION_STATUS@"
32 # - OpenCV_CONFIG_PATH
33 # - OpenCV_INSTALL_PATH (not set on Windows)
34 # - OpenCV_LIB_COMPONENTS
35 # - OpenCV_USE_MANGLED_PATHS
36 # - OpenCV_HAVE_ANDROID_CAMERA
38 # ===================================================================================
40 set(modules_file_suffix "")
42 string(REPLACE - _ modules_file_suffix "_${ANDROID_NDK_ABI_NAME}")
45 include(${CMAKE_CURRENT_LIST_DIR}/OpenCVModules${modules_file_suffix}.cmake)
47 # TODO All things below should be reviewed. What is about of moving this code into related modules (special vars/hooks/files)
49 # Version Compute Capability from which OpenCV has been compiled is remembered
50 set(OpenCV_COMPUTE_CAPABILITIES @OpenCV_CUDA_CC_CONFIGCMAKE@)
52 set(OpenCV_CUDA_VERSION @OpenCV_CUDA_VERSION@)
53 set(OpenCV_USE_CUBLAS @HAVE_CUBLAS@)
54 set(OpenCV_USE_CUFFT @HAVE_CUFFT@)
55 set(OpenCV_USE_NVCUVID @HAVE_NVCUVID@)
57 # Android API level from which OpenCV has been compiled is remembered
58 set(OpenCV_ANDROID_NATIVE_API_LEVEL @OpenCV_ANDROID_NATIVE_API_LEVEL_CONFIGCMAKE@)
60 # Some additional settings are required if OpenCV is built as static libs
61 set(OpenCV_SHARED @BUILD_SHARED_LIBS@)
63 # Enables mangled install paths, that help with side by side installs
64 set(OpenCV_USE_MANGLED_PATHS @OpenCV_USE_MANGLED_PATHS_CONFIGCMAKE@)
66 # Extract the directory where *this* file has been installed (determined at cmake run-time)
67 get_filename_component(OpenCV_CONFIG_PATH "${CMAKE_CURRENT_LIST_FILE}" PATH CACHE)
69 if(NOT WIN32 OR OpenCV_ANDROID_NATIVE_API_LEVEL GREATER 0)
70 if(OpenCV_ANDROID_NATIVE_API_LEVEL GREATER 0)
71 set(OpenCV_INSTALL_PATH "${OpenCV_CONFIG_PATH}/../../..")
73 set(OpenCV_INSTALL_PATH "${OpenCV_CONFIG_PATH}/../..")
75 # Get the absolute path with no ../.. relative marks, to eliminate implicit linker warnings
76 if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} VERSION_LESS 2.8)
77 get_filename_component(OpenCV_INSTALL_PATH "${OpenCV_INSTALL_PATH}" ABSOLUTE)
79 get_filename_component(OpenCV_INSTALL_PATH "${OpenCV_INSTALL_PATH}" REALPATH)
83 # Presence of Android native camera wrappers
84 set(OpenCV_HAVE_ANDROID_CAMERA @HAVE_opencv_androidcamera@)
86 # ======================================================
87 # Include directories to add to the user project:
88 # ======================================================
90 # Provide the include directories to the caller
91 set(OpenCV_INCLUDE_DIRS @OpenCV_INCLUDE_DIRS_CONFIGCMAKE@)
93 # ======================================================
94 # Link directories to add to the user project:
95 # ======================================================
97 # Provide the libs directories to the caller
98 set(OpenCV_LIB_DIR_OPT @OpenCV_LIB_DIRS_CONFIGCMAKE@ CACHE PATH "Path where release OpenCV libraries are located")
99 set(OpenCV_LIB_DIR_DBG @OpenCV_LIB_DIRS_CONFIGCMAKE@ CACHE PATH "Path where debug OpenCV libraries are located")
100 set(OpenCV_3RDPARTY_LIB_DIR_OPT @OpenCV_3RDPARTY_LIB_DIRS_CONFIGCMAKE@ CACHE PATH "Path where release 3rdpaty OpenCV dependencies are located")
101 set(OpenCV_3RDPARTY_LIB_DIR_DBG @OpenCV_3RDPARTY_LIB_DIRS_CONFIGCMAKE@ CACHE PATH "Path where debug 3rdpaty OpenCV dependencies are located")
102 mark_as_advanced(FORCE OpenCV_LIB_DIR_OPT OpenCV_LIB_DIR_DBG OpenCV_3RDPARTY_LIB_DIR_OPT OpenCV_3RDPARTY_LIB_DIR_DBG OpenCV_CONFIG_PATH)
104 # ======================================================
106 # ======================================================
107 SET(OpenCV_VERSION @OPENCV_VERSION_PLAIN@)
108 SET(OpenCV_VERSION_MAJOR @OPENCV_VERSION_MAJOR@)
109 SET(OpenCV_VERSION_MINOR @OPENCV_VERSION_MINOR@)
110 SET(OpenCV_VERSION_PATCH @OPENCV_VERSION_PATCH@)
111 SET(OpenCV_VERSION_TWEAK @OPENCV_VERSION_TWEAK@)
112 SET(OpenCV_VERSION_STATUS "@OPENCV_VERSION_STATUS@")
114 # ====================================================================
115 # Link libraries: e.g. opencv_core;opencv_imgproc; etc...
116 # ====================================================================
118 SET(OpenCV_LIB_COMPONENTS @OPENCV_MODULES_CONFIGCMAKE@)
120 # ==============================================================
121 # Extra include directories, needed by OpenCV 2 new structure
122 # ==============================================================
123 SET(OpenCV2_INCLUDE_DIRS @OpenCV2_INCLUDE_DIRS_CONFIGCMAKE@)
124 if(OpenCV2_INCLUDE_DIRS)
125 include_directories(${OpenCV2_INCLUDE_DIRS})
126 list(APPEND OpenCV_INCLUDE_DIRS ${OpenCV2_INCLUDE_DIRS})
128 set(OpenCV_ADD_DEBUG_RELEASE @OpenCV_ADD_DEBUG_RELEASE_CONFIGCMAKE@)
129 if(OpenCV_ADD_DEBUG_RELEASE)
130 set(OpenCV_LIB_DIR_OPT "${OpenCV_LIB_DIR_OPT}/Release")
131 set(OpenCV_LIB_DIR_DBG "${OpenCV_LIB_DIR_DBG}/Debug")
132 set(OpenCV_3RDPARTY_LIB_DIR_OPT "${OpenCV_3RDPARTY_LIB_DIR_OPT}/Release")
133 set(OpenCV_3RDPARTY_LIB_DIR_DBG "${OpenCV_3RDPARTY_LIB_DIR_DBG}/Debug")
137 # ==============================================================
138 # Check OpenCV availability
139 # ==============================================================
140 if(ANDROID AND OpenCV_ANDROID_NATIVE_API_LEVEL GREATER ANDROID_NATIVE_API_LEVEL)
141 message(FATAL_ERROR "Minimum required by OpenCV API level is android-${OpenCV_ANDROID_NATIVE_API_LEVEL}")
142 #always FATAL_ERROR because we can't say to the caller that OpenCV is not found
143 #http://www.mail-archive.com/cmake@cmake.org/msg37831.html
144 if(OpenCV_FIND_REQUIRED)
145 message(FATAL_ERROR "Minimum required by OpenCV API level is android-${OpenCV_ANDROID_NATIVE_API_LEVEL}")
146 elseif(NOT OpenCV_FIND_QUIETLY)
147 message(WARNING "Minimum required by OpenCV API level is android-${OpenCV_ANDROID_NATIVE_API_LEVEL}")
149 set(OpenCV_FOUND "OpenCV_FOUND-NOTFOUND")
150 return()#Android toolchain requires CMake > 2.6
153 # ==============================================================
154 # Form list of modules (components) to find
155 # ==============================================================
156 if(NOT OpenCV_FIND_COMPONENTS)
157 set(OpenCV_FIND_COMPONENTS ${OpenCV_LIB_COMPONENTS})
158 list(REMOVE_ITEM OpenCV_FIND_COMPONENTS opencv_java)
159 if(GTest_FOUND OR GTEST_FOUND)
160 list(REMOVE_ITEM OpenCV_FIND_COMPONENTS opencv_ts)
164 # expand short module names and see if requested components exist
165 set(OpenCV_FIND_COMPONENTS_ "")
166 foreach(__cvcomponent ${OpenCV_FIND_COMPONENTS})
167 if(NOT __cvcomponent MATCHES "^opencv_")
168 set(__cvcomponent opencv_${__cvcomponent})
170 list(FIND OpenCV_LIB_COMPONENTS ${__cvcomponent} __cvcomponentIdx)
171 if(__cvcomponentIdx LESS 0)
172 #requested component is not found...
173 if(OpenCV_FIND_REQUIRED)
174 message(FATAL_ERROR "${__cvcomponent} is required but was not found")
175 elseif(NOT OpenCV_FIND_QUIETLY)
176 message(WARNING "${__cvcomponent} is required but was not found")
178 #indicate that module is NOT found
179 string(TOUPPER "${__cvcomponent}" __cvcomponent)
180 set(${__cvcomponent}_FOUND "${__cvcomponent}_FOUND-NOTFOUND")
182 list(APPEND OpenCV_FIND_COMPONENTS_ ${__cvcomponent})
183 #indicate that module is found
184 string(TOUPPER "${__cvcomponent}" __cvcomponent)
185 set(${__cvcomponent}_FOUND 1)
188 set(OpenCV_FIND_COMPONENTS ${OpenCV_FIND_COMPONENTS_})
190 # ==============================================================
191 # Resolve dependencies
192 # ==============================================================
193 if(OpenCV_USE_MANGLED_PATHS)
194 set(OpenCV_LIB_SUFFIX ".${OpenCV_VERSION_MAJOR}.${OpenCV_VERSION_MINOR}.${OpenCV_VERSION_PATCH}")
196 set(OpenCV_LIB_SUFFIX "")
199 SET(OpenCV_LIBS "${OpenCV_LIB_COMPONENTS}")
201 foreach(__opttype OPT DBG)
202 SET(OpenCV_LIBS_${__opttype} "${OpenCV_LIBS}")
203 SET(OpenCV_EXTRA_LIBS_${__opttype} "")
206 if(OpenCV_CUDA_VERSION AND (CMAKE_CROSSCOMPILING OR (WIN32 AND NOT OpenCV_SHARED)))
208 find_package(CUDA ${OpenCV_CUDA_VERSION} EXACT REQUIRED)
210 if(NOT CUDA_VERSION_STRING VERSION_EQUAL OpenCV_CUDA_VERSION)
211 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}")
215 list(APPEND OpenCV_EXTRA_LIBS_${__opttype} ${CUDA_LIBRARIES})
217 if(${CUDA_VERSION} VERSION_LESS "5.5")
218 list(APPEND OpenCV_EXTRA_LIBS_${__opttype} ${CUDA_npp_LIBRARY})
220 find_cuda_helper_libs(nppc)
221 find_cuda_helper_libs(nppi)
222 find_cuda_helper_libs(npps)
223 list(APPEND OpenCV_EXTRA_LIBS_${__opttype} ${CUDA_nppc_LIBRARY} ${CUDA_nppi_LIBRARY} ${CUDA_npps_LIBRARY})
226 if(OpenCV_USE_CUBLAS)
227 list(APPEND OpenCV_EXTRA_LIBS_${__opttype} ${CUDA_CUBLAS_LIBRARIES})
231 list(APPEND OpenCV_EXTRA_LIBS_${__opttype} ${CUDA_CUFFT_LIBRARIES})
234 if(OpenCV_USE_NVCUVID)
235 list(APPEND OpenCV_EXTRA_LIBS_${__opttype} ${CUDA_nvcuvid_LIBRARIES})
239 list(APPEND OpenCV_EXTRA_LIBS_${__opttype} ${CUDA_nvcuvenc_LIBRARIES})
244 # ==============================================================
245 # Android camera helper macro
246 # ==============================================================
247 if(OpenCV_HAVE_ANDROID_CAMERA)
248 macro(COPY_NATIVE_CAMERA_LIBS target)
249 get_target_property(target_location ${target} LOCATION)
250 get_filename_component(target_location "${target_location}" PATH)
251 file(GLOB camera_wrappers "${OpenCV_LIB_DIR_OPT}/libnative_camera_r*.so")
252 foreach(wrapper ${camera_wrappers})
256 COMMAND ${CMAKE_COMMAND} -E copy "${wrapper}" "${target_location}"
262 # ==============================================================
263 # Compatibility stuff
264 # ==============================================================
265 if(CMAKE_BUILD_TYPE MATCHES "Debug")
266 SET(OpenCV_LIB_DIR ${OpenCV_LIB_DIR_DBG} ${OpenCV_3RDPARTY_LIB_DIR_DBG})
268 SET(OpenCV_LIB_DIR ${OpenCV_LIB_DIR_OPT} ${OpenCV_3RDPARTY_LIB_DIR_OPT})
270 set(OpenCV_LIBRARIES ${OpenCV_LIBS})
272 if(CMAKE_CROSSCOMPILING AND OpenCV_SHARED AND (CMAKE_SYSTEM_NAME MATCHES "Linux"))
273 foreach(dir ${OpenCV_LIB_DIR})
274 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath-link,${dir}")
275 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-rpath-link,${dir}")
276 set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-rpath-link,${dir}")
283 # Some macroses for samples
285 macro(ocv_check_dependencies)
286 set(OCV_DEPENDENCIES_FOUND TRUE)
289 set(OCV_DEPENDENCIES_FOUND FALSE)
295 # adds include directories in such way that directories from the OpenCV source tree go first
296 function(ocv_include_directories)
298 file(TO_CMAKE_PATH "${OpenCV_DIR}" __baseDir)
300 get_filename_component(__abs_dir "${dir}" ABSOLUTE)
301 if("${__abs_dir}" MATCHES "^${__baseDir}")
302 list(APPEND __add_before "${dir}")
304 include_directories(AFTER SYSTEM "${dir}")
307 include_directories(BEFORE ${__add_before})
310 macro(ocv_include_modules)
311 include_directories(BEFORE "${OpenCV_INCLUDE_DIRS}")
314 # remove all matching elements from the list
315 macro(ocv_list_filterout lst regex)
316 foreach(item ${${lst}})
317 if(item MATCHES "${regex}")
318 list(REMOVE_ITEM ${lst} "${item}")