Skip to content

Commit

Permalink
Add PCL package
Browse files Browse the repository at this point in the history
  • Loading branch information
planetmarshall committed Jun 13, 2020
1 parent b2153e2 commit 78029bd
Show file tree
Hide file tree
Showing 7 changed files with 255 additions and 0 deletions.
3 changes: 3 additions & 0 deletions recipes/pcl/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
add_subdirectory(pcl)
7 changes: 7 additions & 0 deletions recipes/pcl/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
sources:
"1.10.1":
url: "https://github.com/PointCloudLibrary/pcl/archive/pcl-1.10.1.tar.gz"
sha256: "61ec734ec7c786c628491844b46f9624958c360012c173bbc993c5ff88b4900e"
"1.11.0":
url: "https://github.com/PointCloudLibrary/pcl/archive/pcl-1.11.0.tar.gz"
sha256: "4255c3d3572e9774b5a1dccc235711b7a723197b79430ef539c2044e9ce65954"
198 changes: 198 additions & 0 deletions recipes/pcl/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
import shutil
import os.path

from conans import ConanFile, CMake, tools


class ConanRecipe(ConanFile):
name = "pcl"
description = "Point Cloud Library"
license = "BSD-3-Clause"
homepage = "https://pointclouds.org/"
settings = "os", "compiler", "build_type", "arch"
options = {
"shared": [True, False],
"fPIC": [True, False],
"tools": [True, False],
"usb": [True, False],
"png": [True, False],
"qhull": [True, False],
"cuda": [True, False],
"vtk": [True, False],
"pcap": [True, False],
"opengl": [True, False],
"openni": [True, False],
"openni2": [True, False],
"ensenso": [True, False],
"davidsdk": [True, False],
"dssdk": [True, False],
"rssdk": [True, False],
"kdtree": [True, False],
"octree": [True, False],
"search": [True, False],
"sample_consensus": [True, False],
"filters": [True, False],
"twod": [True, False],
"geometry": [True, False],
"io": [True, False],
"features": [True, False],
"ml": [True, False],
"segmentation": [True, False],
"surface": [True, False],
"registration": [True, False],
"keypoints": [True, False],
"tracking": [True, False],
"recognition": [True, False],
"stereo": [True, False]
}
default_options = {
"shared": True,
"fPIC": True,
"tools": False,
"boost:shared": True,
"usb": False,
"png": True,
"qhull": True,
"cuda": False,
"vtk": False,
"pcap": False,
"opengl": True,
"openni": False,
"openni2": False,
"ensenso": False,
"davidsdk": False,
"dssdk": False,
"rssdk": False,
"kdtree": True,
"octree": True,
"search": False,
"sample_consensus": False,
"filters": False,
"twod": False,
"geometry": True,
"io": True,
"features": False,
"ml": True,
"segmentation": True,
"surface": True,
"registration": True,
"keypoints": False,
"tracking": False,
"recognition": False,
"stereo": False
}
requires = ("boost/[>1.69.0]",
"eigen/[>3.3.5]",
"flann/[>1.9.0]")
generators = "cmake"
exports = ["CMakeLists.txt"]

@property
def _major_minor_version(self):
major, minor, patch = self.version.split(".")
return ".".join([major, minor])

@property
def _source_subfolder(self):
return f"pcl-pcl-{self.version}"

def source(self):
tools.get(**self.conan_data["sources"][self.version])
tools.replace_in_file("CMakeLists.txt", "add_subdirectory(pcl)", f"add_subdirectory({self._source_subfolder})")

def requirements(self):
if self.options.png:
self.requires("libpng/[>1.6.36]")
if self.options.qhull:
self.requires("qhull/[>7.3.0]")
self.options["qhull"].shared=False

def configure(self):
if self.options.registration:
self.options.octree = True
self.options.filters = True
self.options.features = True
if self.options.io:
self.options.octree = True
if self.options.filters:
self.options.kdtree = True
self.options.search = True
self.options.sample_consensus = True
if self.options.segmentation:
self.options.ml = True
if self.options.features:
self.options.twod = True


def _configure_cmake(self):
cmake_definitions = {
"PCL_BUILD_WITH_BOOST_DYNAMIC_LINKING_WIN32": self.options["boost"].shared,
}

