Skip to content

Commit 078a9c8

Browse files
Add pcl PointCloudLibrary package
Inspired from conan-io#1891
1 parent 8305ea0 commit 078a9c8

9 files changed

+619
-0
lines changed

recipes/pcl/all/conandata.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
sources:
2+
"1.13.1":
3+
url: https://github.com/PointCloudLibrary/pcl/archive/refs/tags/pcl-1.13.1.tar.gz
4+
sha256: 8ab98a9db371d822de0859084a375a74bdc7f31c96d674147710cf4101b79621
5+
patches:
6+
"1.13.1":
7+
- patch_file: "patches/0001-test.patch"
8+
patch_description: "Update pcl CMake files to work with conan"
9+
patch_type: "conan"
10+
- patch_file: "patches/0001-KB-H020_avoid_pkgconfig_files.patch"
11+
patch_description: "Disable pkgconfig files install to follow KB-H020 rule"
12+
patch_type: "conan"
13+
- patch_file: "patches/0001-ReportFixAboutMemoryConsumptionDuringBuild.patch"
14+
patch_description: "Report fix from https://github.com/PointCloudLibrary/pcl/pull/5764"
15+
patch_type: "conan"

recipes/pcl/all/conanfile.py

+243
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,243 @@
1+
from conan import ConanFile
2+
from conan.errors import ConanInvalidConfiguration
3+
from conan.tools.microsoft import check_min_vs, is_msvc
4+
from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy, rmdir
5+
from conan.tools.build import check_min_cppstd
6+
from conan.tools.scm import Version
7+
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
8+
from conan.tools.system import package_manager
9+
import os
10+
11+
12+
required_conan_version = ">=1.53.0"
13+
14+
15+
class PclConan(ConanFile):
16+
name = "pcl"
17+
description = "Point Cloud Library"
18+
license = "BSD-3-Clause"
19+
url = "https://github.com/conan-io/conan-center-index"
20+
homepage = "https://github.com/PointCloudLibrary/pcl"
21+
topics = ("computer vision", "point cloud", "pointcloud", "3d", "pcd", "ply", "stl", "ifs", "vtk")
22+
package_type = "library"
23+
settings = "os", "arch", "compiler", "build_type"
24+
options = {
25+
"shared": [True, False],
26+
"fPIC": [True, False],
27+
"with_openmp": [True, False],
28+
"with_libusb": [True, False],
29+
"with_png": [True, False],
30+
"with_qhull": [True, False],
31+
"with_vtk": [True, False],
32+
"with_cuda": [True, False],
33+
"with_pcap": [True, False],
34+
"with_opengl": [True, False],
35+
"with_tools": [True, False],
36+
"with_apps": [True, False],
37+
}
38+
default_options = {
39+
"shared": False,
40+
"fPIC": True,
41+
"with_openmp": False,
42+
"with_libusb": False,
43+
"with_png": True,
44+
"with_qhull": True,
45+
"with_vtk": False,
46+
"with_cuda": False,
47+
"with_pcap": False,
48+
"with_opengl": False,
49+
"with_tools": False,
50+
"with_apps": False,
51+
}
52+
53+
@property
54+
def _min_cppstd(self):
55+
return 17
56+
57+
# in case the project requires C++14/17/20/... the minimum compiler version should be listed
58+
@property
59+
def _compilers_minimum_version(self):
60+
return {
61+
"gcc": "7",
62+
"clang": "7",
63+
"apple-clang": "10",
64+
}
65+
66+
def export_sources(self):
67+
export_conandata_patches(self)
68+
69+
def config_options(self):
70+
if self.settings.os == "Windows":
71+
del self.options.fPIC
72+
73+
def configure(self):
74+
if self.options.shared:
75+
self.options.rm_safe("fPIC")
76+
77+
def layout(self):
78+
cmake_layout(self, src_folder="src")
79+
80+
def system_requirements(self):
81+
if self.options.with_vtk:
82+
package_manager.Apt(self).install(["libvtk-dev"])
83+
package_manager.Dnf(self).install(["vtk-devel"])
84+
if self.settings.os == "Windows":
85+
self.output.warn("On Windows VTK must be installed manually.")
86+
87+
def requirements(self):
88+
self.requires("zlib/1.2.13")
89+
# Transitive headers on boost because pcl/point_struct_traits.h:40:10: references boost/mpl/assert.hpp
90+
self.requires("boost/1.82.0", transitive_headers=True)
91+
self.requires("eigen/3.4.0", transitive_headers=True)
92+
self.requires("flann/1.9.2")
93+
if self.options.with_png:
94+
self.requires("libpng/1.6.40")
95+
if self.options.with_qhull:
96+
self.requires("qhull/8.0.1")
97+
if self.options.with_apps:
98+
self.requires("qt/6.5.1")
99+
if self.options.with_libusb:
100+
self.requires("libusb/1.0.26")
101+
if self.options.with_pcap:
102+
self.requires("libpcap/1.10.4")
103+
if self.options.with_opengl:
104+
self.requires("opengl/system")
105+
106+
def validate(self):
107+
# validate the minimum cpp standard supported. For C++ projects only
108+
if self.settings.compiler.cppstd:
109+
check_min_cppstd(self, self._min_cppstd)
110+
check_min_vs(self, 191)
111+
if not is_msvc(self):
112+
minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False)
113+
if minimum_version and Version(self.settings.compiler.version) < minimum_version:
114+
raise ConanInvalidConfiguration(
115+
f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support."
116+
)
117+
# in case it does not work in another configuration, it should validated here too
118+
if is_msvc(self) and self.options.shared:
119+
raise ConanInvalidConfiguration(f"{self.ref} can not be built as shared on Visual Studio and msvc.")
120+
121+
def source(self):
122+
get(self, **self.conan_data["sources"][self.version], strip_root=True)
123+
124+
def generate(self):
125+
tc = CMakeToolchain(self)
126+
tc.variables["PCL_SHARED_LIBS"] = self.options.shared
127+
tc.variables["WITH_OPENMP"] = self.options.with_openmp
128+
tc.variables["WITH_LIBUSB"] = self.options.with_libusb
129+
tc.variables["WITH_PNG"] = self.options.with_png
130+
tc.variables["WITH_QHULL"] = self.options.with_qhull
131+
tc.variables["WITH_VTK"] = self.options.with_vtk
132+
tc.variables["WITH_CUDA"] = self.options.with_cuda
133+
tc.variables["WITH_PCAP"] = self.options.with_pcap
134+
tc.variables["WITH_OPENGL"] = self.options.with_opengl
135+
tc.variables["BUILD_tools"] = self.options.with_tools
136+
tc.variables["BUILD_apps"] = self.options.with_apps
137+
tc.variables["BUILD_examples"] = True
138+
tc.cache_variables["WITH_QT"] = self.options.with_apps
139+
tc.generate()
140+
141+
tc = CMakeDeps(self)
142+
tc.generate()
143+
144+
def _patch_sources(self):
145+
apply_conandata_patches(self)
146+
147+
def build(self):
148+
self._patch_sources()
149+
cmake = CMake(self)
150+
cmake.configure(variables={"PCL_ONLY_CORE_POINT_TYPES": "ON"})
151+
cmake.build()
152+
153+
def package(self):
154+
copy(self, pattern="LICENSE.txt", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder)
155+
cmake = CMake(self)
156+
cmake.install()
157+
158+
rmdir(self, os.path.join(self.package_folder, "share"))
159+
160+
@property
161+
def _pcl_lib_components(self):
162+
def usb():
163+
return ["libusb::libusb"] if self.options.with_libusb else []
164+
def png():
165+
return ["libpng::libpng"] if self.options.with_png else []
166+
def qhull():
167+
return ["qhull::qhull"] if self.options.with_qhull else []
168+
169+
return {
170+
"common": {"requires": ["eigen::eigen3", "boost::boost"]},
171+
"kdtree": {"requires": ["common", "flann::flann"]},
172+
"octree": {"requires": ["common"]},
173+
"search": {"requires": ["common", "kdtree", "octree", "flann::flann"]},
174+
"sample_consensus": {"requires": ["common", "search"]},
175+
"filters": {"requires": ["common", "sample_consensus", "search", "kdtree", "octree"]},
176+
"2d": {"requires": ["common", "filters"], "header_only": True},
177+
"geometry": {"requires": ["common"], "header_only": True},
178+
"io": {"requires": ["common", "octree", "zlib::zlib"] + png() + usb(), "extra_libs": ["io_ply"]},
179+
"features": {"requires": ["common", "search", "kdtree", "octree", "filters", "2d"]},
180+
"ml": {"requires": ["common"]},
181+
"segmentation": {"requires": ["common", "geometry", "search", "sample_consensus", "kdtree", "octree", "features", "filters", "ml"]},
182+
"surface": {"requires": ["common", "search", "kdtree", "octree"] + qhull()},
183+
"registration": {"requires": ["common", "octree", "kdtree", "search", "sample_consensus", "features", "filters"]},
184+
"keypoints": {"requires": ["common", "search", "kdtree", "octree", "features", "filters"]},
185+
"tracking": {"requires": ["common", "search", "kdtree", "filters", "octree"]},
186+
"recognition": {"requires": ["common", "io", "search", "kdtree", "octree", "features", "filters", "registration", "sample_consensus", "ml"]},
187+
"stereo": {"requires": ["common", "io"]}
188+
}
189+
190+
@property
191+
def _version_suffix(self):
192+
semver = Version(self.version)
193+
return "{}.{}".format(semver.major, semver.minor)
194+
195+
def _lib_name(self, lib):
196+
if self.settings.compiler == "msvc" and self.settings.build_type == "Debug":
197+
return "pcl_{}d".format(lib)
198+
return "pcl_{}".format(lib)
199+
200+
def package_info(self):
201+
self.cpp_info.names["cmake_find_package"] = "PCL"
202+
self.cpp_info.names["cmake_find_package_multi"] = "PCL"
203+
204+
self.cpp_info.set_property("cmake_file_name", "PCL")
205+
self.cpp_info.set_property("cmake_module_file_name", "PCL")
206+
self.cpp_info.set_property("cmake_target_name", "PCL::PCL")
207+
208+
def _update_components(components):
209+
for comp, values in components.items():
210+
self.cpp_info.components[comp].names["cmake_find_package"] = comp
211+
self.cpp_info.components[comp].names["cmake_find_package_multi"] = comp
212+
self.cpp_info.components[comp].set_property("cmake_file_name", comp)
213+
self.cpp_info.components[comp].set_property("cmake_module_file_name", comp)
214+
self.cpp_info.components[comp].set_property("cmake_target_name", f"PCL::{comp}")
215+
216+
self.cpp_info.components[comp].names["pkg_config"] = "pcl_{}-{}".format(comp, self._version_suffix)
217+
self.cpp_info.components[comp].set_property("pkg_config_name", "pcl_{}-{}".format(comp, self._version_suffix))
218+
219+
self.cpp_info.components[comp].includedirs = [os.path.join("include", "pcl-{}".format(self._version_suffix))]
220+
if not values.get("header_only", False):
221+
libs = [comp] + values.get("extra_libs", [])
222+
self.cpp_info.components[comp].libs = [self._lib_name(lib) for lib in libs]
223+
self.cpp_info.components[comp].requires = values["requires"]
224+
225+
_update_components(self._pcl_lib_components)
226+
227+
if not self.options.shared:
228+
if self.settings.os in ["Linux", "FreeBSD"]:
229+
self.cpp_info.components["common"].system_libs.append("pthread")
230+
if self.options.with_openmp:
231+
if self.settings.os == "Linux":
232+
if self.settings.compiler == "gcc":
233+
self.cpp_info.components["common"].sharedlinkflags.append("-fopenmp")
234+
self.cpp_info.components["common"].exelinkflags.append("-fopenmp")
235+
elif self.settings.os == "Windows":
236+
if self.settings.compiler == "msvc":
237+
self.cpp_info.components["common"].system_libs.append("delayimp")
238+
elif self.settings.compiler == "gcc":
239+
self.cpp_info.components["common"].system_libs.append("gomp")
240+
241+
if self.options.with_apps:
242+
self.cpp_info.components["apps"].libs = []
243+
self.cpp_info.components["apps"].requires = ["qt::qt"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--- a/cmake/pcl_targets.cmake
2+
+++ b/cmake/pcl_targets.cmake
3+
@@ -571,9 +571,6 @@ function(PCL_MAKE_PKGCONFIG _name)
4+
else()
5+
configure_file(${PROJECT_SOURCE_DIR}/cmake/pkgconfig.cmake.in ${_pc_file} @ONLY)
6+
endif()
7+
- install(FILES ${_pc_file}
8+
- DESTINATION ${PKGCFG_INSTALL_DIR}
9+
- COMPONENT pcl_${ARGS_COMPONENT})
10+
endfunction()
11+
12+
###############################################################################
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--- a/surface/src/mls.cpp
2+
+++ b/surface/src/mls.cpp
3+
@@ -80,6 +80,15 @@ pcl::MLSResult::calculatePrincipalCurvatures (const double u, const double v) co
4+
PCL_INSTANTIATE_PRODUCT(MovingLeastSquares, ((pcl::PointXYZ)(pcl::PointXYZI)(pcl::PointXYZRGB)(pcl::PointXYZRGBA)(pcl::PointXYZRGBNormal)(pcl::PointNormal))
5+
((pcl::PointXYZ)(pcl::PointXYZI)(pcl::PointXYZRGB)(pcl::PointXYZRGBA)(pcl::PointXYZRGBNormal)(pcl::PointNormal)))
6+
#else
7+
- PCL_INSTANTIATE_PRODUCT(MovingLeastSquares, (PCL_XYZ_POINT_TYPES)(PCL_XYZ_POINT_TYPES))
8+
+ // PCL_INSTANTIATE_PRODUCT(MovingLeastSquares, (PCL_XYZ_POINT_TYPES)(PCL_XYZ_POINT_TYPES))
9+
+ // All instantiations that are available with PCL_ONLY_CORE_POINT_TYPES, plus instantiations for all XYZ types where PointInT and PointOutT are the same
10+
+ #define PCL_INSTANTIATE_MovingLeastSquaresSameInAndOut(T) template class PCL_EXPORTS pcl::MovingLeastSquares<T,T>;
11+
+ PCL_INSTANTIATE(MovingLeastSquaresSameInAndOut, PCL_XYZ_POINT_TYPES)
12+
+ PCL_INSTANTIATE_PRODUCT(MovingLeastSquares, ((pcl::PointXYZ))((pcl::PointXYZI)(pcl::PointXYZRGB)(pcl::PointXYZRGBA)(pcl::PointXYZRGBNormal)(pcl::PointNormal)))
13+
+ PCL_INSTANTIATE_PRODUCT(MovingLeastSquares, ((pcl::PointXYZI))((pcl::PointXYZ)(pcl::PointXYZRGB)(pcl::PointXYZRGBA)(pcl::PointXYZRGBNormal)(pcl::PointNormal)))
14+
+ PCL_INSTANTIATE_PRODUCT(MovingLeastSquares, ((pcl::PointXYZRGB))((pcl::PointXYZ)(pcl::PointXYZI)(pcl::PointXYZRGBA)(pcl::PointXYZRGBNormal)(pcl::PointNormal)))
15+
+ PCL_INSTANTIATE_PRODUCT(MovingLeastSquares, ((pcl::PointXYZRGBA))((pcl::PointXYZ)(pcl::PointXYZI)(pcl::PointXYZRGB)(pcl::PointXYZRGBNormal)(pcl::PointNormal)))
16+
+ PCL_INSTANTIATE_PRODUCT(MovingLeastSquares, ((pcl::PointXYZRGBNormal))((pcl::PointXYZ)(pcl::PointXYZI)(pcl::PointXYZRGB)(pcl::PointXYZRGBA)(pcl::PointNormal)))
17+
+ PCL_INSTANTIATE_PRODUCT(MovingLeastSquares, ((pcl::PointNormal))((pcl::PointXYZ)(pcl::PointXYZI)(pcl::PointXYZRGB)(pcl::PointXYZRGBA)(pcl::PointXYZRGBNormal)))
18+
#endif
19+
#endif // PCL_NO_PRECOMPILE

0 commit comments

Comments
 (0)