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}) # Not needed for CMake >= 2.8.11
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#    You can also mark OpenCV components as optional:
18
19#    find_package(OpenCV REQUIRED core OPTIONAL_COMPONENTS viz)
20#
21#    If the module is found then OPENCV_<MODULE>_FOUND is set to TRUE.
22#
23#    This file will define the following variables:
24#      - OpenCV_LIBS                     : The list of all imported targets for OpenCV modules.
25#      - OpenCV_INCLUDE_DIRS             : The OpenCV include directories.
26#      - OpenCV_COMPUTE_CAPABILITIES     : The version of compute capability.
27#      - OpenCV_ANDROID_NATIVE_API_LEVEL : Minimum required level of Android API.
28#      - OpenCV_VERSION                  : The version of this OpenCV build: "3.4.5"
29#      - OpenCV_VERSION_MAJOR            : Major version part of OpenCV_VERSION: "3"
30#      - OpenCV_VERSION_MINOR            : Minor version part of OpenCV_VERSION: "4"
31#      - OpenCV_VERSION_PATCH            : Patch version part of OpenCV_VERSION: "5"
32#      - OpenCV_VERSION_STATUS           : Development status of this build: ""
33#
34#    Advanced variables:
35#      - OpenCV_SHARED                   : Use OpenCV as shared library
36#      - OpenCV_INSTALL_PATH             : OpenCV location
37#      - OpenCV_LIB_COMPONENTS           : Present OpenCV modules list
38#      - OpenCV_USE_MANGLED_PATHS        : Mangled OpenCV path flag
39#
40#    Deprecated variables:
41#      - OpenCV_VERSION_TWEAK            : Always "0"
42#
43# ===================================================================================
44
45# ======================================================
46#  Version variables:
47# ======================================================
48SET(OpenCV_VERSION 3.4.5)
49SET(OpenCV_VERSION_MAJOR  3)
50SET(OpenCV_VERSION_MINOR  4)
51SET(OpenCV_VERSION_PATCH  5)
52SET(OpenCV_VERSION_TWEAK  0)
53SET(OpenCV_VERSION_STATUS "")
54
55include(FindPackageHandleStandardArgs)
56
57if(NOT CMAKE_VERSION VERSION_LESS 2.8.8
58    AND OpenCV_FIND_COMPONENTS  # prevent excessive output
59)
60  # HANDLE_COMPONENTS was introduced in CMake 2.8.8
61  list(APPEND _OpenCV_FPHSA_ARGS HANDLE_COMPONENTS)
62  # The missing components will be handled by the FindPackageHandleStandardArgs
63  # module.
64  set(_OpenCV_HANDLE_COMPONENTS_MANUALLY FALSE)
65else()
66  # The missing components will be handled by this config.
67  set(_OpenCV_HANDLE_COMPONENTS_MANUALLY TRUE)
68endif()
69
70# Extract directory name from full path of the file currently being processed.
71# Note that CMake 2.8.3 introduced CMAKE_CURRENT_LIST_DIR. We reimplement it
72# for older versions of CMake to support these as well.
73if(CMAKE_VERSION VERSION_LESS "2.8.3")
74  get_filename_component(CMAKE_CURRENT_LIST_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
75endif()
76
77# Extract the directory where *this* file has been installed (determined at cmake run-time)
78# Get the absolute path with no ../.. relative marks, to eliminate implicit linker warnings
79set(OpenCV_CONFIG_PATH "${CMAKE_CURRENT_LIST_DIR}")
80get_filename_component(OpenCV_INSTALL_PATH "${OpenCV_CONFIG_PATH}/../../" REALPATH)
81
82# Search packages for host system instead of packages for target system.
83# in case of cross compilation this macro should be defined by toolchain file
84if(NOT COMMAND find_host_package)
85    macro(find_host_package)
86        find_package(${ARGN})
87    endmacro()
88endif()
89if(NOT COMMAND find_host_program)
90    macro(find_host_program)
91        find_program(${ARGN})
92    endmacro()
93endif()
94
95
96
97
98
99
100
101
102# Some additional settings are required if OpenCV is built as static libs
103set(OpenCV_SHARED OFF)
104
105# Enables mangled install paths, that help with side by side installs
106set(OpenCV_USE_MANGLED_PATHS FALSE)
107
108set(OpenCV_LIB_COMPONENTS opencv_calib3d;opencv_core;opencv_features2d;opencv_imgcodecs;opencv_imgproc;opencv_video)
109set(OpenCV_INCLUDE_DIRS "${OpenCV_INSTALL_PATH}/include" "${OpenCV_INSTALL_PATH}/include/opencv")
110
111if(NOT TARGET opencv_core)
112  include(${CMAKE_CURRENT_LIST_DIR}/OpenCVModules${OpenCV_MODULES_SUFFIX}.cmake)
113endif()
114
115if(NOT CMAKE_VERSION VERSION_LESS "2.8.11")
116  # Target property INTERFACE_INCLUDE_DIRECTORIES available since 2.8.11:
117  # * http://www.cmake.org/cmake/help/v2.8.11/cmake.html#prop_tgt:INTERFACE_INCLUDE_DIRECTORIES
118  foreach(__component ${OpenCV_LIB_COMPONENTS})
119    if(TARGET ${__component})
120      set_target_properties(
121          ${__component}
122          PROPERTIES
123          INTERFACE_INCLUDE_DIRECTORIES "${OpenCV_INCLUDE_DIRS}"
124      )
125    endif()
126  endforeach()
127endif()
128
129
130if(NOT DEFINED OPENCV_MAP_IMPORTED_CONFIG)
131  if(CMAKE_GENERATOR MATCHES "Visual Studio" OR MSVC)
132    # OpenCV supports Debug and Release builds only.
133    # But MSVS has 'RelWithDebInfo' 'MinSizeRel' configurations for applications.
134    # By default CMake maps these configuration on the first available (Debug) which is wrong.
135    # Non-Debug build of Application can't be used with OpenCV Debug build (ABI mismatch problem)
136    # Add mapping of RelWithDebInfo and MinSizeRel to Release here
137    set(OPENCV_MAP_IMPORTED_CONFIG "RELWITHDEBINFO=!Release;MINSIZEREL=!Release")
138  endif()
139endif()
140set(__remap_warnings "")
141macro(ocv_map_imported_config target)
142  if(DEFINED OPENCV_MAP_IMPORTED_CONFIG) # list, "RELWITHDEBINFO=Release;MINSIZEREL=Release"
143    get_target_property(__available_configurations ${target} IMPORTED_CONFIGURATIONS)
144    foreach(remap ${OPENCV_MAP_IMPORTED_CONFIG})
145      if(remap MATCHES "^(.+)=(!?)([^!]+)$")
146        set(__remap_config "${CMAKE_MATCH_1}")
147        set(__final_config "${CMAKE_MATCH_3}")
148        set(__force_flag "${CMAKE_MATCH_2}")
149        string(TOUPPER "${__final_config}" __final_config_upper)
150        string(TOUPPER "${__remap_config}" __remap_config_upper)
151        if(";${__available_configurations};" MATCHES ";${__remap_config_upper};" AND NOT "${__force_flag}" STREQUAL "!")
152          # configuration already exists, skip remap
153          set(__remap_warnings "${__remap_warnings}... Configuration already exists ${__remap_config} (skip mapping ${__remap_config} => ${__final_config}) (available configurations: ${__available_configurations})\n")
154          continue()
155        endif()
156        if(__available_configurations AND NOT ";${__available_configurations};" MATCHES ";${__final_config_upper};")
157          # skip, configuration is not available
158          if(NOT "${__force_flag}" STREQUAL "!")
159            set(__remap_warnings "${__remap_warnings}... Configuration is not available '${__final_config}' for ${target}, build may fail (available configurations: ${__available_configurations})\n")
160          endif()
161        endif()
162        set_target_properties(${target} PROPERTIES
163            MAP_IMPORTED_CONFIG_${__remap_config} "${__final_config}"
164        )
165      else()
166        message(WARNING "Invalid entry of OPENCV_MAP_IMPORTED_CONFIG: '${remap}' (${OPENCV_MAP_IMPORTED_CONFIG})")
167      endif()
168    endforeach()
169  endif()
170endmacro()
171
172
173# ==============================================================
174#  Form list of modules (components) to find
175# ==============================================================
176if(NOT OpenCV_FIND_COMPONENTS)
177  set(OpenCV_FIND_COMPONENTS ${OpenCV_LIB_COMPONENTS})
178  list(REMOVE_ITEM OpenCV_FIND_COMPONENTS opencv_java)
179  if(GTest_FOUND OR GTEST_FOUND)
180    list(REMOVE_ITEM OpenCV_FIND_COMPONENTS opencv_ts)
181  endif()
182endif()
183
184set(OpenCV_WORLD_COMPONENTS )
185
186# expand short module names and see if requested components exist
187foreach(__cvcomponent ${OpenCV_FIND_COMPONENTS})
188  # Store the name of the original component so we can set the
189  # OpenCV_<component>_FOUND variable which can be checked by the user.
190  set (__original_cvcomponent ${__cvcomponent})
191  if(NOT __cvcomponent MATCHES "^opencv_")
192    set(__cvcomponent opencv_${__cvcomponent})
193  endif()
194  list(FIND OpenCV_LIB_COMPONENTS ${__cvcomponent} __cvcomponentIdx)
195  if(__cvcomponentIdx LESS 0)
196    if(_OpenCV_HANDLE_COMPONENTS_MANUALLY)
197      # Either the component is required or the user did not set any components at
198      # all. In the latter case, the OpenCV_FIND_REQUIRED_<component> variable
199      # will not be defined since it is not set by this config. So let's assume
200      # the implicitly set components are always required.
201      if(NOT DEFINED OpenCV_FIND_REQUIRED_${__original_cvcomponent} OR
202          OpenCV_FIND_REQUIRED_${__original_cvcomponent})
203        message(FATAL_ERROR "${__cvcomponent} is required but was not found")
204      elseif(NOT OpenCV_FIND_QUIETLY)
205        # The component was marked as optional using OPTIONAL_COMPONENTS
206        message(WARNING "Optional component ${__cvcomponent} was not found")
207      endif()
208    endif(_OpenCV_HANDLE_COMPONENTS_MANUALLY)
209    #indicate that module is NOT found
210    string(TOUPPER "${__cvcomponent}" __cvcomponentUP)
211    set(${__cvcomponentUP}_FOUND "${__cvcomponentUP}_FOUND-NOTFOUND")
212    set(OpenCV_${__original_cvcomponent}_FOUND FALSE)
213  else()
214    # Not using list(APPEND) here, because OpenCV_LIBS may not exist yet.
215    # Also not clearing OpenCV_LIBS anywhere, so that multiple calls
216    # to find_package(OpenCV) with different component lists add up.
217    set(OpenCV_LIBS ${OpenCV_LIBS} "${__cvcomponent}")
218    #indicate that module is found
219    string(TOUPPER "${__cvcomponent}" __cvcomponentUP)
220    set(${__cvcomponentUP}_FOUND 1)
221    set(OpenCV_${__original_cvcomponent}_FOUND TRUE)
222  endif()
223  if(OpenCV_SHARED AND ";${OpenCV_WORLD_COMPONENTS};" MATCHES ";${__cvcomponent};" AND NOT TARGET ${__cvcomponent})
224    get_target_property(__implib_dbg opencv_world IMPORTED_IMPLIB_DEBUG)
225    get_target_property(__implib_release opencv_world  IMPORTED_IMPLIB_RELEASE)
226    get_target_property(__location_dbg opencv_world IMPORTED_LOCATION_DEBUG)
227    get_target_property(__location_release opencv_world  IMPORTED_LOCATION_RELEASE)
228    get_target_property(__include_dir opencv_world INTERFACE_INCLUDE_DIRECTORIES)
229    add_library(${__cvcomponent} SHARED IMPORTED)
230    set_target_properties(${__cvcomponent} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${__include_dir}")
231    if(__location_dbg)
232      set_property(TARGET ${__cvcomponent} APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
233      set_target_properties(${__cvcomponent} PROPERTIES
234        IMPORTED_IMPLIB_DEBUG "${__implib_dbg}"
235        IMPORTED_LINK_INTERFACE_LIBRARIES_DEBUG ""
236        IMPORTED_LOCATION_DEBUG "${__location_dbg}"
237      )
238    endif()
239    if(__location_release)
240      set_property(TARGET ${__cvcomponent} APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
241      set_target_properties(${__cvcomponent} PROPERTIES
242        IMPORTED_IMPLIB_RELEASE "${__implib_release}"
243        IMPORTED_LINK_INTERFACE_LIBRARIES_RELEASE ""
244        IMPORTED_LOCATION_RELEASE "${__location_release}"
245      )
246    endif()
247  endif()
248  if(TARGET ${__cvcomponent})
249    ocv_map_imported_config(${__cvcomponent})
250  endif()
251endforeach()
252
253if(__remap_warnings AND NOT OpenCV_FIND_QUIETLY)
254  message("OpenCV: configurations remap warnings:\n${__remap_warnings}OpenCV: Check variable OPENCV_MAP_IMPORTED_CONFIG=${OPENCV_MAP_IMPORTED_CONFIG}")
255endif()
256
257# ==============================================================
258# Compatibility stuff
259# ==============================================================
260set(OpenCV_LIBRARIES ${OpenCV_LIBS})
261
262#
263# Some macros for samples
264#
265macro(ocv_check_dependencies)
266  set(OCV_DEPENDENCIES_FOUND TRUE)
267  foreach(d ${ARGN})
268    if(NOT TARGET ${d})
269      message(WARNING "OpenCV: Can't resolve dependency: ${d}")
270      set(OCV_DEPENDENCIES_FOUND FALSE)
271      break()
272    endif()
273  endforeach()
274endmacro()
275
276# adds include directories in such way that directories from the OpenCV source tree go first
277function(ocv_include_directories)
278  set(__add_before "")
279  file(TO_CMAKE_PATH "${OpenCV_INSTALL_PATH}" __baseDir)
280  foreach(dir ${ARGN})
281    get_filename_component(__abs_dir "${dir}" ABSOLUTE)
282    if("${__abs_dir}" MATCHES "^${__baseDir}")
283      list(APPEND __add_before "${dir}")
284    else()
285      include_directories(AFTER SYSTEM "${dir}")
286    endif()
287  endforeach()
288  include_directories(BEFORE ${__add_before})
289endfunction()
290
291macro(ocv_include_modules)
292  include_directories(BEFORE "${OpenCV_INCLUDE_DIRS}")
293endmacro()
294
295macro(ocv_include_modules_recurse)
296  include_directories(BEFORE "${OpenCV_INCLUDE_DIRS}")
297endmacro()
298
299macro(ocv_target_link_libraries)
300  target_link_libraries(${ARGN})
301endmacro()
302
303# remove all matching elements from the list
304macro(ocv_list_filterout lst regex)
305  foreach(item ${${lst}})
306    if(item MATCHES "${regex}")
307      list(REMOVE_ITEM ${lst} "${item}")
308    endif()
309  endforeach()
310endmacro()
311
312# We do not actually need REQUIRED_VARS to be checked for. Just use the
313# installation directory for the status.
314find_package_handle_standard_args(OpenCV REQUIRED_VARS OpenCV_INSTALL_PATH
315                                  VERSION_VAR OpenCV_VERSION ${_OpenCV_FPHSA_ARGS})
316