3
3
from conan .tools .build import check_min_cppstd
4
4
from conan .tools .cmake import CMake , CMakeDeps , CMakeToolchain , cmake_layout
5
5
from conan .tools .files import apply_conandata_patches , export_conandata_patches , get , copy , rmdir , rm
6
+ from conan .tools .gnu import PkgConfigDeps
6
7
from conan .tools .scm import Version
7
8
from conan .tools .system import package_manager
8
9
import os
12
13
13
14
class PclConan (ConanFile ):
14
15
name = "pcl"
15
- description = "The Point Cloud Library (PCL) is a standalone, large-scale, open project for 2D/3D image and point cloud processing."
16
+ description = ("The Point Cloud Library (PCL) is a standalone, large-scale, "
17
+ "open project for 2D/3D image and point cloud processing." )
16
18
license = "BSD-3-Clause"
17
19
url = "https://github.com/conan-io/conan-center-index"
18
20
homepage = "https://github.com/PointCloudLibrary/pcl"
@@ -103,9 +105,24 @@ def requirements(self):
103
105
self .requires ("libusb/1.0.26" )
104
106
if self .options .with_pcap :
105
107
self .requires ("libpcap/1.10.4" )
106
- if self .options .with_opengl :
108
+ if self .options .with_opengl and self .options .with_vtk :
109
+ # OpenGL is only used if VTK is available
107
110
self .requires ("opengl/system" )
111
+ self .requires ("freeglut/3.4.0" )
108
112
self .requires ("glew/2.2.0" )
113
+ # TODO:
114
+ # self.requires("vtk/9.x.x")
115
+ # self.requires("openni/x.x.x")
116
+ # self.requires("openni2/x.x.x")
117
+ # self.requires("ensenso/x.x.x")
118
+ # self.requires("davidsdk/x.x.x")
119
+ # self.requires("dssdk/x.x.x")
120
+ # self.requires("rssdk/x.x.x")
121
+
122
+ def package_id (self ):
123
+ if self .info .options .with_vtk :
124
+ # with_opengl has no effect if VTK is not available
125
+ self .info .options .with_opengl = False
109
126
110
127
def validate (self ):
111
128
if self .settings .compiler .cppstd :
@@ -122,29 +139,35 @@ def source(self):
122
139
def generate (self ):
123
140
tc = CMakeToolchain (self )
124
141
tc .cache_variables ["PCL_SHARED_LIBS" ] = self .options .shared
125
- tc .cache_variables ["WITH_OPENMP " ] = self .options .with_openmp
142
+ tc .cache_variables ["WITH_CUDA " ] = self .options .with_cuda
126
143
tc .cache_variables ["WITH_LIBUSB" ] = self .options .with_libusb
144
+ tc .cache_variables ["WITH_OPENGL" ] = self .options .with_opengl
145
+ tc .cache_variables ["WITH_OPENMP" ] = self .options .with_openmp
146
+ tc .cache_variables ["WITH_PCAP" ] = self .options .with_pcap
127
147
tc .cache_variables ["WITH_PNG" ] = self .options .with_png
128
148
tc .cache_variables ["WITH_QHULL" ] = self .options .with_qhull
149
+ tc .cache_variables ["WITH_QT" ] = self .options .with_apps
129
150
tc .cache_variables ["WITH_VTK" ] = self .options .with_vtk
130
- tc .cache_variables ["WITH_CUDA" ] = self .options .with_cuda
131
- tc .cache_variables ["WITH_PCAP" ] = self .options .with_pcap
132
- tc .cache_variables ["WITH_OPENGL" ] = self .options .with_opengl
151
+ tc .cache_variables ["WITH_SYSTEM_ZLIB" ] = True
133
152
tc .cache_variables ["BUILD_tools" ] = self .options .with_tools
134
153
tc .cache_variables ["BUILD_apps" ] = self .options .with_apps
135
154
tc .cache_variables ["BUILD_examples" ] = False
136
- tc .cache_variables ["WITH_QT" ] = self .options .with_apps
137
155
tc .cache_variables ["PCL_ONLY_CORE_POINT_TYPES" ] = True
156
+ # The default False setting breaks OpenGL detection in CMake
157
+ tc .cache_variables ["PCL_ALLOW_BOTH_SHARED_AND_STATIC_DEPENDENCIES" ] = True
138
158
tc .generate ()
139
159
140
- tc = CMakeDeps (self )
141
- tc .set_property ("eigen" , "cmake_file_name" , "EIGEN" )
142
- tc .set_property ("flann" , "cmake_file_name" , "FLANN" )
143
- tc .set_property ("flann" , "cmake_target_name" , "FLANN::FLANN" )
144
- tc .set_property ("glew" , "cmake_file_name" , "GLEW" )
145
- if self .options .with_qhull :
146
- tc .set_property ("qhull" , "cmake_file_name" , "QHULL" )
147
- tc .generate ()
160
+ deps = CMakeDeps (self )
161
+ deps .set_property ("eigen" , "cmake_file_name" , "EIGEN" )
162
+ deps .set_property ("flann" , "cmake_file_name" , "FLANN" )
163
+ deps .set_property ("flann" , "cmake_target_name" , "FLANN::FLANN" )
164
+ deps .set_property ("pcap" , "cmake_file_name" , "PCAP" )
165
+ deps .set_property ("qhull" , "cmake_file_name" , "QHULL" )
166
+ deps .set_property ("qhull" , "cmake_target_name" , "QHULL::QHULL" )
167
+ deps .generate ()
168
+
169
+ deps = PkgConfigDeps (self )
170
+ deps .generate ()
148
171
149
172
def _patch_sources (self ):
150
173
apply_conandata_patches (self )
@@ -183,54 +206,90 @@ def _lib_name(self, lib):
183
206
return f"pcl_{ lib } "
184
207
185
208
def package_info (self ):
186
- self .cpp_info .names ["cmake_find_package" ] = "PCL"
187
- self .cpp_info .names ["cmake_find_package_multi" ] = "PCL"
188
-
189
209
self .cpp_info .set_property ("cmake_file_name" , "PCL" )
190
- self .cpp_info .set_property ("cmake_module_file_name" , "PCL" )
191
210
self .cpp_info .set_property ("cmake_target_name" , "PCL::PCL" )
211
+ self .cpp_info .set_property ("cmake_find_mode" , "both" )
192
212
193
- def _add_component (comp , requires , * , extra_libs = (), header_only = False ):
194
- self .cpp_info .components [comp ].names ["cmake_find_package" ] = comp
195
- self .cpp_info .components [comp ].names ["cmake_find_package_multi" ] = comp
196
- self .cpp_info .components [comp ].set_property ("cmake_file_name" , comp )
197
- self .cpp_info .components [comp ].set_property ("cmake_module_file_name" , comp )
198
- self .cpp_info .components [comp ].set_property ("cmake_target_name" , f"PCL::{ comp } " )
199
- self .cpp_info .components [comp ].set_property ("pkg_config_name" , f"pcl_{ comp } -{ self ._version_suffix } " )
200
- self .cpp_info .components [comp ].includedirs = [os .path .join ("include" , f"pcl-{ self ._version_suffix } " )]
213
+ def _add_component (name , requires , * , extra_libs = None , header_only = False ):
214
+ component = self .cpp_info .components [name ]
215
+ component .names ["cmake_find_package" ] = name
216
+ component .names ["cmake_find_package_multi" ] = name
217
+ component .set_property ("cmake_file_name" , name )
218
+ component .set_property ("cmake_module_file_name" , name )
219
+ component .set_property ("cmake_target_name" , f"PCL::{ name } " )
220
+ component .set_property ("pkg_config_name" , f"pcl_{ name } -{ self ._version_suffix } " )
221
+ component .includedirs = [os .path .join ("include" , f"pcl-{ self ._version_suffix } " )]
201
222
if not header_only :
202
- libs = [comp ] + extra_libs
203
- if comp != "common" :
204
- libs .append ("common" )
205
- self .cpp_info .components [comp ].libs = [self ._lib_name (lib ) for lib in libs ]
206
- self .cpp_info .components [comp ].requires = requires
223
+ libs = [name ]
224
+ if extra_libs :
225
+ libs += extra_libs
226
+ component .libs = [self ._lib_name (lib ) for lib in libs ]
227
+ if name != "common" :
228
+ component .requires = ["common" ]
229
+ component .requires += requires
207
230
208
231
def usb ():
209
232
return ["libusb::libusb" ] if self .options .with_libusb else []
210
233
def png ():
211
234
return ["libpng::libpng" ] if self .options .with_png else []
212
235
def qhull ():
213
236
return ["qhull::qhull" ] if self .options .with_qhull else []
237
+ def vtk ():
238
+ # TODO: add vtk package to CCI
239
+ return []
240
+ def opengl ():
241
+ if self .options .with_opengl :
242
+ return ["opengl::opengl" , "freeglut::freeglut" , "glew::glew" ]
243
+ return []
214
244
245
+ # FIXME: grep for PCL_MAKE_PKGCONFIG and add any missing sub-components
246
+ # TODO: make the set of enabled components configurable via options
247
+ # TODO: maybe extract the component configuration automatically from each CMakelists.txt
215
248
_add_component ("common" , ["eigen::eigen3" , "boost::boost" ])
216
- _add_component ("kdtree" , ["flann::flann" ])
217
- _add_component ("octree" , [])
218
- _add_component ("search" , ["kdtree" , "octree" , "flann::flann" ])
219
- _add_component ("sample_consensus" , ["search" ])
249
+ _add_component ("2d" , ["filters" ] + vtk (), header_only = True )
250
+ if self .options .with_cuda :
251
+ # FIXME: add individual sub-components
252
+ _add_component ("cuda" , [])
253
+ _add_component ("features" , ["search" , "kdtree" , "octree" , "filters" , "2d" ])
220
254
_add_component ("filters" , ["sample_consensus" , "search" , "kdtree" , "octree" ])
221
- _add_component ("2d" , ["filters" ], header_only = True )
222
255
_add_component ("geometry" , [], header_only = True )
223
- _add_component ("io" , ["octree" , "zlib::zlib" ] + png () + usb (), extra_libs = ["io_ply" ])
224
- _add_component ("features" , ["search" , "kdtree" , "octree" , "filters" , "2d" ])
225
- _add_component ("ml" , [])
226
- _add_component ("segmentation" , ["geometry" , "search" , "sample_consensus" , "kdtree" , "octree" , "features" , "filters" , "ml" ])
227
- _add_component ("surface" , ["search" , "kdtree" , "octree" ] + qhull ())
228
- _add_component ("registration" , ["octree" , "kdtree" , "search" , "sample_consensus" , "features" , "filters" ])
256
+ if self .options .with_cuda :
257
+ # FIXME: add individual sub-components
258
+ _add_component ("gpu" , [])
259
+ _add_component ("io" , ["octree" , "zlib::zlib" ] + png () + usb () + vtk (), extra_libs = ["io_ply" ])
260
+ _add_component ("kdtree" , ["flann::flann" ])
229
261
_add_component ("keypoints" , ["search" , "kdtree" , "octree" , "features" , "filters" ])
230
- _add_component ("tracking" , ["search" , "kdtree" , "filters" , "octree" ])
262
+ _add_component ("ml" , [])
263
+ _add_component ("octree" , [])
264
+ if self .options .with_vtk :
265
+ # FIXME: add individual sub-components
266
+ _add_component ("outofcore" , ["io" , "filters" , "octree" , "visualization" ] + vtk ())
267
+ if self .options .with_vtk :
268
+ _add_component ("people" , ["kdtree" , "search" , "sample_consensus" , "filters" , "io" , "visualization" , "geometry" , "segmentation" , "octree" ] + vtk ())
231
269
_add_component ("recognition" , ["io" , "search" , "kdtree" , "octree" , "features" , "filters" , "registration" , "sample_consensus" , "ml" ])
270
+ _add_component ("registration" , ["octree" , "kdtree" , "search" , "sample_consensus" , "features" , "filters" ])
271
+ _add_component ("sample_consensus" , ["search" ])
272
+ _add_component ("search" , ["kdtree" , "octree" , "flann::flann" ])
273
+ _add_component ("segmentation" , ["geometry" , "search" , "sample_consensus" , "kdtree" , "octree" , "features" , "filters" , "ml" ])
274
+ # simulation is disabled by default
275
+ # _add_component("simulation", ["io", "surface", "kdtree", "features", "search", "octree", "visualization", "filters", "geometry"] + opengl() + vtk())
232
276
_add_component ("stereo" , ["io" ])
277
+ _add_component ("surface" , ["search" , "kdtree" , "octree" ] + qhull () + vtk ())
278
+ _add_component ("tracking" , ["search" , "kdtree" , "filters" , "octree" ])
279
+ if self .options .with_vtk :
280
+ _add_component ("visualization" , ["io" , "kdtree" , "geometry" , "search" , "octree" ] + opengl () + vtk ())
233
281
282
+ if self .options .with_tools :
283
+ self .cpp_info .components ["tools" ].libs = []
284
+ self .cpp_info .components ["apps" ].requires = [
285
+ "filters" , "sample_consensus" , "segmentation" , "search" , "kdtree" , "features" , "surface" ,
286
+ "octree" , "registration" , "recognition" , "geometry" , "keypoints" , "ml" , "visualization"
287
+ ] + vtk () + qhull ()
288
+
289
+ if self .options .with_apps :
290
+ # FIXME: add each app as individual sub-component
291
+ self .cpp_info .components ["apps" ].libs = []
292
+ self .cpp_info .components ["apps" ].requires = ["qt::qt" ] + opengl () + vtk ()
234
293
235
294
if not self .options .shared :
236
295
common = self .cpp_info .components ["common" ]
@@ -247,6 +306,6 @@ def qhull():
247
306
elif self .settings .compiler == "gcc" :
248
307
common .system_libs .append ("gomp" )
249
308
250
- if self . options . with_apps :
251
- self .cpp_info .components [ "apps" ]. libs = []
252
- self .cpp_info .components [ "apps" ]. requires = [ "qt::qt" ]
309
+ # TODO: Legacy, to be removed on Conan 2.0
310
+ self .cpp_info .names [ "cmake_find_package" ] = "PCL"
311
+ self .cpp_info .names [ "cmake_find_package_multi" ] = "PCL"
0 commit comments