diff --git a/recipes/gtsam/all/CMakeLists.txt b/recipes/gtsam/all/CMakeLists.txt index f52f2456d347d..04c96c99f25c3 100644 --- a/recipes/gtsam/all/CMakeLists.txt +++ b/recipes/gtsam/all/CMakeLists.txt @@ -2,6 +2,6 @@ cmake_minimum_required(VERSION 3.15) project(cmake_wrapper) include(conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(KEEP_RPATHS) add_subdirectory("source_subfolder") diff --git a/recipes/gtsam/all/conandata.yml b/recipes/gtsam/all/conandata.yml index be9b2302c5966..1612a37c7aa97 100644 --- a/recipes/gtsam/all/conandata.yml +++ b/recipes/gtsam/all/conandata.yml @@ -1,14 +1,18 @@ sources: - "4.0.2": - url: "https://github.com/borglab/gtsam/archive/4.0.2.tar.gz" - sha256: "8770a440f1af98c3f0d9d4dffd568de2d4c21b245e7231e987e26bc236aeb5aa" "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.0.3": + - patch_file: "patches/0001-conan-4.0.3.patch" + base_path: "source_subfolder" + - patch_file: "patches/0002-macos-rpath-4.0.3.patch" + base_path: "source_subfolder" "4.0.2": - - patch_file: "patches/conan-4.0.2.patch" + - patch_file: "patches/0001-conan-4.0.2.patch" base_path: "source_subfolder" - "4.0.3": - - patch_file: "patches/conan-4.0.3.patch" + - patch_file: "patches/0002-macos-rpath-4.0.2.patch" base_path: "source_subfolder" diff --git a/recipes/gtsam/all/conanfile.py b/recipes/gtsam/all/conanfile.py index dade01dc5e7b9..5ec6b807c74ad 100644 --- a/recipes/gtsam/all/conanfile.py +++ b/recipes/gtsam/all/conanfile.py @@ -1,154 +1,178 @@ -import os -import stat +from conan.tools.microsoft import msvc_runtime_flag from conans import ConanFile, tools, CMake from conans.errors import ConanInvalidConfiguration -from conans.tools import Version +import os +import textwrap + +required_conan_version = ">=1.43.0" -required_conan_version = ">=1.32.0" -class gtsamConan(ConanFile): +class GtsamConan(ConanFile): name = "gtsam" 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 = ("conan", "gtsam", "mapping", "smoothing") + topics = ("gtsam", "mapping", "smoothing") + settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], - "fPIC": [True, False], - "use_quaternions": [True, False], - "pose3_expmap": [True, False], - "rot3_expmap": [True, False], - "enable_consistency_checks": [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], - "install_geographiclib": [True, False, "deprecated"]} - - default_options = {"shared": False, - "fPIC": True, - "use_quaternions": False, - "pose3_expmap": False, - "rot3_expmap": False, - "enable_consistency_checks": 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, - "install_geographiclib": "deprecated"} + options = { + "shared": [True, False], + "fPIC": [True, False], + "use_quaternions": [True, False], + "pose3_expmap": [True, False], + "rot3_expmap": [True, False], + "enable_consistency_checks": [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, + "pose3_expmap": False, + "rot3_expmap": False, + "enable_consistency_checks": 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, + } generators = "cmake", "cmake_find_package" - exports_sources = ["CMakeLists.txt", "patches/*"] - _source_subfolder = "source_subfolder" - _build_subfolder = "build_subfolder" _cmake = None - def _configure_cmake(self): - if not self._cmake: - self._cmake = CMake(self) - self._cmake.definitions["BUILD_SHARED_LIBS"] = self.options.shared - self._cmake.definitions["GTSAM_USE_QUATERNIONS"] = self.options.use_quaternions - self._cmake.definitions["GTSAM_POSE3_EXPMAP"] = self.options.pose3_expmap - self._cmake.definitions["GTSAM_ROT3_EXPMAP"] = self.options.rot3_expmap - self._cmake.definitions["GTSAM_ENABLE_CONSISTENCY_CHECKS"] = self.options.enable_consistency_checks - self._cmake.definitions["GTSAM_WITH_TBB"] = self.options.with_TBB - self._cmake.definitions["GTSAM_WITH_EIGEN_MKL"] = self.options.with_eigen_MKL - self._cmake.definitions["GTSAM_WITH_EIGEN_MKL_OPENMP"] = self.options.with_eigen_MKL_OPENMP - self._cmake.definitions["GTSAM_THROW_CHEIRALITY_EXCEPTION"] = self.options.throw_cheirality_exception - self._cmake.definitions["GTSAM_ALLOW_DEPRECATED_SINCE_V4"] = self.options.allow_deprecated_since_V4 - self._cmake.definitions["GTSAM_TYPEDEF_POINTS_TO_VECTORS"] = self.options.typedef_points_to_vectors - self._cmake.definitions["GTSAM_SUPPORT_NESTED_DISSECTION"] = self.options.support_nested_dissection - self._cmake.definitions["GTSAM_TANGENT_PREINTEGRATION"] = self.options.tangent_preintegration - self._cmake.definitions["GTSAM_BUILD_UNSTABLE"] = self.options.build_unstable - self._cmake.definitions["GTSAM_DISABLE_NEW_TIMERS"] = self.options.disable_new_timers - self._cmake.definitions["GTSAM_BUILD_TYPE_POSTFIXES"] = self.options.build_type_postfixes - self._cmake.definitions["GTSAM_BUILD_TESTS"] = False - self._cmake.definitions["Boost_USE_STATIC_LIBS"] = not self.options["boost"].shared - self._cmake.definitions["Boost_NO_SYSTEM_PATHS"] = True - self._cmake.definitions["GTSAM_BUILD_DOCS"] = False - self._cmake.definitions["GTSAM_BUILD_DOC_HTML"] = False - self._cmake.definitions["GTSAM_BUILD_EXAMPLES_ALWAYS"] = False - self._cmake.definitions["GTSAM_BUILD_WRAP"] = self.options.build_wrap - self._cmake.definitions["GTSAM_BUILD_WITH_MARCH_NATIVE"] = False - self._cmake.definitions["GTSAM_WRAP_SERIALIZATION"] = self.options.wrap_serialization - self._cmake.definitions["GTSAM_INSTALL_MATLAB_TOOLBOX"] = self.options.install_matlab_toolbox - self._cmake.definitions["GTSAM_INSTALL_CYTHON_TOOLBOX"] = self.options.install_cython_toolbox - self._cmake.definitions["GTSAM_INSTALL_CPPUNITLITE"] = self.options.install_cppunitlite - self._cmake.definitions["GTSAM_INSTALL_GEOGRAPHICLIB"] = False - self._cmake.definitions["GTSAM_USE_SYSTEM_EIGEN"] = True #Set to false to use eigen sources contained in GTSAM - self._cmake.definitions["GTSAM_BUILD_TYPE_POSTFIXES"] = False - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + @property + def _source_subfolder(self): + return "source_subfolder" - def _patch_sources(self): - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) - # compiler.runtime field only exists on Windows therefore we patch it on the recipe - if self.settings.os == "Windows": - tools.replace_in_file(os.path.join(self._source_subfolder, "cmake", "GtsamBuildTypes.cmake"), - "/MD ", - "/{} ".format(self.settings.compiler.runtime)) - tools.replace_in_file(os.path.join(self._source_subfolder, "cmake", "GtsamBuildTypes.cmake"), - "/MDd ", - "/{} ".format(self.settings.compiler.runtime)) + @property + def _build_subfolder(self): + return "build_subfolder" @property - def _required_boost_components(self): - return ["serialization", "system", "filesystem", "thread", "date_time", "regex", "timer", "chrono"] + def _is_msvc(self): + return str(self.settings.compiler) in ["Visual Studio", "msvc"] - def validate(self): - miss_boost_required_comp = any(getattr(self.options["boost"], "without_{}".format(boost_comp), True) for boost_comp in self._required_boost_components) - if self.options["boost"].header_only or miss_boost_required_comp: - raise ConanInvalidConfiguration("{0} requires non header-only boost with these components: {1}".format(self.name, ", ".join(self._required_boost_components))) + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): - if self.settings.os == "Windows": - if self.settings.compiler == "Visual Studio" and tools.Version(self.settings.compiler.version) < 15: - raise ConanInvalidConfiguration ("GTSAM requires MSVC >= 15") - if self.options.install_geographiclib != "deprecated": - self.output.warn("install_geographiclib option is deprecated (GTSAM doesn't use geographiclib). If you want it add is a requirement in your project") + if self.options.shared: + del self.options.fPIC + if self.options.with_TBB: + self.options["onetbb"].tbbmalloc = True def requirements(self): - self.requires("boost/1.75.0") - self.requires("eigen/3.3.9") + self.requires("boost/1.78.0") + self.requires("eigen/3.4.0") if self.options.with_TBB: - self.requires("tbb/2020.3") - self.options["tbb"].tbbmalloc = True + self.requires("onetbb/2020.3") + + @property + def _required_boost_components(self): + return ["serialization", "system", "filesystem", "thread", "date_time", "regex", "timer", "chrono"] + + def validate(self): + miss_boost_required_comp = any(getattr(self.options["boost"], "without_{}".format(boost_comp), True) for boost_comp in self._required_boost_components) + if self.options["boost"].header_only or miss_boost_required_comp: + raise ConanInvalidConfiguration( + "{0} requires non header-only boost with these components: {1}".format( + self.name, ", ".join(self._required_boost_components) + ) + ) + + if self.options.with_TBB and not self.options["onetbb"].tbbmalloc: + raise ConanInvalidConfiguration("gtsam with tbb requires onetbb:tbbmalloc=True") + + if self.settings.compiler == "Visual Studio" and tools.Version(self.settings.compiler.version) < 15: + raise ConanInvalidConfiguration ("GTSAM requires MSVC >= 15") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_dir = self.name + "-" + self.version - os.rename(extracted_dir, self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _patch_sources(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + if self._is_msvc: + tools.replace_in_file(os.path.join(self._source_subfolder, "cmake", "GtsamBuildTypes.cmake"), + "/MD ", + "/{} ".format(msvc_runtime_flag(self))) + tools.replace_in_file(os.path.join(self._source_subfolder, "cmake", "GtsamBuildTypes.cmake"), + "/MDd ", + "/{} ".format(msvc_runtime_flag(self))) + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + self._cmake.definitions["BUILD_SHARED_LIBS"] = self.options.shared + self._cmake.definitions["GTSAM_USE_QUATERNIONS"] = self.options.use_quaternions + self._cmake.definitions["GTSAM_POSE3_EXPMAP"] = self.options.pose3_expmap + self._cmake.definitions["GTSAM_ROT3_EXPMAP"] = self.options.rot3_expmap + self._cmake.definitions["GTSAM_ENABLE_CONSISTENCY_CHECKS"] = self.options.enable_consistency_checks + self._cmake.definitions["GTSAM_WITH_TBB"] = self.options.with_TBB + self._cmake.definitions["GTSAM_WITH_EIGEN_MKL"] = self.options.with_eigen_MKL + self._cmake.definitions["GTSAM_WITH_EIGEN_MKL_OPENMP"] = self.options.with_eigen_MKL_OPENMP + self._cmake.definitions["GTSAM_THROW_CHEIRALITY_EXCEPTION"] = self.options.throw_cheirality_exception + self._cmake.definitions["GTSAM_ALLOW_DEPRECATED_SINCE_V4"] = self.options.allow_deprecated_since_V4 + self._cmake.definitions["GTSAM_TYPEDEF_POINTS_TO_VECTORS"] = self.options.typedef_points_to_vectors + self._cmake.definitions["GTSAM_SUPPORT_NESTED_DISSECTION"] = self.options.support_nested_dissection + self._cmake.definitions["GTSAM_TANGENT_PREINTEGRATION"] = self.options.tangent_preintegration + self._cmake.definitions["GTSAM_BUILD_UNSTABLE"] = self.options.build_unstable + self._cmake.definitions["GTSAM_DISABLE_NEW_TIMERS"] = self.options.disable_new_timers + self._cmake.definitions["GTSAM_BUILD_TYPE_POSTFIXES"] = self.options.build_type_postfixes + self._cmake.definitions["GTSAM_BUILD_TESTS"] = False + self._cmake.definitions["Boost_USE_STATIC_LIBS"] = not self.options["boost"].shared + self._cmake.definitions["Boost_NO_SYSTEM_PATHS"] = True + self._cmake.definitions["GTSAM_BUILD_DOCS"] = False + self._cmake.definitions["GTSAM_BUILD_DOC_HTML"] = False + self._cmake.definitions["GTSAM_BUILD_EXAMPLES_ALWAYS"] = False + self._cmake.definitions["GTSAM_BUILD_WRAP"] = self.options.build_wrap + self._cmake.definitions["GTSAM_BUILD_WITH_MARCH_NATIVE"] = False + self._cmake.definitions["GTSAM_WRAP_SERIALIZATION"] = self.options.wrap_serialization + self._cmake.definitions["GTSAM_INSTALL_MATLAB_TOOLBOX"] = self.options.install_matlab_toolbox + self._cmake.definitions["GTSAM_INSTALL_CYTHON_TOOLBOX"] = self.options.install_cython_toolbox + self._cmake.definitions["GTSAM_INSTALL_CPPUNITLITE"] = self.options.install_cppunitlite + self._cmake.definitions["GTSAM_INSTALL_GEOGRAPHICLIB"] = False + self._cmake.definitions["GTSAM_USE_SYSTEM_EIGEN"] = True #Set to false to use eigen sources contained in GTSAM + self._cmake.definitions["GTSAM_BUILD_TYPE_POSTFIXES"] = False + self._cmake.configure(build_folder=self._build_subfolder) + return self._cmake def build(self): self._patch_sources() @@ -163,40 +187,83 @@ def package(self): tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) tools.rmdir(os.path.join(self.package_folder, "CMake")) - def package_id(self): - del self.info.options.install_geographiclib + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_file_rel_path), + { + "gtsam": "GTSAM::gtsam", + "gtsam_unstable": "GTSAM::gtsam_unstable", + "metis-gtsam": "GTSAM::metis-gtsam", + "CppUnitLite": "GTSAM::CppUnitLite", + } + ) + + @staticmethod + def _create_cmake_module_alias_targets(module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent("""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """.format(alias=alias, aliased=aliased)) + tools.save(module_file, content) + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", "conan-official-{}-targets.cmake".format(self.name)) def package_info(self): - # FIXME: official imported targets are not namespaced - self.cpp_info.names["cmake_find_package"] = "GTSAM" - self.cpp_info.names["cmake_find_package_multi"] = "GTSAM" + self.cpp_info.set_property("cmake_file_name", "GTSAM") - self.cpp_info.components["libgtsam"].libs = ["libgtsam" if self.settings.os == "Windows" and not self.options.shared else "gtsam"] - self.cpp_info.components["libgtsam"].names["cmake_find_package"] = "gtsam" - self.cpp_info.components["libgtsam"].names["cmake_find_package_multi"] = "gtsam" + prefix = "lib" if self._is_msvc and not self.options.shared else "" + + self.cpp_info.components["libgtsam"].set_property("cmake_target_name", "gtsam") + self.cpp_info.components["libgtsam"].libs = ["{}gtsam".format(prefix)] self.cpp_info.components["libgtsam"].requires = ["boost::{}".format(component) for component in self._required_boost_components] self.cpp_info.components["libgtsam"].requires.append("eigen::eigen") if self.options.with_TBB: - self.cpp_info.components["libgtsam"].requires.append("tbb::tbb") + self.cpp_info.components["libgtsam"].requires.append("onetbb::onetbb") if self.options.support_nested_dissection: self.cpp_info.components["libgtsam"].requires.append("libmetis-gtsam") if self.settings.os == "Windows" and tools.Version(self.version) >= "4.0.3": self.cpp_info.components["libgtsam"].system_libs = ["dbghelp"] if self.options.build_unstable: - self.cpp_info.components["libgtsam_unstable"].libs = ["libgtsam_unstable" if self.settings.os == "Windows" and not self.options.shared else "gtsam_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"].set_property("cmake_target_name", "gtsam_unstable") + self.cpp_info.components["libgtsam_unstable"].libs = ["{}gtsam_unstable".format(prefix)] self.cpp_info.components["libgtsam_unstable"].requires = ["libgtsam"] if self.options.support_nested_dissection: - self.cpp_info.components["libmetis-gtsam"].libs = ["libmetis-gtsam" if self.settings.os == "Windows" and not self.options.shared else "metis-gtsam"] - 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"].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" 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"] + + # 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"].requires = ["boost::boost"] + 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] diff --git a/recipes/gtsam/all/patches/conan-4.0.2.patch b/recipes/gtsam/all/patches/0001-conan-4.0.2.patch similarity index 100% rename from recipes/gtsam/all/patches/conan-4.0.2.patch rename to recipes/gtsam/all/patches/0001-conan-4.0.2.patch diff --git a/recipes/gtsam/all/patches/conan-4.0.3.patch b/recipes/gtsam/all/patches/0001-conan-4.0.3.patch similarity index 100% rename from recipes/gtsam/all/patches/conan-4.0.3.patch rename to recipes/gtsam/all/patches/0001-conan-4.0.3.patch diff --git a/recipes/gtsam/all/patches/0002-macos-rpath-4.0.2.patch b/recipes/gtsam/all/patches/0002-macos-rpath-4.0.2.patch new file mode 100644 index 0000000000000..6bc74d30d7ff1 --- /dev/null +++ b/recipes/gtsam/all/patches/0002-macos-rpath-4.0.2.patch @@ -0,0 +1,34 @@ +--- 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/0002-macos-rpath-4.0.3.patch b/recipes/gtsam/all/patches/0002-macos-rpath-4.0.3.patch new file mode 100644 index 0000000000000..c172edcd2dcc4 --- /dev/null +++ b/recipes/gtsam/all/patches/0002-macos-rpath-4.0.3.patch @@ -0,0 +1,30 @@ +--- 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 +@@ -347,7 +346,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 +@@ -16,9 +16,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/test_package/CMakeLists.txt b/recipes/gtsam/all/test_package/CMakeLists.txt index ea7da7360a676..bac6d84e2319d 100644 --- a/recipes/gtsam/all/test_package/CMakeLists.txt +++ b/recipes/gtsam/all/test_package/CMakeLists.txt @@ -1,11 +1,11 @@ -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.1) project(test_package) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) -add_executable(${PROJECT_NAME} test_package.cpp) +find_package(GTSAM REQUIRED CONFIG) -find_package(GTSAM REQUIRED) -target_link_libraries(${PROJECT_NAME} GTSAM::gtsam) +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} gtsam) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) diff --git a/recipes/gtsam/all/test_package/conanfile.py b/recipes/gtsam/all/test_package/conanfile.py index 86a9b5e546a07..38f4483872d47 100644 --- a/recipes/gtsam/all/test_package/conanfile.py +++ b/recipes/gtsam/all/test_package/conanfile.py @@ -1,9 +1,10 @@ -import os from conans import ConanFile, CMake, tools +import os + -class gtsamTestConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" def build(self): cmake = CMake(self) @@ -11,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + 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 7d4d713f6cc00..d9e49f7cf409c 100644 --- a/recipes/gtsam/config.yml +++ b/recipes/gtsam/config.yml @@ -1,5 +1,5 @@ versions: - "4.0.2": - folder: all "4.0.3": folder: all + "4.0.2": + folder: all