Skip to content

Commit

Permalink
(#18389) Add pcl PointCloudLibrary package
Browse files Browse the repository at this point in the history
* Add pcl PointCloudLibrary package

Inspired from #1891

* pcl: misc recipe tweaks

* Update recipes/pcl/all/conanfile.py

Co-authored-by: Martin Valgur <martin.valgur@gmail.com>

* pcl: Further fixes to Conan targets use in CMake

* pcl: Fix buggy OpenNI detection if libusb missing

* pcl: Fix PCL CMake config breaking OpenGL detection

* pcl: Fix _add_component() bugs

* pcl: add TODOs for missing Conan packages

* pcl: set_property("cmake_find_mode", "both")

* pcl: more accurate modelling of PCL components

* pcl: tidy description

* Enable opengl event if with_vtk is false

- Enable opengl event if with_vtk is false as done in PCL CMakeLists.txt

* Revert "Enable opengl event if with_vtk is false"

This reverts commit c4be26d.

* Enable opengl only if with_vtk==True

* test is_msvc() method

* test is_msvc_static_runtime

* pcl: make components optional, add full dependency info

* pcl: fixes to the component system

* pcl: set OpenGL_GL_PREFERENCE=GLVND

* pcl: fix _extra_libs handling

* pcl: fix CUDA support

* pcl: add all VTK system package variants

* pcl: add missing transitive_headers=True based on installed header includes

* pcl: add ws2_32 dep on Windows

* Restore is_msvc_static_runtime import

* pcl: fix Conan v1 issue

* pcl: new add_build_type_postfix option, fix library naming on Windows

* Take into account @maksim-petukhov  remark

* Take into account @valgur remark

* Take into account maksim-petukhov remark

* Set instantiate_only_core_point_types option at True

* pcl: restore zlib dependency

* pcl: adjust precompile_only_core_point_types name, add comment

Based on https://github.com/PointCloudLibrary/pcl/blob/3ed96c246e5c873713ec670b895469d09149a552/cmake/pcl_options.cmake#L49

* Add rm to prevent PDBs files install

---------

Co-authored-by: Martin Valgur <martin.valgur@gmail.com>
  • Loading branch information
EstebanDugueperoux2 and valgur committed Aug 22, 2023
1 parent a065baf commit 9be5d79
Show file tree
Hide file tree
Showing 10 changed files with 858 additions and 0 deletions.
19 changes: 19 additions & 0 deletions recipes/pcl/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
sources:
"1.13.1":
url: https://github.com/PointCloudLibrary/pcl/archive/refs/tags/pcl-1.13.1.tar.gz
sha256: 8ab98a9db371d822de0859084a375a74bdc7f31c96d674147710cf4101b79621
patches:
"1.13.1":
- patch_file: "patches/0001-cmake_use_conan_targets.patch"
patch_description: "Update PCL CMake files to work with Conan"
patch_type: "conan"
- patch_file: "patches/0001-fix-FindOpenNI-bug.patch"
patch_description: "Fix a libusb detection bug in FindOpenNI.cmake"
patch_type: "bugfix"
- patch_file: "patches/0001-Add-Eigen3-Eigen-target-in-pcl_common-target.patch"
patch_description: "Add Eigen3::Eigen target to pcl_common target"
patch_type: "conan"
- patch_file: "patches/0001-ReportFixAboutMemoryConsumptionDuringBuild.patch"
patch_description: "MovingLeastSquares: reduce the number of instantiations to reduce compile time"
patch_source: "https://github.com/PointCloudLibrary/pcl/pull/5764"
patch_type: "conan"
579 changes: 579 additions & 0 deletions recipes/pcl/all/conanfile.py

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
From a975f68d2e399a1563fe0d66b2c048978f0282d1 Mon Sep 17 00:00:00 2001
From: Esteban DUGUEPEROUX <esteban.dugueperoux@gmail.com>
Date: Mon, 7 Aug 2023 23:50:12 +0200
Subject: [PATCH] Add Eigen3::Eigen target in pcl_common target

---
common/CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt
index 48e1a202e..e0ced5241 100644
--- a/common/CMakeLists.txt
+++ b/common/CMakeLists.txt
@@ -179,7 +179,7 @@ target_include_directories(${LIB_NAME} PUBLIC
$<INSTALL_INTERFACE:include>
)

-target_link_libraries(${LIB_NAME} Boost::boost)
+target_link_libraries(${LIB_NAME} Boost::boost Eigen3::Eigen)

if(MSVC AND NOT (MSVC_VERSION LESS 1915))
# MSVC resolved a byte alignment issue in compiler version 15.9
--
2.41.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
From 0bc2f2cc369f7d013ee5c29075188c4e26ea6f87 Mon Sep 17 00:00:00 2001
From: Markus Vieth <mvieth@techfak.uni-bielefeld.de>
Date: Sat, 15 Jul 2023 15:49:25 +0200
Subject: [PATCH] MovingLeastSquares: reduce the number of instantiations to
reduce compile time PCL_XYZ_POINT_TYPES currently contains 18 types, so
previously, MLS was instantiated for 18*18=324 different type combinations.
However, among those were instantiations which are likely used by nobody
(like `pcl::MovingLeastSquares<pcl::PointWithRange, pcl::PointDEM>`). With
these changes, MLS is only instantiated 6*6+(18-6)=48 times. The most common
type combinations should be covered, but if someone uses an uncommon
combinations, they have to add `#define PCL_NO_PRECOMPILE` before including
`pcl/surface/mls.h` to avoid linker errors.

---
surface/src/mls.cpp | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/surface/src/mls.cpp b/surface/src/mls.cpp
index ba2fd655300..c948f4d19e1 100644
--- a/surface/src/mls.cpp
+++ b/surface/src/mls.cpp
@@ -80,6 +80,15 @@ pcl::MLSResult::calculatePrincipalCurvatures (const double u, const double v) co
PCL_INSTANTIATE_PRODUCT(MovingLeastSquares, ((pcl::PointXYZ)(pcl::PointXYZI)(pcl::PointXYZRGB)(pcl::PointXYZRGBA)(pcl::PointXYZRGBNormal)(pcl::PointNormal))
((pcl::PointXYZ)(pcl::PointXYZI)(pcl::PointXYZRGB)(pcl::PointXYZRGBA)(pcl::PointXYZRGBNormal)(pcl::PointNormal)))
#else
- PCL_INSTANTIATE_PRODUCT(MovingLeastSquares, (PCL_XYZ_POINT_TYPES)(PCL_XYZ_POINT_TYPES))
+ // PCL_INSTANTIATE_PRODUCT(MovingLeastSquares, (PCL_XYZ_POINT_TYPES)(PCL_XYZ_POINT_TYPES))
+ // All instantiations that are available with PCL_ONLY_CORE_POINT_TYPES, plus instantiations for all XYZ types where PointInT and PointOutT are the same
+ #define PCL_INSTANTIATE_MovingLeastSquaresSameInAndOut(T) template class PCL_EXPORTS pcl::MovingLeastSquares<T,T>;
+ PCL_INSTANTIATE(MovingLeastSquaresSameInAndOut, PCL_XYZ_POINT_TYPES)
+ PCL_INSTANTIATE_PRODUCT(MovingLeastSquares, ((pcl::PointXYZ))((pcl::PointXYZI)(pcl::PointXYZRGB)(pcl::PointXYZRGBA)(pcl::PointXYZRGBNormal)(pcl::PointNormal)))
+ PCL_INSTANTIATE_PRODUCT(MovingLeastSquares, ((pcl::PointXYZI))((pcl::PointXYZ)(pcl::PointXYZRGB)(pcl::PointXYZRGBA)(pcl::PointXYZRGBNormal)(pcl::PointNormal)))
+ PCL_INSTANTIATE_PRODUCT(MovingLeastSquares, ((pcl::PointXYZRGB))((pcl::PointXYZ)(pcl::PointXYZI)(pcl::PointXYZRGBA)(pcl::PointXYZRGBNormal)(pcl::PointNormal)))
+ PCL_INSTANTIATE_PRODUCT(MovingLeastSquares, ((pcl::PointXYZRGBA))((pcl::PointXYZ)(pcl::PointXYZI)(pcl::PointXYZRGB)(pcl::PointXYZRGBNormal)(pcl::PointNormal)))
+ PCL_INSTANTIATE_PRODUCT(MovingLeastSquares, ((pcl::PointXYZRGBNormal))((pcl::PointXYZ)(pcl::PointXYZI)(pcl::PointXYZRGB)(pcl::PointXYZRGBA)(pcl::PointNormal)))
+ PCL_INSTANTIATE_PRODUCT(MovingLeastSquares, ((pcl::PointNormal))((pcl::PointXYZ)(pcl::PointXYZI)(pcl::PointXYZRGB)(pcl::PointXYZRGBA)(pcl::PointXYZRGBNormal)))
#endif
#endif // PCL_NO_PRECOMPILE
52 changes: 52 additions & 0 deletions recipes/pcl/all/patches/0001-cmake_use_conan_targets.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -297,7 +297,7 @@
# OpenMP (optional)
option(WITH_OPENMP "Build with parallelization using OpenMP" TRUE)
if(WITH_OPENMP)
- find_package(OpenMP COMPONENTS C CXX)
+ find_package(OpenMP REQUIRED COMPONENTS C CXX)
endif()
if(OpenMP_FOUND)
string(APPEND CMAKE_C_FLAGS " ${OpenMP_C_FLAGS}")
@@ -319,11 +319,11 @@
find_package(Threads REQUIRED)

# Eigen (required)
-find_package(Eigen 3.3 REQUIRED)
+find_package(EIGEN REQUIRED CONFIG)
include_directories(SYSTEM ${EIGEN_INCLUDE_DIRS})

# FLANN (required)
-find_package(FLANN 1.9.1 REQUIRED)
+find_package(FLANN CONFIG)
if(NOT (${FLANN_LIBRARY_TYPE} MATCHES ${PCL_FLANN_REQUIRED_TYPE}) AND NOT (${PCL_FLANN_REQUIRED_TYPE} MATCHES "DONTCARE"))
message(FATAL_ERROR "Flann was selected with ${PCL_FLANN_REQUIRED_TYPE} but found as ${FLANN_LIBRARY_TYPE}")
endif()
@@ -359,7 +359,7 @@
# LibPNG
option(WITH_PNG "PNG file support" TRUE)
if(WITH_PNG)
- find_package(PNG)
+ find_package(PNG REQUIRED CONFIG)
if(PNG_FOUND)
set(HAVE_PNG ON)
include_directories(SYSTEM "${PNG_INCLUDE_DIR}")
@@ -369,7 +369,7 @@
# Qhull
option(WITH_QHULL "Include convex-hull operations" TRUE)
if(WITH_QHULL)
- find_package(Qhull)
+ find_package(QHULL REQUIRED CONFIG)
if(NOT (${QHULL_LIBRARY_TYPE} MATCHES ${PCL_QHULL_REQUIRED_TYPE}) AND NOT (${PCL_QHULL_REQUIRED_TYPE} MATCHES "DONTCARE"))
message(FATAL_ERROR "Qhull was selected with ${PCL_QHULL_REQUIRED_TYPE} but found as ${QHULL_LIBRARY_TYPE}")
endif()
@@ -404,7 +404,7 @@
#Find PCAP
option(WITH_PCAP "pcap file capabilities in Velodyne HDL driver" TRUE)
if(WITH_PCAP)
- find_package(Pcap)
+ find_package(PCAP REQUIRED CONFIG)
endif()

# OpenGL and GLUT
32 changes: 32 additions & 0 deletions recipes/pcl/all/patches/0001-fix-FindOpenNI-bug.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
--- cmake/Modules/FindOpenNI.cmake
+++ cmake/Modules/FindOpenNI.cmake
@@ -52,7 +52,12 @@

# Libraries
if(NOT WIN32)
- find_package(libusb REQUIRED)
+ find_package(libusb QUIET)
+ if (NOT libusb_FOUND)
+ message(WARNING "Found OpenNI library, but required libusb is not available")
+ set(OPENNI_FOUND FALSE)
+ return()
+ endif()
set(OPENNI_LIBRARIES ${OPENNI_LIBRARY} libusb::libusb)
else()
set(OPENNI_LIBRARIES ${OPENNI_LIBRARY})
--- cmake/Modules/FindOpenNI2.cmake
+++ cmake/Modules/FindOpenNI2.cmake
@@ -42,7 +42,12 @@

# Libraries
if(NOT WIN32)
- find_package(libusb REQUIRED)
+ find_package(libusb QUIET)
+ if (NOT libusb_FOUND)
+ message(WARNING "Found OpenNI2 library, but required libusb is not available")
+ set(OPENNI2_FOUND FALSE)
+ return()
+ endif()
set(OPENNI2_LIBRARIES ${OPENNI2_LIBRARY} libusb::libusb)
else()
set(OPENNI2_LIBRARIES ${OPENNI2_LIBRARY})
10 changes: 10 additions & 0 deletions recipes/pcl/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 3.15)

