Skip to content

Commit 161aef4

Browse files
Merge pull request #6 from valgur/feature/AddPCL
PCL: further PR fixes
2 parents eeb72b3 + 5a5e796 commit 161aef4

File tree

4 files changed

+184
-70
lines changed

4 files changed

+184
-70
lines changed

recipes/pcl/all/conandata.yml

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ patches:
77
- patch_file: "patches/0001-cmake_use_conan_targets.patch"
88
patch_description: "Update PCL CMake files to work with Conan"
99
patch_type: "conan"
10+
- patch_file: "patches/0001-fix-FindOpenNI-bug.patch"
11+
patch_description: "Fix a libusb detection bug in FindOpenNI.cmake"
12+
patch_type: "bugfix"
1013
- patch_file: "patches/0001-Add-Eigen3-Eigen-target-in-pcl_common-target.patch"
1114
patch_description: "Add Eigen3::Eigen target to pcl_common target"
1215
patch_type: "conan"

recipes/pcl/all/conanfile.py

+106-47
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from conan.tools.build import check_min_cppstd
44
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
55
from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy, rmdir, rm
6+
from conan.tools.gnu import PkgConfigDeps
67
from conan.tools.scm import Version
78
from conan.tools.system import package_manager
89
import os
@@ -12,7 +13,8 @@
1213

1314
class PclConan(ConanFile):
1415
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.")
1618
license = "BSD-3-Clause"
1719
url = "https://github.com/conan-io/conan-center-index"
1820
homepage = "https://github.com/PointCloudLibrary/pcl"
@@ -103,9 +105,24 @@ def requirements(self):
103105
self.requires("libusb/1.0.26")
104106
if self.options.with_pcap:
105107
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
107110
self.requires("opengl/system")
111+
self.requires("freeglut/3.4.0")
108112
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
109126

110127
def validate(self):
111128
if self.settings.compiler.cppstd:
@@ -122,29 +139,35 @@ def source(self):
122139
def generate(self):
123140
tc = CMakeToolchain(self)
124141
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
126143
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
127147
tc.cache_variables["WITH_PNG"] = self.options.with_png
128148
tc.cache_variables["WITH_QHULL"] = self.options.with_qhull
149+
tc.cache_variables["WITH_QT"] = self.options.with_apps
129150
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
133152
tc.cache_variables["BUILD_tools"] = self.options.with_tools
134153
tc.cache_variables["BUILD_apps"] = self.options.with_apps
135154
tc.cache_variables["BUILD_examples"] = False
136-
tc.cache_variables["WITH_QT"] = self.options.with_apps
137155
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
138158
tc.generate()
139159

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()
148171

149172
def _patch_sources(self):
150173
apply_conandata_patches(self)
@@ -183,54 +206,90 @@ def _lib_name(self, lib):
183206
return f"pcl_{lib}"
184207

185208
def package_info(self):
186-
self.cpp_info.names["cmake_find_package"] = "PCL"
187-
self.cpp_info.names["cmake_find_package_multi"] = "PCL"
188-
189209
self.cpp_info.set_property("cmake_file_name", "PCL")
190-
self.cpp_info.set_property("cmake_module_file_name", "PCL")
191210
self.cpp_info.set_property("cmake_target_name", "PCL::PCL")
211+
self.cpp_info.set_property("cmake_find_mode", "both")
192212

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}")]
201222
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
207230

208231
def usb():
209232
return ["libusb::libusb"] if self.options.with_libusb else []
210233
def png():
211234
return ["libpng::libpng"] if self.options.with_png else []
212235
def qhull():
213236
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 []
214244

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
215248
_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"])
220254
_add_component("filters", ["sample_consensus", "search", "kdtree", "octree"])
221-
_add_component("2d", ["filters"], header_only=True)
222255
_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"])
229261
_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())
231269
_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())
232276
_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())
233281

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()
234293

235294
if not self.options.shared:
236295
common = self.cpp_info.components["common"]
@@ -247,6 +306,6 @@ def qhull():
247306
elif self.settings.compiler == "gcc":
248307
common.system_libs.append("gomp")
249308

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"
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,52 @@
11
--- a/CMakeLists.txt
22
+++ b/CMakeLists.txt
3-
@@ -319,6 +319,6 @@ endif()
3+
@@ -297,7 +297,7 @@
4+
# OpenMP (optional)
5+
option(WITH_OPENMP "Build with parallelization using OpenMP" TRUE)
6+
if(WITH_OPENMP)
7+
- find_package(OpenMP COMPONENTS C CXX)
8+
+ find_package(OpenMP REQUIRED COMPONENTS C CXX)
9+
endif()
10+
if(OpenMP_FOUND)
11+
string(APPEND CMAKE_C_FLAGS " ${OpenMP_C_FLAGS}")
12+
@@ -319,11 +319,11 @@
413
find_package(Threads REQUIRED)
514

615
# Eigen (required)
716
-find_package(Eigen 3.3 REQUIRED)
8-
+find_package(EIGEN REQUIRED)
17+
+find_package(EIGEN REQUIRED CONFIG)
918
include_directories(SYSTEM ${EIGEN_INCLUDE_DIRS})
1019

