Skip to content

Commit

Permalink
gtsam: update package options
Browse files Browse the repository at this point in the history
- Covers all options that could be found in GTSAM build scripts.
- Added links to source code since they are hard to find otherwise.
- Added `allow_deprecated` option and deprecated `allow_deprecated_since_V4` as the wording of the GTSAM variable keeps changing but the meaning has stayed the same.
- Added vars:
  GTSAM_DEFAULT_ALLOCATOR
  GTSAM_SLOW_BUT_CORRECT_BETWEENFACTOR
  GTSAM_USE_SYSTEM_METIS
  GTSAM_MEX_BUILD_STATIC_MODULE
  • Loading branch information
valgur committed Jun 15, 2023
1 parent f764397 commit 278f47e
Showing 1 changed file with 111 additions and 46 deletions.
157 changes: 111 additions & 46 deletions recipes/gtsam/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,56 +17,66 @@ class GtsamConan(ConanFile):
url = "https://github.com/conan-io/conan-center-index"
description = ("GTSAM is a library of C++ classes that implement\
smoothing and mapping (SAM) in robotics and vision")
topics = ("mapping", "smoothing")
topics = ("mapping", "smoothing", "optimization", "factor-graphs")

settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
"use_quaternions": [True, False],
"allow_deprecated": [True, False],
"allow_deprecated_since_V4": [True, False, "deprecated"],
"build_type_postfixes": [True, False],
"build_unstable": [True, False],
"build_with_march_native": [True, False],
"build_wrap": [True, False],
"default_allocator": [None, "STL", "BoostPool", "TBB", "tcmalloc"],
"disable_new_timers": [True, False],
"enable_consistency_checks": [True, False],
"install_cppunitlite": [True, False],
"install_cython_toolbox": [True, False],
"install_matlab_toolbox": [True, False],
"print_summary_padding_length": ["ANY"],
"pose3_expmap": [True, False],
"rot3_expmap": [True, False],
"enable_consistency_checks": [True, False],
"slow_but_correct_betweenfactor": [True, False],
"support_nested_dissection": [True, False],
"tangent_preintegration": [True, False],
"throw_cheirality_exception": [True, False],
"typedef_points_to_vectors": [True, False],
"use_quaternions": [True, False],
"with_TBB": [True, False],
"with_eigen_MKL": [True, False],
"with_eigen_MKL_OPENMP": [True, False],
"throw_cheirality_exception": [True, False],
"allow_deprecated_since_V4": [True, False],
"typedef_points_to_vectors": [True, False],
"support_nested_dissection": [True, False],
"tangent_preintegration": [True, False],
"build_wrap": [True, False],
"wrap_serialization": [True, False],
"build_unstable": [True, False],
"disable_new_timers": [True, False],
"build_type_postfixes": [True, False],
"install_matlab_toolbox": [True, False],
"install_cython_toolbox": [True, False],
"install_cppunitlite": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"use_quaternions": False,
"allow_deprecated": True,
"allow_deprecated_since_V4": "deprecated",
"build_type_postfixes": True,
"build_unstable": True,
"build_with_march_native": False,
"build_wrap": False,
"default_allocator": None,
"disable_new_timers": False,
"enable_consistency_checks": False,
"install_cppunitlite": True,
"install_cython_toolbox": False,
"install_matlab_toolbox": False,
"print_summary_padding_length": 50,
"pose3_expmap": False,
"rot3_expmap": False,
"enable_consistency_checks": False,
"slow_but_correct_betweenfactor": False,
"support_nested_dissection": False,
"tangent_preintegration": False,
"throw_cheirality_exception": True,
"typedef_points_to_vectors": False,
"use_quaternions": False,
"with_TBB": False,
"with_eigen_MKL": False,
"with_eigen_MKL_OPENMP": False,
"throw_cheirality_exception": True,
"allow_deprecated_since_V4": True,
"typedef_points_to_vectors": False,
"support_nested_dissection": False,
"tangent_preintegration": False,
"build_wrap": False,
"wrap_serialization": True,
"build_unstable": True,
"disable_new_timers": False,
"build_type_postfixes": True,
"install_matlab_toolbox": False,
"install_cython_toolbox": False,
"install_cppunitlite": True,
}

def export_sources(self):
Expand All @@ -75,12 +85,21 @@ def export_sources(self):
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
if Version(self.version) >= "4.1":
del self.options.build_wrap
del self.options.install_cython_toolbox
del self.options.typedef_points_to_vectors
del self.options.wrap_serialization
else:
del self.options.slow_but_correct_betweenfactor

def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")
if self.options.with_TBB:
self.options["onetbb"].tbbmalloc = True
if self.options.allow_deprecated_since_V4 != "deprecated":
self.output.warn("'allow_deprecated_since_V4' option is deprecated. Use 'allow_deprecated' instead.")

