forked from panda3d/panda3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFindOpenCV.cmake
More file actions
92 lines (82 loc) · 2.67 KB
/
FindOpenCV.cmake
File metadata and controls
92 lines (82 loc) · 2.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# Filename: FindOpenCV.cmake
# Authors: CFSworks (3 Nov, 2018)
#
# Usage:
# find_package(OpenCV [REQUIRED] [QUIET])
#
# This supports the following components:
# calib3d
# contrib
# core
# features2d
# flann
# gpu
# highgui
# imgproc
# legacy
# ml
# nonfree
# objdetect
# photo
# stitching
# superres
# video
# videoio
# videostab
#
# Once done this will define:
# OPENCV_FOUND - system has OpenCV
# OpenCV_INCLUDE_DIRS - the include dir(s) containing OpenCV header files
# OpenCV_comp_LIBRARY - the path to the OpenCV library for the particular
# component
# OpenCV_LIBS - the paths to the OpenCV libraries for the requested
# component(s)
# OpenCV_VERSION_MAJOR- a "best guess" of the major version (X.x)
# OpenCV_VERSION_MINOR- a "best guess" of the minor version (x.X)
#
set(OpenCV_INCLUDE_DIRS)
find_path(OpenCV_V1_INCLUDE_DIR
NAMES "cv.h"
PATH_SUFFIXES "opencv")
mark_as_advanced(OpenCV_V1_INCLUDE_DIR)
if(OpenCV_V1_INCLUDE_DIR)
list(APPEND OpenCV_INCLUDE_DIRS "${OpenCV_V1_INCLUDE_DIR}")
# This is a wild guess:
set(OpenCV_VERSION_MAJOR 1)
set(OpenCV_VERSION_MINOR 0)
endif()
find_path(OpenCV_V2_INCLUDE_DIR "opencv2/core/version.hpp")
mark_as_advanced(OpenCV_V2_INCLUDE_DIR)
if(OpenCV_V2_INCLUDE_DIR)
list(APPEND OpenCV_INCLUDE_DIRS "${OpenCV_V2_INCLUDE_DIR}")
file(STRINGS "${OpenCV_V2_INCLUDE_DIR}/opencv2/core/version.hpp"
_version_major REGEX "#define CV_VERSION_EPOCH")
file(STRINGS "${OpenCV_V2_INCLUDE_DIR}/opencv2/core/version.hpp"
_version_minor REGEX "#define CV_VERSION_MAJOR")
string(REGEX REPLACE "[^0-9]" "" OpenCV_VERSION_MAJOR "${_version_major}")
string(REGEX REPLACE "[^0-9]" "" OpenCV_VERSION_MINOR "${_version_minor}")
unset(_version_major)
unset(_version_minor)
endif()
set(OpenCV_LIBS)
foreach(_component calib3d contrib core features2d flann gpu highgui imgproc
legacy ml nonfree objdetect photo stitching superres video
videoio videostab)
list(FIND OpenCV_FIND_COMPONENTS "${_component}" _index)
if(_index GREATER -1 OR _component STREQUAL "core")
if(NOT OpenCV_${_component}_LIBRARY)
find_library(OpenCV_${_component}_LIBRARY
NAMES "opencv_${_component}")
endif()
if(OpenCV_${_component}_LIBRARY)
list(APPEND OpenCV_LIBS "${OpenCV_${_component}_LIBRARY}")
set(OpenCV_${_component}_FOUND ON)
endif()
endif()
unset(_index)
endforeach(_component)
unset(_component)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(OpenCV HANDLE_COMPONENTS
REQUIRED_VARS OpenCV_INCLUDE_DIRS OpenCV_LIBS
OpenCV_VERSION_MAJOR OpenCV_VERSION_MINOR)