-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconanfile.py
295 lines (286 loc) · 15.1 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
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.4.6-1"
opencv_version_suffix = "346"
settings = "os", "compiler", "build_type", "arch"
requires = "libjpeg-turbo/2.1.2"
options = {
"shared": [True, False],
"host_gtk": [True, False],
"host_cuda": [True, False]
}
default_options = "shared=False", "host_gtk=False", "host_cuda=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.4.6")
self.run("git clone https://github.com/opencv/opencv_contrib.git")
self.run("cd opencv_contrib && git checkout tags/3.4.6")
def imports(self):
self.copy("*", dst="jpeg-turbo", src="")
def build(self):
cmake = CMake(self)
cmake_options = {
"BUILD_WITH_DEBUG_INFO": False,
"CMAKE_CONFIGURATION_TYPES": self.settings.build_type,
"CMAKE_INSTALL_PREFIX": "install",
"WITH_OPENXL": False,
"WITH_IPP": True,
"WITH_QT": False,
"WITH_GTK": self.options.host_gtk,
"WITH_OPENGL": False,
"WITH_CUDA": self.options.host_cuda,
"WITH_JPEG": True,
"JPEG_INCLUDE_DIR": self.deps_cpp_info.includedirs[0],
"JPEG_LIBRARY": "to be inserted bellow",
"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": False,
"BUILD_opencv_superres": True,
"BUILD_opencv_ts": True,
"BUILD_opencv_video": True,
"BUILD_opencv_videoio": True,
"BUILD_opencv_videostab": True,
"BUILD_opencv_java": False,
"BUILD_opencv_python3": False,
"BUILD_opencv_cudaarithm": self.options.host_cuda,
"BUILD_opencv_cudacodec": self.options.host_cuda,
"BUILD_opencv_cudafilters": self.options.host_cuda,
"BUILD_opencv_cudaimgproc": self.options.host_cuda,
"BUILD_opencv_cudabgsegm": False,
"BUILD_opencv_cudafeatures2d": False,
"BUILD_opencv_cudalegacy": False,
"BUILD_opencv_cudaobjdetect": False,
"BUILD_opencv_cudaoptflow": False,
"BUILD_opencv_cudastereo": False,
"BUILD_opencv_cudawarping": self.options.host_cuda,
"BUILD_opencv_cudaev": self.options.host_cuda,
"OPENCV_EXTRA_MODULES_PATH": "opencv_contrib/modules"
}
if self.settings.compiler == "Visual Studio":
cmake_options["CUDA_HOST_COMPILER"] = "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.11.25503\\bin\\Hostx64\\x64\\cl.exe"
cmake_options["BUILD_WITH_STATIC_CRT"] = self.settings.compiler.runtime in ["MT","MTd"]
cmake_options["JPEG_LIBRARY"] = self.deps_cpp_info.libdirs[0] + "/jpeg-static.lib"
elif self.settings.os == "Linux":
#cmake_options["WITH_GTK"] = True
cmake_options["JPEG_LIBRARY"] = self.deps_cpp_info.libdirs[0] + "/libjpeg.a"
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="*.pdb", 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="*.pdb", dst="lib", src="3rdparty\\ippicv\\ippicv_win\\lib\\intel64", keep_path=False)
self.copy(pattern="*.lib", dst="lib", src="3rdparty\\ippicv\\ippiw_win\\lib\\intel64", keep_path=False)
self.copy(pattern="*.pdb", dst="lib", src="3rdparty\\ippicv\\ippiw_win\\lib\\intel64", keep_path=False)
self.copy(pattern="*.lib", dst="lib", src="install", keep_path=False)
self.copy(pattern="*.pdb", 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.options.host_cuda:
self.copy(pattern="nvcuvid.lib", dst="lib", src="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.1/lib/x64", keep_path=False)
self.copy(pattern="npps.lib", dst="lib", src="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.1/lib/x64", keep_path=False)
self.copy(pattern="nppial.lib", dst="lib", src="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.1/lib/x64", keep_path=False)
self.copy(pattern="nppicc.lib", dst="lib", src="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.1/lib/x64", keep_path=False)
self.copy(pattern="nppidei.lib", dst="lib", src="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.1/lib/x64", keep_path=False)
self.copy(pattern="nppif.lib", dst="lib", src="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.1/lib/x64", keep_path=False)
self.copy(pattern="nppig.lib", dst="lib", src="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.1/lib/x64", keep_path=False)
self.copy(pattern="nppim.lib", dst="lib", src="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.1/lib/x64", keep_path=False)
self.copy(pattern="nppist.lib", dst="lib", src="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.1/lib/x64", keep_path=False)
self.copy(pattern="nppitc.lib", dst="lib", src="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.1/lib/x64", keep_path=False)
self.copy(pattern="nppc.lib", dst="lib", src="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.1/lib/x64", keep_path=False)
self.copy(pattern="cublas.lib", dst="lib", src="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.1/lib/x64", keep_path=False)
self.copy(pattern="cufft.lib", dst="lib", src="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.1/lib/x64", keep_path=False)
self.copy(pattern="curand.lib", dst="lib", src="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.1/lib/x64", keep_path=False)
self.copy(pattern="cusparse.lib", dst="lib", src="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.1/lib/x64", keep_path=False)
self.copy(pattern="cuda.lib", dst="lib", src="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.1/lib/x64", keep_path=False)
self.copy(pattern="cudart.lib", dst="lib", src="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.1/lib/x64", keep_path=False)
self.copy(pattern="cupti.lib", dst="lib", src="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.1/extras/CUPTI/libx64", keep_path=False)
self.copy(pattern="nvcuvid64_91.dll", dst="bin", src="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.1/bin", keep_path=False)
self.copy(pattern="npps64_91.dll", dst="bin", src="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.1/bin", keep_path=False)
self.copy(pattern="nppial64_91.dll", dst="bin", src="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.1/bin", keep_path=False)
self.copy(pattern="nppicc64_91.dll", dst="bin", src="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.1/bin", keep_path=False)
self.copy(pattern="nppidei64_91.dll", dst="bin", src="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.1/bin", keep_path=False)
self.copy(pattern="nppif64_91.dll", dst="bin", src="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.1/bin", keep_path=False)
self.copy(pattern="nppig64_91.dll", dst="bin", src="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.1/bin", keep_path=False)
self.copy(pattern="nppim64_91.dll", dst="bin", src="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.1/bin", keep_path=False)
self.copy(pattern="nppist64_91.dll", dst="bin", src="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.1/bin", keep_path=False)
self.copy(pattern="nppitc64_91.dll", dst="bin", src="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.1/bin", keep_path=False)
self.copy(pattern="nppc64_91.dll", dst="bin", src="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.1/bin", keep_path=False)
self.copy(pattern="cublas64_91.dll", dst="bin", src="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.1/bin", keep_path=False)
self.copy(pattern="cufft64_91.dll", dst="bin", src="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.1/bin", keep_path=False)
self.copy(pattern="curand64_91.dll", dst="bin", src="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.1/bin", keep_path=False)
self.copy(pattern="cusparse64_91.dll", dst="bin", src="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.1/bin", keep_path=False)
self.copy(pattern="cuda64_91.dll", dst="bin", src="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.1/bin", keep_path=False)
self.copy(pattern="cudart64_91.dll", dst="bin", src="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.1/bin", keep_path=False)
self.copy(pattern="cupti64_91.dll", dst="bin", src="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.1/extras/CUPTI/libx64", 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="3rdparty/ippicv/ippiw_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_cuda = [
"opencv_cudaarithm",
"opencv_cudacodec",
"opencv_cudafilters",
"opencv_cudaimgproc",
"opencv_cudawarping",
"opencv_cudev"
]
libs_opencv = [
# OpenCV contrib
"opencv_aruco",
"opencv_bgsegm",
"opencv_bioinspired",
"opencv_ccalib",
"opencv_datasets",
"opencv_dpm",
"opencv_face",
"opencv_fuzzy",
#"opencv_hdf",
"opencv_img_hash",
"opencv_line_descriptor",
"opencv_optflow",
"opencv_phase_unwrapping",
"opencv_plot",
"opencv_reg",
"opencv_rgbd",
"opencv_saliency",
"opencv_stereo",
"opencv_structured_light",
"opencv_surface_matching",
"opencv_text",
"opencv_tracking",
"opencv_xfeatures2d",
"opencv_ximgproc",
"opencv_xobjdetect",
"opencv_xphoto",
# OpenCV
"opencv_calib3d",
"opencv_dnn",
"opencv_features2d",
"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 = [
"ittnotify",
"libprotobuf",
"libpng",
"libjasper",
"libtiff",
"libwebp",
"IlmImf",
"zlib" # GCC wants this last
]
libs_win_cuda = [
"cudart",
"cupti",
"nvcuvid",
"npps",
"nppial",
"nppicc",
"nppidei",
"nppif",
"nppig",
"nppim",
"nppist",
"nppitc",
"nppc",
"cublas",
"cufft",
"curand",
"cusparse",
"cuda",
]
libs_win = [
"ippiw",
"ippicvmt"
]
libs_linux_gtk = [
"gtk-x11-2.0",
"gdk-x11-2.0",
"pangocairo-1.0",
"atk-1.0",
"cairo",
"gdk_pixbuf-2.0",
"gio-2.0",
"pangoft2-1.0",
"pango-1.0",
"gobject-2.0",
"glib-2.0",
"fontconfig",
"freetype"
],
libs_linux = [
"ippiw",
"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 = [n + self.opencv_version_suffix + debug_suffix for n in libs_opencv]
libs_opencv_cuda_win = [n + self.opencv_version_suffix + debug_suffix for n in libs_opencv_cuda]
libs_3rdparty_win =[n + debug_suffix for n in libs_3rdparty]
if self.options.host_cuda:
libs_opencv_win = libs_opencv_cuda_win + libs_opencv_win
libs_3rdparty_win = libs_win_cuda + libs_3rdparty_win
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
if self.options.host_gtk:
libs = libs + libs_linux_gtk
libs = libs + libs_linux
self.cpp_info.libs.extend(libs)