11-
--- a/common/CMakeLists.txt
12-
+++ b/common/CMakeLists.txt
13-
@@ -4,7 +4,7 @@ set(SUBSYS_DEPS)
20+
# FLANN (required)
21+
-find_package(FLANN 1.9.1 REQUIRED)
22+
+find_package(FLANN REQUIRED CONFIG)
23+
if(NOT (${FLANN_LIBRARY_TYPE} MATCHES ${PCL_FLANN_REQUIRED_TYPE}) AND NOT (${PCL_FLANN_REQUIRED_TYPE} MATCHES "DONTCARE"))
24+
message(FATAL_ERROR "Flann was selected with ${PCL_FLANN_REQUIRED_TYPE} but found as ${FLANN_LIBRARY_TYPE}")
25+
endif()
26+
@@ -359,7 +359,7 @@
27+
# LibPNG
28+
option(WITH_PNG "PNG file support" TRUE)
29+
if(WITH_PNG)
30+
- find_package(PNG)
31+
+ find_package(PNG REQUIRED CONFIG)
32+
if(PNG_FOUND)
33+
set(HAVE_PNG ON)
34+
include_directories(SYSTEM "${PNG_INCLUDE_DIR}")
35+
@@ -369,7 +369,7 @@
36+
# Qhull
37+
option(WITH_QHULL "Include convex-hull operations" TRUE)
38+
if(WITH_QHULL)
39+
- find_package(Qhull)
40+
+ find_package(QHULL REQUIRED CONFIG)
41+
if(NOT (${QHULL_LIBRARY_TYPE} MATCHES ${PCL_QHULL_REQUIRED_TYPE}) AND NOT (${PCL_QHULL_REQUIRED_TYPE} MATCHES "DONTCARE"))
42+
message(FATAL_ERROR "Qhull was selected with ${PCL_QHULL_REQUIRED_TYPE} but found as ${QHULL_LIBRARY_TYPE}")
43+
endif()
44+
@@ -404,7 +404,7 @@
45+
#Find PCAP
46+
option(WITH_PCAP "pcap file capabilities in Velodyne HDL driver" TRUE)
47+
if(WITH_PCAP)
48+
- find_package(Pcap)
49+
+ find_package(PCAP REQUIRED CONFIG)
50+
endif()
1451

15-
set(build TRUE)
16-
PCL_SUBSYS_OPTION(build "${SUBSYS_NAME}" "${SUBSYS_DESC}" ON)
17-
-PCL_SUBSYS_DEPEND(build NAME ${SUBSYS_NAME} DEPS ${SUBSYS_DEPS} EXT_DEPS eigen boost)
18-
+PCL_SUBSYS_DEPEND(build NAME ${SUBSYS_NAME} DEPS ${SUBSYS_DEPS} EXT_DEPS EIGEN Boost)
19-
20-
PCL_ADD_DOC("${SUBSYS_NAME}")
21-
22-
--- a/io/CMakeLists.txt
23-
+++ b/io/CMakeLists.txt
24-
@@ -1,7 +1,7 @@
25-
set(SUBSYS_NAME io)
26-
set(SUBSYS_DESC "Point cloud IO library")
27-
set(SUBSYS_DEPS common octree)
28-
-set(SUBSYS_EXT_DEPS boost eigen)
29-
+set(SUBSYS_EXT_DEPS Boost EIGEN)
30-
31-
set(build TRUE)
32-
PCL_SUBSYS_OPTION(build "${SUBSYS_NAME}" "${SUBSYS_DESC}" ON)
52+
# OpenGL and GLUT
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
--- cmake/Modules/FindOpenNI.cmake
2+
+++ cmake/Modules/FindOpenNI.cmake
3+
@@ -52,7 +52,12 @@
4+
5+
# Libraries
6+
if(NOT WIN32)
7+
- find_package(libusb REQUIRED)
8+
+ find_package(libusb QUIET)
9+
+ if (NOT libusb_FOUND)
10+
+ message(WARNING "Found OpenNI library, but required libusb is not available")
11+
+ set(OPENNI_FOUND FALSE)
12+
+ return()
13+
+ endif()
14+
set(OPENNI_LIBRARIES ${OPENNI_LIBRARY} libusb::libusb)
15+
else()
16+
set(OPENNI_LIBRARIES ${OPENNI_LIBRARY})
17+
--- cmake/Modules/FindOpenNI2.cmake
18+
+++ cmake/Modules/FindOpenNI2.cmake
19+
@@ -42,7 +42,12 @@
20+
21+
# Libraries
22+
if(NOT WIN32)
23+
- find_package(libusb REQUIRED)
24+
+ find_package(libusb QUIET)
25+
+ if (NOT libusb_FOUND)
26+
+ message(WARNING "Found OpenNI2 library, but required libusb is not available")
27+
+ set(OPENNI2_FOUND FALSE)
28+
+ return()
29+
+ endif()
30+
set(OPENNI2_LIBRARIES ${OPENNI2_LIBRARY} libusb::libusb)
31+
else()
32+
set(OPENNI2_LIBRARIES ${OPENNI2_LIBRARY})

0 commit comments

Comments
 (0)