Skip to content

Commit

Permalink
small_gicp: update to v0.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
valgur committed Jul 8, 2024
1 parent a125c66 commit d58fc0e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 38 deletions.
6 changes: 3 additions & 3 deletions recipes/small_gicp/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sources:
"cci.20240518":
url: "https://github.com/koide3/small_gicp/archive/5c6f13cfc94c1ab129d32b8554c8bd712dc76346.zip"
sha256: "c1c1ebebf7181f1db3130d24cc56314bf5b7b3669ab7e92a58017889e21de448"
"0.1.2":
url: "https://github.com/koide3/small_gicp/archive/refs/tags/v0.1.2.tar.gz"
sha256: "dc3fc95236079c71dda63706e75bede03b0a2bb24447474da6fced91f0bf4a56"
41 changes: 7 additions & 34 deletions recipes/small_gicp/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.env import VirtualBuildEnv
from conan.tools.files import copy, get, rm, rmdir, download
from conan.tools.microsoft import is_msvc
from conan.tools.scm import Version
import os

Expand All @@ -24,11 +23,13 @@ class IridescenceConan(ConanFile):
options = {
"shared": [True, False],
"fPIC": [True, False],
"with_openmp": [True, False],
"with_tbb": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"with_openmp": True,
"with_tbb": True,
}

Expand Down Expand Up @@ -59,9 +60,10 @@ def layout(self):

def requirements(self):
self.requires("eigen/3.4.0", transitive_headers=True)
# '#pragma omp' is used in public headers
# Note: native MSVC OpenMP is not compatible
self.requires("llvm-openmp/17.0.6", transitive_headers=True, transitive_libs=True)
if self.options.with_openmp:
# '#pragma omp' is used in public headers
# Note: native MSVC OpenMP is not compatible
self.requires("llvm-openmp/18.1.8", transitive_headers=True, transitive_libs=True)
if self.options.with_tbb:
self.requires("onetbb/2021.12.0", transitive_headers=True, transitive_libs=True)

Expand All @@ -88,10 +90,8 @@ def generate(self):

tc = CMakeToolchain(self)
tc.variables["BUILD_HELPER"] = True
tc.variables["BUILD_WITH_OPENMP"] = True
tc.variables["BUILD_WITH_OPENMP"] = self.options.with_openmp
tc.variables["BUILD_WITH_TBB"] = self.options.with_tbb
if is_msvc(self):
tc.preprocessor_definitions["_USE_MATH_DEFINES"] = ""
tc.generate()

deps = CMakeDeps(self)
Expand All @@ -114,23 +114,6 @@ def package(self):
rm(self, "*.pdb", os.path.join(self.package_folder, "lib"))
rm(self, "*.pdb", os.path.join(self.package_folder, "bin"))

@property
def _openmp_flags(self):
# Based on https://github.com/Kitware/CMake/blob/v3.28.1/Modules/FindOpenMP.cmake#L104-L135
if self.settings.compiler == "clang":
return ["-fopenmp=libomp"]
elif self.settings.compiler == "apple-clang":
return ["-Xclang", "-fopenmp"]
elif self.settings.compiler == "gcc":
return ["-fopenmp"]
elif self.settings.compiler == "intel-cc":
return ["-Qopenmp"]
elif self.settings.compiler == "sun-cc":
return ["-xopenmp"]
if is_msvc(self):
return ["-openmp:llvm"]
return None

def package_info(self):
self.cpp_info.set_property("cmake_file_name", "small_gicp")
self.cpp_info.set_property("cmake_target_name", "small_gicp::small_gicp")
Expand All @@ -139,13 +122,3 @@ def package_info(self):

if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.system_libs.append("m")
elif is_msvc(self):
self.cpp_info.defines.append("_USE_MATH_DEFINES")

# TODO: drop after https://github.com/conan-io/conan-center-index/pull/22353 is merged
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.system_libs.extend(["dl", "pthread", "rt"])
self.cpp_info.cflags = self._openmp_flags
self.cpp_info.cxxflags = self._openmp_flags
self.cpp_info.sharedlinkflags = self._openmp_flags
self.cpp_info.exelinkflags = self._openmp_flags
2 changes: 2 additions & 0 deletions recipes/small_gicp/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ def layout(self):

def generate(self):
tc = CMakeToolchain(self)
if self.dependencies["small_gicp"].options.with_openmp:
tc.preprocessor_definitions["WITH_OPENMP"] = ""
if self.dependencies["small_gicp"].options.with_tbb:
tc.preprocessor_definitions["WITH_TBB"] = ""
tc.generate()
Expand Down
7 changes: 7 additions & 0 deletions recipes/small_gicp/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#include <small_gicp/points/point_cloud.hpp>
#include <small_gicp/ann/kdtree.hpp>
#ifdef WITH_OPENMP
#include <small_gicp/ann/kdtree_omp.hpp>
#endif
#ifdef WITH_TBB
#include <small_gicp/ann/kdtree_tbb.hpp>
#endif
Expand All @@ -17,6 +20,10 @@ int main() {
const int num_threads = 1;
std::make_shared<KdTree<PointCloud>>(target, KdTreeBuilderOMP(num_threads));

#ifdef WITH_OPENMP
std::make_shared<KdTree<PointCloud>>(target, KdTreeBuilderOMP());
#endif

#ifdef WITH_TBB
std::make_shared<KdTree<PointCloud>>(target, KdTreeBuilderTBB());
#endif
Expand Down
2 changes: 1 addition & 1 deletion recipes/small_gicp/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
versions:
"cci.20240518":
"0.1.2":
folder: all

0 comments on commit d58fc0e

Please sign in to comment.