def layout(self):
cmake_layout(self, src_folder="src")
Expand All @@ -90,9 +109,18 @@ def requirements(self):
self.requires("eigen/3.4.0", transitive_headers=True)
if self.options.with_TBB:
self.requires("onetbb/2020.3", transitive_headers=True, transitive_libs=True)
# TODO: port metis recipe to Conan v2
# if Version(self.version) >= "4.1" and self.options.support_nested_dissection:
# # Used in a public header here:
# # https://github.com/borglab/gtsam/blob/4.2a9/gtsam_unstable/partition/FindSeparator-inl.h#L23-L27
# self.requires("metis/5.1.1", transitive_headers=True, transitive_libs=True)
# TODO: add gperftools to ConanCenter
# if self.options.default_allocator == "tcmalloc":
# self.requires("gperftools/2.10")

@property
def _required_boost_components(self):
# Based on https://github.com/borglab/gtsam/blob/4.2a9/cmake/HandleBoost.cmake#L26
return [
"chrono",
"date_time",
Expand All @@ -119,7 +147,7 @@ def validate(self):

check_min_vs(self, "191")

if Version(self.version) >= "4.1.0" and is_msvc(self) and self.options.shared:
if Version(self.version) >= "4.1" and is_msvc(self) and self.options.shared:
raise ConanInvalidConfiguration(
f"{self.ref} does not support shared builds with MSVC. See https://github.com/borglab/gtsam/issues/1087"
)
Expand All @@ -130,6 +158,10 @@ def source(self):
def generate(self):
tc = CMakeToolchain(self)
tc.variables["BUILD_SHARED_LIBS"] = self.options.shared
# https://github.com/borglab/gtsam/blob/4.2a9/cmake/HandleGeneralOptions.cmake
tc.variables["GTSAM_BUILD_UNSTABLE"] = self.options.build_unstable
tc.variables["GTSAM_UNSTABLE_BUILD_PYTHON"] = False
tc.variables["GTSAM_UNSTABLE_INSTALL_MATLAB_TOOLBOX"] = self.options.install_matlab_toolbox
tc.variables["GTSAM_USE_QUATERNIONS"] = self.options.use_quaternions
tc.variables["GTSAM_POSE3_EXPMAP"] = self.options.pose3_expmap
tc.variables["GTSAM_ROT3_EXPMAP"] = self.options.rot3_expmap
Expand All @@ -138,30 +170,63 @@ def generate(self):
tc.variables["GTSAM_WITH_EIGEN_MKL"] = self.options.with_eigen_MKL
tc.variables["GTSAM_WITH_EIGEN_MKL_OPENMP"] = self.options.with_eigen_MKL_OPENMP
tc.variables["GTSAM_THROW_CHEIRALITY_EXCEPTION"] = self.options.throw_cheirality_exception
tc.variables["GTSAM_ALLOW_DEPRECATED_SINCE_V4"] = self.options.allow_deprecated_since_V4
tc.variables["GTSAM_TYPEDEF_POINTS_TO_VECTORS"] = self.options.typedef_points_to_vectors
tc.variables["GTSAM_BUILD_PYTHON"] = False
tc.variables["GTSAM_INSTALL_MATLAB_TOOLBOX"] = self.options.install_matlab_toolbox
tc.variables["GTSAM_ALLOW_DEPRECATED_SINCE_V4"] = self.options.allow_deprecated
if self.options.allow_deprecated_since_V4 != "deprecated":
tc.variables["GTSAM_ALLOW_DEPRECATED_SINCE_V4"] = self.options.allow_deprecated_since_V4
tc.variables["GTSAM_ALLOW_DEPRECATED_SINCE_V41"] = self.options.allow_deprecated
tc.variables["GTSAM_ALLOW_DEPRECATED_SINCE_V42"] = self.options.allow_deprecated
tc.variables["GTSAM_SUPPORT_NESTED_DISSECTION"] = self.options.support_nested_dissection
tc.variables["GTSAM_TANGENT_PREINTEGRATION"] = self.options.tangent_preintegration
# Added in 4.1+
if Version(self.version) >= "4.1":
tc.variables["GTSAM_SLOW_BUT_CORRECT_BETWEENFACTOR"] = self.options.slow_but_correct_betweenfactor
tc.variables["GTSAM_BUILD_WITH_CCACHE"] = False
tc.variables["GTSAM_BUILD_UNSTABLE"] = self.options.build_unstable
tc.variables["GTSAM_DISABLE_NEW_TIMERS"] = self.options.disable_new_timers
# https://github.com/borglab/gtsam/blob/4.2a9/cmake/HandleAllocators.cmake
if self.options.default_allocator is not None:
tc.variables["GTSAM_DEFAULT_ALLOCATOR"] = self.options.default_allocator
# https://github.com/borglab/gtsam/blob/4.2a9/cmake/GtsamBuildTypes.cmake#L59
tc.variables["GTSAM_BUILD_TYPE_POSTFIXES"] = self.options.build_type_postfixes
# https://github.com/borglab/gtsam/blob/4.2a9/cmake/GtsamBuildTypes.cmake#L193
tc.variables["GTSAM_BUILD_WITH_MARCH_NATIVE"] = self.options.build_with_march_native
# https://github.com/borglab/gtsam/blob/4.2a9/cmake/GtsamPrinting.cmake#L15
tc.variables["GTSAM_PRINT_SUMMARY_PADDING_LENGTH"] = self.options.print_summary_padding_length
# https://github.com/borglab/gtsam/blob/4.2a9/cmake/HandleBoost.cmake#L36
tc.variables["GTSAM_DISABLE_NEW_TIMERS"] = self.options.disable_new_timers
# https://github.com/borglab/gtsam/blob/4.2a9/CppUnitLite/CMakeLists.txt#L13
tc.variables["GTSAM_INSTALL_CPPUNITLITE"] = self.options.install_cppunitlite
# https://github.com/borglab/gtsam/blob/4.2a9/cmake/HandleEigen.cmake#L3
tc.variables["GTSAM_USE_SYSTEM_EIGEN"] = True
# https://github.com/borglab/gtsam/blob/4.2a9/cmake/HandleMetis.cmake#L11
# TODO: set to True when metis from CC can be used
tc.variables["GTSAM_USE_SYSTEM_METIS"] = False
# https://github.com/borglab/gtsam/blob/4.2a9/gtsam/3rdparty/CMakeLists.txt#L76
tc.variables["GTSAM_INSTALL_GEOGRAPHICLIB"] = False
# https://github.com/borglab/gtsam/blob/4.2a9/matlab/CMakeLists.txt#L14-L15
tc.variables["GTSAM_MEX_BUILD_STATIC_MODULE"] = False
# https://github.com/borglab/gtsam/blob/4.2a9/cmake/GtsamTesting.cmake#L89-L91
tc.variables["GTSAM_BUILD_TESTS"] = False
tc.variables["Boost_USE_STATIC_LIBS"] = not self.dependencies["boost"].options.shared
tc.variables["Boost_NO_SYSTEM_PATHS"] = True
tc.variables["GTSAM_BUILD_EXAMPLES_ALWAYS"] = False
tc.variables["GTSAM_BUILD_TIMING_ALWAYS"] = False
# https://github.com/borglab/gtsam/blob/4.2a9/doc/CMakeLists.txt
tc.variables["GTSAM_BUILD_DOCS"] = False
tc.variables["GTSAM_BUILD_DOC_HTML"] = False
tc.variables["GTSAM_BUILD_EXAMPLES_ALWAYS"] = False
tc.variables["GTSAM_BUILD_WRAP"] = self.options.build_wrap
tc.variables["GTSAM_BUILD_WITH_MARCH_NATIVE"] = False
tc.variables["GTSAM_WRAP_SERIALIZATION"] = self.options.wrap_serialization
tc.variables["GTSAM_INSTALL_MATLAB_TOOLBOX"] = self.options.install_matlab_toolbox
tc.variables["GTSAM_INSTALL_CYTHON_TOOLBOX"] = self.options.install_cython_toolbox
tc.variables["GTSAM_INSTALL_CPPUNITLITE"] = self.options.install_cppunitlite
tc.variables["GTSAM_INSTALL_GEOGRAPHICLIB"] = False
tc.variables["GTSAM_USE_SYSTEM_EIGEN"] = True
tc.variables["GTSAM_BUILD_TYPE_POSTFIXES"] = False
tc.variables["GTSAM_BUILD_DOC_LATEX"] = False

# Removed in 4.1+
if Version(self.version) < "4.1":
# https://github.com/borglab/gtsam/blob/4.0.2/CMakeLists.txt
tc.variables["GTSAM_BUILD_WRAP"] = self.options.build_wrap
tc.variables["GTSAM_INSTALL_CYTHON_TOOLBOX"] = self.options.install_cython_toolbox
tc.variables["GTSAM_TYPEDEF_POINTS_TO_VECTORS"] = self.options.typedef_points_to_vectors
# https://github.com/borglab/gtsam/blob/4.0.2/wrap/CMakeLists.txt#L15
tc.variables["GTSAM_WRAP_SERIALIZATION"] = self.options.wrap_serialization

tc.variables["Boost_USE_STATIC_LIBS"] = not self.dependencies["boost"].options.shared
tc.variables["Boost_NO_SYSTEM_PATHS"] = True
tc.generate()

deps = CMakeDeps(self)
deps.generate()

Expand Down

0 comments on commit 278f47e

Please sign in to comment.