forked from ohhi/conan-opencv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconanfile.py
142 lines (133 loc) · 5.28 KB
/
conanfile.py
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
from conans import ConanFile, CMake
import os, fnmatch
class OpenCVConan(ConanFile):
# Description must be very short for conan.io
description = "OpenCV: Open Source Computer Vision Library."
name = "OpenCV"
version = "3.2.0"
opencv_version_suffix = "320"
settings = "os", "compiler", "build_type", "arch"
requires = "libjpeg-turbo/1.5.1@lasote/stable"
options = {
"shared": [True, False]
}
default_options = "shared=False"
url = "https://github.com/ohhi/conan-opencv"
license = "http://http://opencv.org/license.html"
generators = "cmake", "txt"
short_paths = True
def source(self):
self.run("git clone https://github.com/opencv/opencv.git")
self.run("cd opencv && git checkout tags/3.2.0")
def imports(self):
self.copy("*", dst="jpeg-turbo", src="")
def build(self):
cmake = CMake(self)
cmake_options = {
"CMAKE_INSTALL_PREFIX": "install",
"WITH_OPENXL": False,
"WITH_IPP": True,
"WITH_QT": False,
"WITH_GTK": False,
"WITH_OPENGL": False,
"WITH_CUDA": False,
"WITH_JPEG": True,
"JPEG_INCLUDE_DIR": "jpeg-turbo/include",
"JPEG_LIBRARY": "jpeg-turbo/lib/jpeg-static.lib",
"BUILD_JPEG": False,
"WITH_PNG": True,
"BUILD_PNG": True,
"WITH_JASPER": True,
"BUILD_JASPER": True,
"WITH_ZLIB": True,
"BUILD_ZLIB": True,
"WITH_TIFF": True,
"BUILD_TIFF": True,
"WITH_TBB": False,
"BUILD_TBB": False,
"WITH_OPENEXR": True,
"BUILD_OPENEXR": True,
"WITH_WEBP": True,
"BUILD_WEBP": True,
"BUILD_SHARED_LIBS": self.options.shared,
"BUILD_TESTS": False,
"BUILD_PERF_TESTS": False,
"BUILD_opencv_apps": False,
"CPACK_BINARY_NSIS": False,
"BUILD_opencv_calib3d": True,
"BUILD_opencv_features2d": True,
"BUILD_opencv_flann": True,
"BUILD_opencv_highgui": True,
"BUILD_opencv_imgcodecs": True,
"BUILD_opencv_imgproc": True,
"BUILD_opencv_ml": True,
"BUILD_opencv_objectdetect": True,
"BUILD_opencv_photo": True,
"BUILD_opencv_shape": True,
"BUILD_opencv_stitching": True,
"BUILD_opencv_superres": True,
"BUILD_opencv_ts": True,
"BUILD_opencv_video": True,
"BUILD_opencv_videoio": True,
"BUILD_opencv_videostab": True
}
if self.settings.compiler == "Visual Studio":
cmake_options["BUILD_WITH_STATIC_CRT"] = self.settings.compiler.runtime in ["MT","MTd"]
cmake.configure(defs=cmake_options, source_dir="opencv")
cmake.build(target="install")
def package(self):
self.copy(pattern="*.h*", dst="include", src =os.path.join("install", "include"), keep_path=True)
if self.settings.os == "Windows":
self.copy(pattern="*.lib", dst="lib", src="3rdparty\\lib", keep_path=False)
self.copy(pattern="*.lib", dst="lib", src="3rdparty\\ippicv\\ippicv_win\\lib\\intel64", keep_path=False)
self.copy(pattern="*.lib", dst="lib", src="install", keep_path=False)
self.copy(pattern="*.dll", dst="bin", src="bin", keep_path=False)
self.copy(pattern="*.exe", dst="bin", src="bin", keep_path=False)
if self.settings.os == "Linux":
self.copy(pattern="*.a", dst="lib", src="3rdparty/lib", keep_path=False)
self.copy(pattern="*.a", dst="lib", src="3rdparty/ippicv/ippicv_lnx/lib/intel64", keep_path=False)
self.copy(pattern="*.a", dst="lib", src="install", keep_path=False)
self.copy(pattern="*.so*", dst="lib", src="install", keep_path=False)
def package_info(self):
libs_opencv = [
"opencv_calib3d",
"opencv_flann",
"opencv_highgui",
"opencv_imgcodecs",
"opencv_imgproc",
"opencv_ml",
"opencv_objdetect",
"opencv_photo",
"opencv_shape",
"opencv_stitching",
"opencv_superres",
"opencv_video",
"opencv_videoio",
"opencv_videostab",
"opencv_core" # GCC wants this last
]
libs_3rdparty = [
"zlib",
"libpng",
"libjasper",
"libtiff",
"libwebp",
"IlmImf"
]
libs_win = [
"ippicvmt"
]
libs_linux = [
"ippicv",
"pthread",
"dl" # GCC wants this last
]
if self.settings.compiler == "Visual Studio":
debug_suffix = ("d" if self.settings.build_type=="Debug" else "")
libs_opencv_win = map(lambda n: n + self.opencv_version_suffix + debug_suffix, libs_opencv)
libs_3rdparty_win = map(lambda n: n + debug_suffix, libs_3rdparty)
libs = libs_opencv_win + libs_3rdparty_win + libs_win
self.cpp_info.libs.extend(libs)
elif self.settings.compiler == "gcc":
libs = libs_opencv + libs_3rdparty + libs_linux
self.cpp_info.libs.extend(libs)