project(test_package CXX)

find_package(PCL REQUIRED surface CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)

target_link_libraries(${PROJECT_NAME} PRIVATE PCL::filters)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)
27 changes: 27 additions & 0 deletions recipes/pcl/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout, CMake
import os


# It will become the standard on Conan 2.x
class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"
test_type = "explicit"

def requirements(self):
self.requires(self.tested_reference_str)

def layout(self):
cmake_layout(self)

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindir, "test_package")
self.run(bin_path, env="conanrun")
73 changes: 73 additions & 0 deletions recipes/pcl/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// Copied from https://github.com/PointCloudLibrary/pcl/blob/pcl-1.13.1/examples/filters/example_extract_indices.cpp
/*
* Software License Agreement (BSD License)
*
* Point Cloud Library (PCL) - www.pointclouds.org
* Copyright (c) 2009-2011, Willow Garage, Inc.
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Willow Garage, Inc. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* $Id: example_ExtractIndices.cpp 4117 2012-01-31 17:56:02Z aichim $
*
*/

#include <iostream>

#include <pcl/filters/extract_indices.h>

int
main (int, char**)
{
using PointType = pcl::PointXYZ;
using CloudType = pcl::PointCloud<PointType>;
CloudType::Ptr cloud (new CloudType);
cloud->is_dense = false;
PointType p;
for (unsigned int i = 0; i < 5; ++i)
{
p.x = p.y = p.z = static_cast<float> (i);
cloud->push_back (p);
}

std::cout << "Cloud has " << cloud->size () << " points." << std::endl;

pcl::PointIndices indices;
indices.indices.push_back (0);
indices.indices.push_back (2);

pcl::ExtractIndices<PointType> extract_indices;
extract_indices.setIndices (pcl::make_shared<const pcl::PointIndices> (indices));
extract_indices.setInputCloud (cloud);
pcl::PointCloud<pcl::PointXYZ>::Ptr output (new pcl::PointCloud<pcl::PointXYZ>);
extract_indices.filter (*output);

std::cout << "Output has " << output->size () << " points." << std::endl;
return (0);
}
3 changes: 3 additions & 0 deletions recipes/pcl/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"1.13.1":
folder: all

0 comments on commit 9be5d79

Please sign in to comment.