pcl_config = {
"EIGEN_ROOT": self.deps_cpp_info["eigen"].rootpath,
"FLANN_ROOT": self.deps_cpp_info["flann"].rootpath,
"BOOST_ROOT": self.deps_cpp_info["boost"].rootpath,
"BUILD_tools": self.options.tools,
"WITH_LIBUSB": self.options.usb,
"WITH_PNG": self.options.png,
"WITH_QHULL": self.options.qhull,
"WITH_CUDA": self.options.cuda,
"WITH_VTK": self.options.vtk,
"WITH_PCAP": self.options.pcap,
"WITH_OPENGL": self.options.opengl,
"WITH_OPENNI": self.options.openni2,
"WITH_OPENNI2": self.options.openni2,
"WITH_ENSENSO": self.options.ensenso,
"WITH_DAVIDSDK": self.options.davidsdk,
"WITH_DSSDK": self.options.dssdk,
"WITH_RSSDK": self.options.rssdk,
"PCL_SHARED_LIBS": self.options.shared
}
pcl_features = {
"BUILD_kdtree": self.options.kdtree,
"BUILD_octree": self.options.octree,
"BUILD_search": self.options.search,
"BUILD_sample_consensus": self.options.sample_consensus,
"BUILD_filters": self.options.filters,
"BUILD_2d": self.options.twod,
"BUILD_geometry": self.options.geometry,
"BUILD_io": self.options.io,
"BUILD_features": self.options.features,
"BUILD_ml": self.options.ml,
"BUILD_segmentation": self.options.segmentation,
"BUILD_surface": self.options.surface,
"BUILD_registration": self.options.registration,
"BUILD_keypoints": self.options.keypoints,
"BUILD_tracking": self.options.tracking,
"BUILD_recognition": self.options.recognition,
"BUILD_stereo": self.options.stereo
}

if self.options.png:
pcl_config["LIBPNG_ROOT"] = self.deps_cpp_info["libpng"].rootpath
if self.options.qhull:
pcl_config["QHULL_ROOT"] = self.deps_cpp_info["qhull"].rootpath
pcl_config["QHULL_USE_STATIC"] = True

cmake = CMake(self)
cmake.definitions.update(cmake_definitions)
cmake.definitions.update(pcl_config)
cmake.definitions.update(pcl_features)
cmake.configure()
return cmake

def build(self):
cmake = self._configure_cmake()
cmake.build()

def package(self):
cmake = self._configure_cmake()
cmake.install()
self.copy(pattern="LICENSE.txt", dst="licenses", src=self._source_subfolder)
shutil.rmtree(os.path.join(self.package_folder, "share"))
shutil.rmtree(os.path.join(self.package_folder, "lib", "pkgconfig"))

def package_info(self):
self.cpp_info.includedirs = [f"include/pcl-{self._major_minor_version}"]
self.cpp_info.libs = tools.collect_libs(self)
9 changes: 9 additions & 0 deletions recipes/pcl/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
cmake_minimum_required(VERSION 3.10)
project(PclTestPackage)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

add_executable(pcl_test_package example.cpp)
target_compile_features(pcl_test_package PUBLIC cxx_std_14)
target_link_libraries(pcl_test_package PRIVATE ${CONAN_TARGETS})
21 changes: 21 additions & 0 deletions recipes/pcl/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from conans import ConanFile, CMake
import os


class PclTestConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"
short_paths = True

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

def imports(self):
self.copy("*.dll", "bin", "bin")

def test(self):
os.chdir('bin')
self.run('.{}pcl_test_package'.format(os.sep))

12 changes: 12 additions & 0 deletions recipes/pcl/all/test_package/example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <pcl/point_types.h>

#include <iostream>

int main() {
pcl::PointXYZ p;
p.x = -1.0f;
p.y = 3.14f;
p.z = 42.0f;

std::cout << "PointXYZ: " << p << std::endl;
}
5 changes: 5 additions & 0 deletions recipes/pcl/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
versions:
"1.10.1":
folder: all
"1.11.0":
folder: all

0 comments on commit 78029bd

Please sign in to comment.