From bc1eb9037ecab0d1455367efada63dcd3f2aab9f Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Sun, 6 Aug 2023 09:25:06 +0300 Subject: [PATCH] (#17933) gtsam: add v4.2.0a9, update package options MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * gtsam: add missing Boost::program_options requirement See https://github.com/borglab/gtsam/blob/4.1.1/cmake/HandleBoost.cmake#L26 * gtsam: add transitive_headers/libs to deps * gtsam: drop test_v1_package * gtsam: backport a patch for C++17 compatibility * gtsam: add v4.2.0a9 https://github.com/borglab/gtsam/releases/tag/4.2a9 * gtsam: update package options - 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 * gtsam: tweak formatting * gtsam: get rid of a duplicate patch * gtsam: handle `build_type_postfixes` option correctly * gtsam: correct metis lib name in 4.0 * gtsam: correct build_type_postfixes behavior * gtsam: fix a bug in 4.2.0a9 * gtsam: add 'lib' prefix to libraries on Windows * gtsam: add patch_source info to conandata.yml * gtsam: apply "lib" prefix on Windows correctly * gtsam: drop v4.0.2 To limit the load on CI. Superseded by v4.0.3. * gtsam: update onetbb and boost versions onetbb/2020.3 did not support Conan v2. * gtsam: better TBB validation * gtsam: add tcmalloc support with gperftools * gtsam: fix Eigen version check * gtsam: enable shared builds on Windows for v4.2 * gtsam: shared builds on Windows are broken in v4.2.0a9 * gtsam: document options with options_description * gtsam: add use_vendored_metis option * gtsam: simplify Conan v1 boilerplate * gtsam: improve default_allocator handling * gtsam: remove use_vendored_metis option It no longer builds with the new metis recipe. --------- Co-authored-by: Francisco Ramírez --- recipes/gtsam/all/conandata.yml | 40 ++- recipes/gtsam/all/conanfile.py | 334 +++++++++++++----- .../all/patches/4.0.2-0001-cmake-boost.patch | 61 ---- .../all/patches/4.0.2-0002-cmake-eigen.patch | 20 -- .../all/patches/4.0.2-0003-macos-rpath.patch | 34 -- ...t.patch => 4.0.3-0004-cmake-project.patch} | 0 .../patches/4.1.1-0005-eigen3-version.patch | 21 ++ .../all/patches/4.2.0-0001-macos-rpath.patch | 30 ++ .../patches/4.2.0-0002-eigen3-version.patch | 20 ++ .../4.2.0a9-0001-fix-invalid-include.patch | 12 + .../gtsam/all/test_v1_package/CMakeLists.txt | 8 - .../gtsam/all/test_v1_package/conanfile.py | 17 - recipes/gtsam/config.yml | 4 +- 13 files changed, 348 insertions(+), 253 deletions(-) delete mode 100644 recipes/gtsam/all/patches/4.0.2-0001-cmake-boost.patch delete mode 100644 recipes/gtsam/all/patches/4.0.2-0002-cmake-eigen.patch delete mode 100644 recipes/gtsam/all/patches/4.0.2-0003-macos-rpath.patch rename recipes/gtsam/all/patches/{4.0.2-0003-cmake-project.patch => 4.0.3-0004-cmake-project.patch} (100%) create mode 100644 recipes/gtsam/all/patches/4.1.1-0005-eigen3-version.patch create mode 100644 recipes/gtsam/all/patches/4.2.0-0001-macos-rpath.patch create mode 100644 recipes/gtsam/all/patches/4.2.0-0002-eigen3-version.patch create mode 100644 recipes/gtsam/all/patches/4.2.0a9-0001-fix-invalid-include.patch delete mode 100644 recipes/gtsam/all/test_v1_package/CMakeLists.txt delete mode 100644 recipes/gtsam/all/test_v1_package/conanfile.py diff --git a/recipes/gtsam/all/conandata.yml b/recipes/gtsam/all/conandata.yml index a7ab46e7ea6fb..eecf7c3eb615e 100644 --- a/recipes/gtsam/all/conandata.yml +++ b/recipes/gtsam/all/conandata.yml @@ -1,14 +1,28 @@ sources: + "4.2.0a9": + url: "https://github.com/borglab/gtsam/archive/refs/tags/4.2a9.tar.gz" + sha256: "a9790e5132bfb2705a5985a1505c3cf9cdf95b711be8352ffa9a9299b279f2f8" "4.1.1": url: "https://github.com/borglab/gtsam/archive/4.1.1.tar.gz" sha256: "c7b5e6cdad52b141c272778f47baf628975457be3e26ed96a7bc2ae685a00af0" "4.0.3": url: "https://github.com/borglab/gtsam/archive/4.0.3.tar.gz" sha256: "eaa561749edf7a2d402981828253e28aed6c717dae35738301c5ab23e2595f25" - "4.0.2": - url: "https://github.com/borglab/gtsam/archive/4.0.2.tar.gz" - sha256: "8770a440f1af98c3f0d9d4dffd568de2d4c21b245e7231e987e26bc236aeb5aa" patches: + "4.2.0a9": + - patch_file: "patches/4.1.1-0001-cmake-boost.patch" + patch_description: "Use boost targets" + patch_type: "conan" + - patch_file: "patches/4.2.0-0001-macos-rpath.patch" + patch_description: "Relocatable shared libs on Apple OS" + patch_type: "conan" + - patch_file: "patches/4.2.0-0002-eigen3-version.patch" + patch_description: "Get Eigen3 version info from Conan" + patch_type: "conan" + - patch_file: "patches/4.2.0a9-0001-fix-invalid-include.patch" + patch_description: "Fix an invalid include for pre-C++17 compatibility" + patch_type: "portability" + patch_source: "https://github.com/borglab/gtsam/pull/1545" "4.1.1": - patch_file: "patches/4.1.1-0001-cmake-boost.patch" patch_description: "Use boost targets" @@ -19,9 +33,12 @@ patches: - patch_file: "patches/4.1.1-0003-macos-rpath.patch" patch_description: "Relocatable shared libs on Apple OS" patch_type: "conan" - - patch_file: "patches/4.0.2-0003-cmake-project.patch" + - patch_file: "patches/4.0.3-0004-cmake-project.patch" patch_description: "CMake: move project() after cmake_minimum_required()" patch_type: "conan" + - patch_file: "patches/4.1.1-0005-eigen3-version.patch" + patch_description: "Get Eigen3 version info from Conan" + patch_type: "conan" "4.0.3": - patch_file: "patches/4.0.3-0001-cmake-boost.patch" patch_description: "Use boost targets" @@ -32,19 +49,6 @@ patches: - patch_file: "patches/4.0.3-0003-macos-rpath.patch" patch_description: "Relocatable shared libs on Apple OS" patch_type: "conan" - - patch_file: "patches/4.0.2-0003-cmake-project.patch" - patch_description: "CMake: move project() after cmake_minimum_required()" - patch_type: "conan" - "4.0.2": - - patch_file: "patches/4.0.2-0001-cmake-boost.patch" - patch_description: "Use boost targets" - patch_type: "conan" - - patch_file: "patches/4.0.2-0002-cmake-eigen.patch" - patch_description: "Use Eigen include variable from CMakeDeps" - patch_type: "conan" - - patch_file: "patches/4.0.2-0003-macos-rpath.patch" - patch_description: "Relocatable shared libs on Apple OS" - patch_type: "conan" - - patch_file: "patches/4.0.2-0003-cmake-project.patch" + - patch_file: "patches/4.0.3-0004-cmake-project.patch" patch_description: "CMake: move project() after cmake_minimum_required()" patch_type: "conan" diff --git a/recipes/gtsam/all/conanfile.py b/recipes/gtsam/all/conanfile.py index 6ed583d1786ac..4320c2bbb7e69 100644 --- a/recipes/gtsam/all/conanfile.py +++ b/recipes/gtsam/all/conanfile.py @@ -15,58 +15,100 @@ class GtsamConan(ConanFile): license = "BSD-3-Clause" homepage = "https://github.com/borglab/gtsam" 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") + description = ("GTSAM is a library of C++ classes that implement " + "smoothing and mapping (SAM) in robotics and vision") + topics = ("mapping", "smoothing", "optimization", "factor-graphs") + package_type = "library" 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], + "default_allocator": [None, "STL", "BoostPool", "TBB", "tcmalloc"], + "disable_new_timers": [True, False], + "enable_consistency_checks": [True, False], + "install_cppunitlite": [True, False], + "install_matlab_toolbox": [True, False], "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], + "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], + + # Removed since v4.1 "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], + "typedef_points_to_vectors": [True, False], + "wrap_serialization": [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, + "default_allocator": None, + "disable_new_timers": False, + "enable_consistency_checks": False, + "install_cppunitlite": True, + "install_matlab_toolbox": False, "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, + "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, + + # < v4.1 only "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, + "typedef_points_to_vectors": False, + "wrap_serialization": True, + } + options_description = { + "allow_deprecated": "Allow use of deprecated methods/functions", + "build_type_postfixes": "Append the build type to the name of compiled libraries", + "build_unstable": "Enable building of gtsam_unstable", + "build_with_march_native": "Build with all instructions supported by native architecture (binary may not be portable!)", + "default_allocator": "Set preferred memory allocator. If unset, defaults to STL or to TBB, if with_TBB is enabled", + "disable_new_timers": "Disables using Boost.chrono for timing", + "enable_consistency_checks": "Enable expensive consistency checks", + "install_cppunitlite": "Install CppUnitLite library as a component", + "install_matlab_toolbox": "Install MATLAB toolbox", + "pose3_expmap": "Use Pose3::EXPMAP as the default mode. If disabled, Pose3::FIRST_ORDER will be used.", + "rot3_expmap": ("Ignore if GTSAM_USE_QUATERNIONS is OFF (Rot3::EXPMAP by default). " + "Otherwise, enable Rot3::EXPMAP, or if disabled, use Rot3::CAYLEY."), + "slow_but_correct_betweenfactor": "Use the slower but correct version of BetweenFactor", + "support_nested_dissection": "Support Metis-based nested dissection", + "tangent_preintegration": "Use the new ImuFactor with integration on tangent space", + "throw_cheirality_exception": "Throw exception when a triangulated point is behind a camera", + "use_quaternions": ("Enable an internal Quaternion representation for rotations instead of rotation matrices. " + "If enabled, Rot3::EXPMAP is enforced by default."), + "with_TBB": "Use Intel Threaded Building Blocks (TBB)", + "with_eigen_MKL": "Eigen will use Intel MKL if available", + "with_eigen_MKL_OPENMP": "Eigen, when using Intel MKL, will also use OpenMP for multithreading if available", + + # < v4.1 only + "build_wrap": "Build Matlab/Cython wrap utility (necessary for Matlab/Cython interface)", + "install_cython_toolbox": "Install Cython toolbox", + "typedef_points_to_vectors": "Typedef Point2 and Point3 to Eigen::Vector equivalents", + "wrap_serialization": "Allow wrapped objects to be saved via boost.serialization", } def export_sources(self): @@ -75,43 +117,90 @@ 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") def requirements(self): - self.requires("boost/1.81.0") - self.requires("eigen/3.4.0") + self.requires("boost/1.82.0", transitive_headers=True) + self.requires("eigen/3.4.0", transitive_headers=True) if self.options.with_TBB: - self.requires("onetbb/2020.3") + self.requires("onetbb/2021.9.0", transitive_headers=True) + if self.options.default_allocator == "tcmalloc": + self.requires("gperftools/2.10.0") + # TODO: add use_vendored_metis=False option + # if self.options.support_nested_dissection and not self.options.use_vendored_metis: + # # 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) @property def _required_boost_components(self): - return ["serialization", "system", "filesystem", "thread", "date_time", "regex", "timer", "chrono"] + # Based on https://github.com/borglab/gtsam/blob/4.2a9/cmake/HandleBoost.cmake#L26 + return [ + "chrono", + "date_time", + "filesystem", + "program_options", + "regex", + "serialization", + "system", + "thread", + "timer", + ] def validate(self): - miss_boost_required_comp = any(self.dependencies["boost"].options.get_safe(f"without_{boost_comp}", True) - for boost_comp in self._required_boost_components) + miss_boost_required_comp = any( + self.dependencies["boost"].options.get_safe(f"without_{boost_comp}", True) + for boost_comp in self._required_boost_components + ) if self.dependencies["boost"].options.header_only or miss_boost_required_comp: raise ConanInvalidConfiguration( f"{self.ref} requires non header-only boost with these components: " f"{', '.join(self._required_boost_components)}" ) - if self.options.with_TBB and not self.dependencies["onetbb"].options.tbbmalloc: - raise ConanInvalidConfiguration("gtsam with tbb requires onetbb:tbbmalloc=True") + if self.options.with_TBB: + if self.options.default_allocator in [None, "TBB"]: + if not self.dependencies["onetbb"].options.tbbmalloc: + raise ConanInvalidConfiguration("GTSAM with TBB requires onetbb/*:tbbmalloc=True") + elif self.options.default_allocator != "tcmalloc": + raise ConanInvalidConfiguration( + "with_TBB option cannot be used with" + f" default_allocator={self.options.default_allocator}" + ) + elif self.options.default_allocator == "TBB": + raise ConanInvalidConfiguration("default_allocator=TBB requires with_TBB=True") 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" + f"{self.ref} does not support shared builds with MSVC. See" + "https://github.com/borglab/gtsam/issues/1087" + if Version(self.version) < "4.2" + else "https://github.com/borglab/gtsam/issues/1541" + ) + + if self.options.allow_deprecated_since_V4 != "deprecated": + self.output.warn( + "'allow_deprecated_since_V4' option is deprecated. Use 'allow_deprecated' instead." ) def source(self): @@ -120,6 +209,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 @@ -128,41 +221,89 @@ 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/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 + 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.3/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.3/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() def _patch_sources(self): apply_conandata_patches(self) + # Honor vc runtime if is_msvc(self): gtsam_build_types_cmake = os.path.join(self.source_folder, "cmake", "GtsamBuildTypes.cmake") replace_in_file(self, gtsam_build_types_cmake, "/MD ", f"/{msvc_runtime_flag(self)} ") replace_in_file(self, gtsam_build_types_cmake, "/MDd ", f"/{msvc_runtime_flag(self)} ") + if self.options.default_allocator == "tcmalloc": + handle_allocators_path = os.path.join(self.source_folder, "cmake", "HandleAllocators.cmake") + if Version(self.version) < "4.1": + handle_allocators_path = os.path.join(self.source_folder, "CMakeLists.txt") + replace_in_file( + self, + handle_allocators_path, + "if(GOOGLE", + "find_package(gperftools REQUIRED)\nset(GOOGLE_PERFTOOLS_FOUND TRUE)\nif(GOOGLE", + ) + replace_in_file( + self, + handle_allocators_path, + 'GTSAM_ADDITIONAL_LIBRARIES "tcmalloc"', + 'GTSAM_ADDITIONAL_LIBRARIES "gperftools::gperftools"', + ) + def build(self): self._patch_sources() cmake = CMake(self) @@ -206,53 +347,60 @@ def _module_file_rel_path(self): def package_info(self): self.cpp_info.set_property("cmake_file_name", "GTSAM") - prefix = "lib" if is_msvc(self) and not self.options.shared else "" - - self.cpp_info.components["libgtsam"].set_property("cmake_target_name", "gtsam") - self.cpp_info.components["libgtsam"].libs = [f"{prefix}gtsam"] - self.cpp_info.components["libgtsam"].requires = [f"boost::{component}" for component in self._required_boost_components] - self.cpp_info.components["libgtsam"].requires.append("eigen::eigen") + gtsam = self.cpp_info.components["libgtsam"] + gtsam.set_property("cmake_target_name", "gtsam") + gtsam.libs = ["gtsam"] + gtsam.requires = [f"boost::{component}" for component in self._required_boost_components] + gtsam.requires.append("eigen::eigen") if self.options.with_TBB: - self.cpp_info.components["libgtsam"].requires.append("onetbb::onetbb") + gtsam.requires.append("onetbb::onetbb") + if self.options.default_allocator == "tcmalloc": + gtsam.requires.append("gperftools::gperftools") if self.options.support_nested_dissection: - self.cpp_info.components["libgtsam"].requires.append("libmetis-gtsam") - if self.settings.os == "Windows" and Version(self.version) >= "4.0.3": - self.cpp_info.components["libgtsam"].system_libs = ["dbghelp"] + gtsam.requires.append("libmetis-gtsam") + if self.settings.os == "Windows": + gtsam.system_libs = ["dbghelp"] if self.options.build_unstable: - self.cpp_info.components["libgtsam_unstable"].set_property("cmake_target_name", "gtsam_unstable") - self.cpp_info.components["libgtsam_unstable"].libs = [f"{prefix}gtsam_unstable"] - self.cpp_info.components["libgtsam_unstable"].requires = ["libgtsam"] + gtsam_unstable = self.cpp_info.components["libgtsam_unstable"] + gtsam_unstable.set_property("cmake_target_name", "gtsam_unstable") + gtsam_unstable.libs = ["gtsam_unstable"] + gtsam_unstable.requires = ["libgtsam"] if self.options.support_nested_dissection: - self.cpp_info.components["libmetis-gtsam"].set_property("cmake_target_name", "metis-gtsam") - self.cpp_info.components["libmetis-gtsam"].libs = ["metis-gtsam"] - self.cpp_info.components["libmetis-gtsam"].names["pkg_config"] = "metis-gtsam" + metis = self.cpp_info.components["libmetis-gtsam"] + metis.set_property("cmake_target_name", "metis-gtsam") + if Version(self.version) >= "4.1": + metis.libs = ["metis-gtsam"] + else: + metis.libs = ["metis"] + metis.names["pkg_config"] = "metis-gtsam" if self.options.install_cppunitlite: - self.cpp_info.components["gtsam_CppUnitLite"].set_property("cmake_target_name", "CppUnitLite") - self.cpp_info.components["gtsam_CppUnitLite"].libs = ["CppUnitLite"] - self.cpp_info.components["gtsam_CppUnitLite"].requires = ["boost::boost"] + cppunitlite = self.cpp_info.components["gtsam_CppUnitLite"] + cppunitlite.set_property("cmake_target_name", "CppUnitLite") + cppunitlite.libs = ["CppUnitLite"] + cppunitlite.requires = ["boost::boost"] + + if is_msvc(self) and not self.options.shared: + for component in self.cpp_info.components.values(): + component.libs = [f"lib{lib}" for lib in component.libs if lib.startswith("gtsam")] + if self.options.build_type_postfixes and self.settings.build_type != "Release": + for component in self.cpp_info.components.values(): + component.libs = [f"{lib}{self.settings.build_type}" for lib in component.libs] # TODO: to remove in conan v2 once cmake_find_package* generators removed self.cpp_info.names["cmake_find_package"] = "GTSAM" self.cpp_info.names["cmake_find_package_multi"] = "GTSAM" - self.cpp_info.components["libgtsam"].names["cmake_find_package"] = "gtsam" - self.cpp_info.components["libgtsam"].names["cmake_find_package_multi"] = "gtsam" - self.cpp_info.components["libgtsam"].build_modules["cmake_find_package"] = [self._module_file_rel_path] - self.cpp_info.components["libgtsam"].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] - if self.options.build_unstable: - self.cpp_info.components["libgtsam_unstable"].names["cmake_find_package"] = "gtsam_unstable" - self.cpp_info.components["libgtsam_unstable"].names["cmake_find_package_multi"] = "gtsam_unstable" - self.cpp_info.components["libgtsam_unstable"].build_modules["cmake_find_package"] = [self._module_file_rel_path] - self.cpp_info.components["libgtsam_unstable"].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] - if self.options.support_nested_dissection: - self.cpp_info.components["libmetis-gtsam"].names["cmake_find_package"] = "metis-gtsam" - self.cpp_info.components["libmetis-gtsam"].names["cmake_find_package_multi"] = "metis-gtsam" - self.cpp_info.components["libmetis-gtsam"].build_modules["cmake_find_package"] = [self._module_file_rel_path] - self.cpp_info.components["libmetis-gtsam"].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] - if self.options.install_cppunitlite: - self.cpp_info.components["gtsam_CppUnitLite"].names["cmake_find_package"] = "CppUnitLite" - self.cpp_info.components["gtsam_CppUnitLite"].names["cmake_find_package_multi"] = "CppUnitLite" - self.cpp_info.components["gtsam_CppUnitLite"].build_modules["cmake_find_package"] = [self._module_file_rel_path] - self.cpp_info.components["gtsam_CppUnitLite"].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] + for component_name, lib_name in [ + ("libgtsam", "gtsam"), + ("libgtsam_unstable", "gtsam_unstable"), + ("libmetis-gtsam", "metis-gtsam"), + ("gtsam_CppUnitLite", "CppUnitLite"), + ]: + if component_name in self.cpp_info.components: + component = self.cpp_info.components[component_name] + component.names["cmake_find_package"] = lib_name + component.names["cmake_find_package_multi"] = lib_name + component.build_modules["cmake_find_package"] = [self._module_file_rel_path] + component.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] diff --git a/recipes/gtsam/all/patches/4.0.2-0001-cmake-boost.patch b/recipes/gtsam/all/patches/4.0.2-0001-cmake-boost.patch deleted file mode 100644 index d19f34cd53327..0000000000000 --- a/recipes/gtsam/all/patches/4.0.2-0001-cmake-boost.patch +++ /dev/null @@ -1,61 +0,0 @@ ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -163,13 +163,13 @@ - set(BOOST_FIND_MINIMUM_VERSION 1.43) - set(BOOST_FIND_MINIMUM_COMPONENTS serialization system filesystem thread program_options date_time timer chrono regex) - --find_package(Boost ${BOOST_FIND_MINIMUM_VERSION} COMPONENTS ${BOOST_FIND_MINIMUM_COMPONENTS}) -+find_package(Boost ${BOOST_FIND_MINIMUM_VERSION} COMPONENTS ${BOOST_FIND_MINIMUM_COMPONENTS} REQUIRED) - - # Required components --if(NOT Boost_SERIALIZATION_LIBRARY OR NOT Boost_SYSTEM_LIBRARY OR NOT Boost_FILESYSTEM_LIBRARY OR -- NOT Boost_THREAD_LIBRARY OR NOT Boost_DATE_TIME_LIBRARY) -- message(FATAL_ERROR "Missing required Boost components >= v1.43, please install/upgrade Boost or configure your search paths.") --endif() -+#if(NOT Boost_SERIALIZATION_LIBRARY OR NOT Boost_SYSTEM_LIBRARY OR NOT Boost_FILESYSTEM_LIBRARY OR -+# NOT Boost_THREAD_LIBRARY OR NOT Boost_DATE_TIME_LIBRARY) -+# message(FATAL_ERROR "Missing required Boost components >= v1.43, please install/upgrade Boost or configure your search paths.") -+#endif() - - # Allow for not using the timer libraries on boost < 1.48 (GTSAM timing code falls back to old timer library) - option(GTSAM_DISABLE_NEW_TIMERS "Disables using Boost.chrono for timing" OFF) -@@ -179,30 +179,22 @@ - # so we downgraded this to classic filenames-based variables, and manually adding - # the target_include_directories(xxx ${Boost_INCLUDE_DIR}) - set(GTSAM_BOOST_LIBRARIES -- optimized ${Boost_SERIALIZATION_LIBRARY_RELEASE} -- optimized ${Boost_SYSTEM_LIBRARY_RELEASE} -- optimized ${Boost_FILESYSTEM_LIBRARY_RELEASE} -- optimized ${Boost_THREAD_LIBRARY_RELEASE} -- optimized ${Boost_DATE_TIME_LIBRARY_RELEASE} -- optimized ${Boost_REGEX_LIBRARY_RELEASE} -- debug ${Boost_SERIALIZATION_LIBRARY_DEBUG} -- debug ${Boost_SYSTEM_LIBRARY_DEBUG} -- debug ${Boost_FILESYSTEM_LIBRARY_DEBUG} -- debug ${Boost_THREAD_LIBRARY_DEBUG} -- debug ${Boost_DATE_TIME_LIBRARY_DEBUG} -- debug ${Boost_REGEX_LIBRARY_DEBUG} -+ Boost::serialization -+ Boost::system -+ Boost::filesystem -+ Boost::thread -+ Boost::date_time -+ Boost::regex - ) - message(STATUS "GTSAM_BOOST_LIBRARIES: ${GTSAM_BOOST_LIBRARIES}") - if (GTSAM_DISABLE_NEW_TIMERS) - message("WARNING: GTSAM timing instrumentation manually disabled") - list_append_cache(GTSAM_COMPILE_DEFINITIONS_PUBLIC DGTSAM_DISABLE_NEW_TIMERS) - else() -- if(Boost_TIMER_LIBRARY) -+ if(TARGET Boost::timer) - list(APPEND GTSAM_BOOST_LIBRARIES -- optimized ${Boost_TIMER_LIBRARY_RELEASE} -- optimized ${Boost_CHRONO_LIBRARY_RELEASE} -- debug ${Boost_TIMER_LIBRARY_DEBUG} -- debug ${Boost_CHRONO_LIBRARY_DEBUG} -+ Boost::timer -+ Boost::chrono - ) - else() - list(APPEND GTSAM_BOOST_LIBRARIES rt) # When using the header-only boost timer library, need -lrt diff --git a/recipes/gtsam/all/patches/4.0.2-0002-cmake-eigen.patch b/recipes/gtsam/all/patches/4.0.2-0002-cmake-eigen.patch deleted file mode 100644 index 21c808ace60fd..0000000000000 --- a/recipes/gtsam/all/patches/4.0.2-0002-cmake-eigen.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -292,7 +292,7 @@ if(GTSAM_USE_SYSTEM_EIGEN) - find_package(Eigen3 REQUIRED) - - # Use generic Eigen include paths e.g. -- set(GTSAM_EIGEN_INCLUDE_FOR_INSTALL "${EIGEN3_INCLUDE_DIR}") -+ set(GTSAM_EIGEN_INCLUDE_FOR_INSTALL "${Eigen3_INCLUDE_DIRS}") - - # check if MKL is also enabled - can have one or the other, but not both! - # Note: Eigen >= v3.2.5 includes our patches -@@ -307,7 +307,7 @@ if(GTSAM_USE_SYSTEM_EIGEN) - endif() - - # The actual include directory (for BUILD cmake target interface): -- set(GTSAM_EIGEN_INCLUDE_FOR_BUILD "${EIGEN3_INCLUDE_DIR}") -+ set(GTSAM_EIGEN_INCLUDE_FOR_BUILD "${Eigen3_INCLUDE_DIRS}") - else() - # Use bundled Eigen include path. - # Clear any variables set by FindEigen3 diff --git a/recipes/gtsam/all/patches/4.0.2-0003-macos-rpath.patch b/recipes/gtsam/all/patches/4.0.2-0003-macos-rpath.patch deleted file mode 100644 index 6bc74d30d7ff1..0000000000000 --- a/recipes/gtsam/all/patches/4.0.2-0003-macos-rpath.patch +++ /dev/null @@ -1,34 +0,0 @@ ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -4,7 +4,6 @@ cmake_minimum_required(VERSION 3.0) - # new feature to Cmake Version > 2.8.12 - # Mac ONLY. Define Relative Path on Mac OS - if(NOT DEFINED CMAKE_MACOSX_RPATH) -- set(CMAKE_MACOSX_RPATH 0) - endif() - - # Set the version number for the library ---- a/gtsam/CMakeLists.txt -+++ b/gtsam/CMakeLists.txt -@@ -177,9 +177,6 @@ if(WIN32) # Add 'lib' prefix to static library to avoid filename collision with - endif() - - if (APPLE AND BUILD_SHARED_LIBS) -- set_target_properties(gtsam PROPERTIES -- INSTALL_NAME_DIR -- "${CMAKE_INSTALL_PREFIX}/lib") - endif() - - install( ---- a/gtsam/3rdparty/metis/libmetis/CMakeLists.txt -+++ b/gtsam/3rdparty/metis/libmetis/CMakeLists.txt -@@ -16,9 +16,6 @@ if(WIN32) - endif() - - if (APPLE) -- set_target_properties(metis PROPERTIES -- INSTALL_NAME_DIR -- "${CMAKE_INSTALL_PREFIX}/lib") - endif() - - install(TARGETS metis EXPORT GTSAM-exports LIBRARY DESTINATION lib ARCHIVE DESTINATION lib RUNTIME DESTINATION bin) diff --git a/recipes/gtsam/all/patches/4.0.2-0003-cmake-project.patch b/recipes/gtsam/all/patches/4.0.3-0004-cmake-project.patch similarity index 100% rename from recipes/gtsam/all/patches/4.0.2-0003-cmake-project.patch rename to recipes/gtsam/all/patches/4.0.3-0004-cmake-project.patch diff --git a/recipes/gtsam/all/patches/4.1.1-0005-eigen3-version.patch b/recipes/gtsam/all/patches/4.1.1-0005-eigen3-version.patch new file mode 100644 index 0000000000000..8bd45c6d8f747 --- /dev/null +++ b/recipes/gtsam/all/patches/4.1.1-0005-eigen3-version.patch @@ -0,0 +1,21 @@ +Otherwise the Eigen version detection will fail due to the Eigen path variable containing a generator expression. +diff --git a/cmake/HandleEigen.cmake b/cmake/HandleEigen.cmake +--- a/cmake/HandleEigen.cmake ++++ b/cmake/HandleEigen.cmake +@@ -46,6 +46,8 @@ + endif() + + # Detect Eigen version: ++set(GTSAM_EIGEN_VERSION "${Eigen3_VERSION_STRING}") ++if (FALSE) + set(EIGEN_VER_H "${GTSAM_EIGEN_INCLUDE_FOR_BUILD}/Eigen/src/Core/util/Macros.h") + if (EXISTS ${EIGEN_VER_H}) + file(READ "${EIGEN_VER_H}" STR_EIGEN_VERSION) +@@ -67,6 +69,7 @@ + else() + message(WARNING "Cannot determine Eigen version, missing file: `${EIGEN_VER_H}`") + endif () ++endif() + + if (MSVC) + if (BUILD_SHARED_LIBS) diff --git a/recipes/gtsam/all/patches/4.2.0-0001-macos-rpath.patch b/recipes/gtsam/all/patches/4.2.0-0001-macos-rpath.patch new file mode 100644 index 0000000000000..2f60f9adaef8a --- /dev/null +++ b/recipes/gtsam/all/patches/4.2.0-0001-macos-rpath.patch @@ -0,0 +1,30 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -5,5 +5,4 @@ cmake_minimum_required(VERSION 3.0) + if(NOT DEFINED CMAKE_MACOSX_RPATH) +- set(CMAKE_MACOSX_RPATH 0) + endif() + + # Set the version number for the library +--- a/cmake/HandleGlobalBuildFlags.cmake ++++ b/cmake/HandleGlobalBuildFlags.cmake +@@ -20,7 +20,6 @@ endif() + + if (APPLE AND BUILD_SHARED_LIBS) + # Set the default install directory on macOS +- set(CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib") + endif() + + ############################################################################### +--- a/gtsam/3rdparty/metis/libmetis/CMakeLists.txt ++++ b/gtsam/3rdparty/metis/libmetis/CMakeLists.txt +@@ -17,9 +17,6 @@ if(WIN32) + endif() + + if (APPLE) +- set_target_properties(metis-gtsam PROPERTIES +- INSTALL_NAME_DIR +- "${CMAKE_INSTALL_PREFIX}/lib") + endif() + + install(TARGETS metis-gtsam EXPORT GTSAM-exports diff --git a/recipes/gtsam/all/patches/4.2.0-0002-eigen3-version.patch b/recipes/gtsam/all/patches/4.2.0-0002-eigen3-version.patch new file mode 100644 index 0000000000000..19bc6febd2db0 --- /dev/null +++ b/recipes/gtsam/all/patches/4.2.0-0002-eigen3-version.patch @@ -0,0 +1,20 @@ +diff --git a/cmake/HandleEigen.cmake b/cmake/HandleEigen.cmake +--- a/cmake/HandleEigen.cmake ++++ b/cmake/HandleEigen.cmake +@@ -59,6 +59,8 @@ + endif() + + # Detect Eigen version: ++set(GTSAM_EIGEN_VERSION "${Eigen3_VERSION_STRING}") ++if (FALSE) + set(EIGEN_VER_H "${GTSAM_EIGEN_INCLUDE_FOR_BUILD}/Eigen/src/Core/util/Macros.h") + if (EXISTS ${EIGEN_VER_H}) + file(READ "${EIGEN_VER_H}" STR_EIGEN_VERSION) +@@ -80,6 +82,7 @@ + else() + message(WARNING "Cannot determine Eigen version, missing file: `${EIGEN_VER_H}`") + endif () ++endif() + + if (MSVC) + if (BUILD_SHARED_LIBS) diff --git a/recipes/gtsam/all/patches/4.2.0a9-0001-fix-invalid-include.patch b/recipes/gtsam/all/patches/4.2.0a9-0001-fix-invalid-include.patch new file mode 100644 index 0000000000000..a0431a45e608d --- /dev/null +++ b/recipes/gtsam/all/patches/4.2.0a9-0001-fix-invalid-include.patch @@ -0,0 +1,12 @@ +diff --git a/gtsam/sfm/DsfTrackGenerator.h b/gtsam/sfm/DsfTrackGenerator.h +--- a/gtsam/sfm/DsfTrackGenerator.h (revision c57988fe554e7213c77fe379c1d7c483de26ad33) ++++ b/gtsam/sfm/DsfTrackGenerator.h (revision 26a37d62103a9b3b828d36e8b1a76f875ed842e3) +@@ -22,7 +22,7 @@ + + #include + #include +-#include ++#include + #include + + namespace gtsam { diff --git a/recipes/gtsam/all/test_v1_package/CMakeLists.txt b/recipes/gtsam/all/test_v1_package/CMakeLists.txt deleted file mode 100644 index 0d20897301b68..0000000000000 --- a/recipes/gtsam/all/test_v1_package/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) - -add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package - ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/gtsam/all/test_v1_package/conanfile.py b/recipes/gtsam/all/test_v1_package/conanfile.py deleted file mode 100644 index 38f4483872d47..0000000000000 --- a/recipes/gtsam/all/test_v1_package/conanfile.py +++ /dev/null @@ -1,17 +0,0 @@ -from conans import ConanFile, CMake, tools -import os - - -class TestPackageConan(ConanFile): - settings = "os", "arch", "compiler", "build_type" - generators = "cmake", "cmake_find_package_multi" - - def build(self): - cmake = CMake(self) - cmake.configure() - cmake.build() - - def test(self): - if not tools.cross_building(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) diff --git a/recipes/gtsam/config.yml b/recipes/gtsam/config.yml index 6f380a83ebb14..9c6d4a9be25c5 100644 --- a/recipes/gtsam/config.yml +++ b/recipes/gtsam/config.yml @@ -1,7 +1,7 @@ versions: + "4.2.0a9": + folder: all "4.1.1": folder: all "4.0.3": folder: all - "4.0.2": - folder: all