OpenCVConfig.cmake 15 KB

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