From ce69234ca35f569cda049347ddc05d2fa2d80377 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Sun, 14 Jan 2024 15:44:08 +0200 Subject: [PATCH 01/16] g2o: new recipe --- recipes/g2o/all/conandata.yml | 9 + recipes/g2o/all/conanfile.py | 265 ++++++++++++++++++ .../all/patches/001-unvendor-freeglut.patch | 44 +++ recipes/g2o/all/test_package/CMakeLists.txt | 8 + recipes/g2o/all/test_package/conanfile.py | 26 ++ recipes/g2o/all/test_package/test_package.cpp | 77 +++++ recipes/g2o/config.yml | 3 + 7 files changed, 432 insertions(+) create mode 100644 recipes/g2o/all/conandata.yml create mode 100644 recipes/g2o/all/conanfile.py create mode 100644 recipes/g2o/all/patches/001-unvendor-freeglut.patch create mode 100644 recipes/g2o/all/test_package/CMakeLists.txt create mode 100644 recipes/g2o/all/test_package/conanfile.py create mode 100644 recipes/g2o/all/test_package/test_package.cpp create mode 100644 recipes/g2o/config.yml diff --git a/recipes/g2o/all/conandata.yml b/recipes/g2o/all/conandata.yml new file mode 100644 index 0000000000000..0c06419d672f6 --- /dev/null +++ b/recipes/g2o/all/conandata.yml @@ -0,0 +1,9 @@ +sources: + "20230806": + url: "https://github.com/RainerKuemmerle/g2o/archive/refs/tags/20230806_git.tar.gz" + sha256: "e717d3b96cc6d00fcbbaf637aae648c9823599e6aa8fcf4546fc9ad4034dcde5" +patches: + "20230806": + - patch_file: "patches/001-unvendor-freeglut.patch" + patch_description: "Replace vendored FreeGLUT with a Conan version" + patch_type: "conan" diff --git a/recipes/g2o/all/conanfile.py b/recipes/g2o/all/conanfile.py new file mode 100644 index 0000000000000..84e71a6078217 --- /dev/null +++ b/recipes/g2o/all/conanfile.py @@ -0,0 +1,265 @@ +import os + +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get, rm, rmdir, save, export_conandata_patches, apply_conandata_patches +from conan.tools.microsoft import is_msvc +from conan.tools.scm import Version + +required_conan_version = ">=1.53.0" + + +class G2oConan(ConanFile): + name = "g2o" + description = "g2o: A General Framework for Graph Optimization" + license = "BSD-2-Clause", "GPL-3.0-or-later", "LGPL-2.1-or-later" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/RainerKuemmerle/g2o" + topics = ("graph-optimization", "slam", "state-estimation", "computer-vision", "robotics") + + package_type = "library" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "build_slam2d_types": [True, False], + "build_slam2d_addon_types": [True, False], + "build_data_types": [True, False], + "build_sclam2d_types": [True, False], + "build_slam3d_types": [True, False], + "build_slam3d_addon_types": [True, False], + "build_sba_types": [True, False], + "build_icp_types": [True, False], + "build_sim3_types": [True, False], + "fast_math": [True, False], + "no_implicit_ownership_of_objects": [True, False], + "sse_autodetect": [True, False], + "sse2": [True, False], + "sse3": [True, False], + "sse4_1": [True, False], + "sse4_2": [True, False], + "sse4_a": [True, False], + "with_openmp": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "build_slam2d_types": True, + "build_slam2d_addon_types": True, + "build_data_types": True, + "build_sclam2d_types": True, + "build_slam3d_types": True, + "build_slam3d_addon_types": True, + "build_sba_types": True, + "build_icp_types": True, + "build_sim3_types": True, + "fast_math": False, + "no_implicit_ownership_of_objects": False, + "sse_autodetect": False, + # All SSE extensions except for SSE4a (34%) have a 99%+ adoption rate + # as of 2024-01 in https://store.steampowered.com/hwsurvey + "sse2": True, + "sse3": True, + "sse4_1": True, + "sse4_2": True, + "sse4_a": False, + "with_openmp": False, + } + + @property + def _min_cppstd(self): + return 17 + + @property + def _compilers_minimum_version(self): + return { + "Visual Studio": "16", + "msvc": "192", + "gcc": "8", + "clang": "7", + "apple-clang": "12", + } + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + + def layout(self): + cmake_layout(self, src_folder="src") + + def package_id(self): + if self.info.options.sse_autodetect: + del self.info.options.sse2 + del self.info.options.sse3 + del self.info.options.sse4_1 + del self.info.options.sse4_2 + del self.info.options.sse4_a + if not self.info.options.build_slam2d_types: + del self.info.options.build_slam2d_addon_types + del self.info.options.build_sclam2d_types + del self.info.options.build_data_types + if not self.info.options.build_slam3d_types: + del self.info.options.build_slam3d_addon_types + del self.info.options.build_sba_types + del self.info.options.build_icp_types + del self.info.options.build_sim3_types + + def requirements(self): + # Used in public core/eigen_types.h + self.requires("eigen/3.4.0", transitive_headers=True, transitive_libs=True) + # Used in stuff/logger.h + self.requires("spdlog/1.13.0", transitive_headers=True, transitive_libs=True) + # Used in stuff/opengl_wrapper.h + self.requires("opengl/system", transitive_headers=True, transitive_libs=True) + self.requires("glu/system", transitive_headers=True, transitive_libs=True) + if self.options.build_slam2d_types and self.options.build_data_types: + self.requires("freeglut/3.4.0") + if self.options.with_openmp and self.settings.compiler in ["clang", "apple-clang"]: + # Used in core/openmp_mutex.h, also '#pragma omp' is used in several core public headers + self.requires("llvm-openmp/17.0.6", transitive_headers=True, transitive_libs=True) + + # TODO: optional dependencies + # self.requires("suitesparse/x.y.z") + # self.requires("csparse/x.y.z") + # self.requires("qt/5.15.12") + # self.requires("libqglviewer/x.y.z") + + def validate(self): + if self.settings.compiler.cppstd: + check_min_cppstd(self, self._min_cppstd) + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if minimum_version and Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support." + ) + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["G2O_BUILD_EXAMPLES"] = False + tc.variables["G2O_BUILD_APPS"] = False + tc.variables["G2O_USE_OPENMP"] = self.options.with_openmp + tc.variables["G2O_USE_CHOLMOD"] = False # not available in CCI yet + tc.variables["G2O_USE_CSPARSE"] = False # not available in CCI yet + tc.variables["G2O_USE_OPENGL"] = True + tc.variables["G2O_USE_LOGGING"] = True + tc.variables["G2O_BUILD_SLAM2D_TYPES"] = self.options.build_slam2d_types + tc.variables["G2O_BUILD_SLAM2D_ADDON_TYPES"] = self.options.build_slam2d_addon_types + tc.variables["G2O_BUILD_DATA_TYPES"] = self.options.build_data_types + tc.variables["G2O_BUILD_SCLAM2D_TYPES"] = self.options.build_sclam2d_types + tc.variables["G2O_BUILD_SLAM3D_TYPES"] = self.options.build_slam3d_types + tc.variables["G2O_BUILD_SLAM3D_ADDON_TYPES"] = self.options.build_slam3d_addon_types + tc.variables["G2O_BUILD_SBA_TYPES"] = self.options.build_sba_types + tc.variables["G2O_BUILD_ICP_TYPES"] = self.options.build_icp_types + tc.variables["G2O_BUILD_SIM3_TYPES"] = self.options.build_sim3_types + tc.variables["G2O_FAST_MATH"] = self.options.fast_math + tc.variables["G2O_NO_IMPLICIT_OWNERSHIP_OF_OBJECTS"] = self.options.no_implicit_ownership_of_objects + tc.variables["DO_SSE_AUTODETECT"] = self.options.sse_autodetect + tc.variables["DISABLE_SSE2"] = not self.options.sse2 + tc.variables["DISABLE_SSE3"] = not self.options.sse3 + tc.variables["DISABLE_SSE4_1"] = not self.options.sse4_1 + tc.variables["DISABLE_SSE4_2"] = not self.options.sse4_2 + tc.variables["DISABLE_SSE4_A"] = not self.options.sse4_a + tc.generate() + + deps = CMakeDeps(self) + deps.set_property("freeglut", "cmake_target_name", "FreeGLUT::freeglut") + deps.generate() + + def _patch_sources(self): + apply_conandata_patches(self) + save(self, os.path.join(self.source_folder, "g2o", "EXTERNAL", "CMakeLists.txt"), "") + + def build(self): + self._patch_sources() + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "license-*.txt", os.path.join(self.source_folder, "doc"), os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rm(self, "*.pdb", self.package_folder, recursive=True) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "g2o") + # The project does not export an official aggregate target + self.cpp_info.set_property("cmake_target_name", "g2o::g2o") + + def _add_component(name, requires=None): + self.cpp_info.components[name].set_property("cmake_target_name", f"g2o::{name}") + self.cpp_info.components[name].libs = [f"g2o_{name}"] + self.cpp_info.components[name].requires = requires or [] + + # Core libraries + self.cpp_info.components["g2o_ceres_ad"].set_property("cmake_target_name", "g2o::g2o_ceres_ad") + _add_component("stuff", requires=["spdlog::spdlog", "eigen::eigen"]) + _add_component("core", requires=["stuff", "eigen::eigen", "g2o_ceres_ad"]) + _add_component("opengl_helper", requires=["opengl::opengl", "glu::glu", "eigen::eigen"]) + + # Solvers + _add_component("solver_dense", requires=["core"]) + _add_component("solver_eigen", requires=["core"]) + _add_component("solver_pcg", requires=["core"]) + _add_component("solver_structure_only", requires=["core"]) + if self.options.build_slam2d_types: + _add_component("solver_slam2d_linear", requires=["core", "solver_eigen", "types_slam2d"]) + if self.options.get_safe("with_suitesparse"): + _add_component("solver_cholmod", requires=["core", "SuiteSparse::CHOLMOD"]) + if self.options.get_safe("with_csparse"): + _add_component("csparse_extension", requires=["stuff", "csparse::csparse", "eigen::eigen"]) + _add_component("solver_csparse", requires=["core", "csparse_extension"]) + + # Types + if self.options.build_slam2d_types: + _add_component("types_slam2d", requires=["core", "opengl_helper"]) + if self.options.build_slam2d_addon_types: + _add_component("types_slam2d_addons", requires=["core", "types_slam2d", "opengl_helper"]) + if self.options.build_sclam2d_types: + _add_component("types_sclam2d", requires=["core", "opengl_helper", "types_slam2d"]) + if self.options.build_data_types: + _add_component("types_data", requires=["core", "types_slam2d", "opengl_helper", "freeglut::freeglut"]) + if self.options.build_slam3d_types: + _add_component("types_slam3d", requires=["core", "opengl_helper"]) + if self.options.build_slam3d_addon_types: + _add_component("types_slam3d_addons", requires=["core", "types_slam3d", "opengl_helper"]) + if self.options.build_sba_types: + _add_component("types_sba", requires=["core", "types_slam3d"]) + if self.options.build_icp_types: + _add_component("types_icp", requires=["core", "types_sba", "types_slam3d"]) + if self.options.build_sim3_types: + _add_component("types_sim3", requires=["core", "types_sba"]) + + if self.options.with_openmp: + openmp_flags = [] + if self.settings.compiler in ["clang", "apple-clang"]: + self.cpp_info.components["core"].requires.append("llvm-openmp::llvm-openmp") + openmp_flags = ["-Xpreprocessor", "-fopenmp"] + elif self.settings.compiler == "gcc": + openmp_flags = ["-fopenmp"] + elif self.settings.compiler == "intel-cc": + openmp_flags = ["/Qopenmp"] if self.settings.os == "Windows" else ["-Qopenmp"] + elif is_msvc(self): + openmp_flags = ["-openmp"] + # '#pragma omp parallel for' is used in multiple public headers in core + self.cpp_info.components["core"].cxxflags = openmp_flags + self.cpp_info.components["core"].sharedlinkflags = openmp_flags + self.cpp_info.components["core"].exelinkflags = openmp_flags + + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["stuff"].system_libs.append("m") + self.cpp_info.components["stuff"].system_libs.append("rt") diff --git a/recipes/g2o/all/patches/001-unvendor-freeglut.patch b/recipes/g2o/all/patches/001-unvendor-freeglut.patch new file mode 100644 index 0000000000000..8c3616e803462 --- /dev/null +++ b/recipes/g2o/all/patches/001-unvendor-freeglut.patch @@ -0,0 +1,44 @@ +--- g2o/types/data/CMakeLists.txt ++++ g2o/types/data/CMakeLists.txt +@@ -22,7 +22,8 @@ + target_compile_features(types_data PUBLIC cxx_std_17) + target_link_libraries(types_data core types_slam2d) + if(G2O_HAVE_OPENGL) ++ find_package(FreeGLUT REQUIRED CONFIG) +- target_link_libraries(types_data freeglut_minimal opengl_helper) ++ target_link_libraries(types_data FreeGLUT::freeglut opengl_helper) + endif() + + target_include_directories(types_data PUBLIC +--- g2o/types/data/vertex_ellipse.cpp ++++ g2o/types/data/vertex_ellipse.cpp +@@ -30,7 +30,7 @@ + #include "g2o/stuff/misc.h" + + #ifdef G2O_HAVE_OPENGL +-#include "g2o/EXTERNAL/freeglut/freeglut_minimal.h" ++#include + #include "g2o/stuff/opengl_primitives.h" + #include "g2o/stuff/opengl_wrapper.h" + #endif +--- g2o/types/data/vertex_tag.cpp ++++ g2o/types/data/vertex_tag.cpp +@@ -29,7 +29,7 @@ + #include "g2o/stuff/macros.h" + + #ifdef G2O_HAVE_OPENGL +-#include "g2o/EXTERNAL/freeglut/freeglut_minimal.h" ++#include + #include "g2o/stuff/opengl_primitives.h" + #include "g2o/stuff/opengl_wrapper.h" + #endif +@@ -99,8 +99,7 @@ + opengl::drawBox(0.1f * textSize, 0.1f * textSize, 0.1f * textSize); + glTranslatef(0.2f * textSize, 0.f, 0.f); + glScalef(0.003f * textSize, 0.003f * textSize, 1.f); +- freeglut_minimal::glutStrokeString(freeglut_minimal::GLUT_STROKE_ROMAN, +- that->name().c_str()); ++ glutStrokeString(GLUT_STROKE_ROMAN, (const unsigned char*)that->name().c_str()); + glPopMatrix(); + return this; + } diff --git a/recipes/g2o/all/test_package/CMakeLists.txt b/recipes/g2o/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..f65755d0fb1b4 --- /dev/null +++ b/recipes/g2o/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package LANGUAGES CXX) + +find_package(g2o REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE g2o::g2o) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) diff --git a/recipes/g2o/all/test_package/conanfile.py b/recipes/g2o/all/test_package/conanfile.py new file mode 100644 index 0000000000000..ef5d7042163ec --- /dev/null +++ b/recipes/g2o/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindir, "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/g2o/all/test_package/test_package.cpp b/recipes/g2o/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..fcde4ee7c7e9e --- /dev/null +++ b/recipes/g2o/all/test_package/test_package.cpp @@ -0,0 +1,77 @@ +// Based on https://github.com/RainerKuemmerle/g2o/blob/20230806_git/unit_test/slam3d/optimization_slam3d.cpp + +// g2o - General Graph Optimization +// Copyright (C) 2011 R. Kuemmerle, G. Grisetti, W. Burgard +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include "g2o/core/block_solver.h" +#include "g2o/core/optimization_algorithm_gauss_newton.h" +#include "g2o/solvers/eigen/linear_solver_eigen.h" +#include "g2o/types/slam3d/edge_se3.h" + +#include + +using namespace g2o; + +using SlamLinearSolver = g2o::LinearSolverEigen; + +int main() { + g2o::SparseOptimizer optimizer; + auto linearSolver = std::make_unique(); + linearSolver->setBlockOrdering(false); + auto blockSolver = std::make_unique(std::move(linearSolver)); + auto* algorithm = new OptimizationAlgorithmGaussNewton(std::move(blockSolver)); + + optimizer.setAlgorithm(algorithm); + + g2o::VertexSE3* v = new g2o::VertexSE3(); + v->setId(0); + v->setEstimate(g2o::Isometry3::Identity()); + v->setFixed(true); + optimizer.addVertex(v); + + v = new g2o::VertexSE3(); + v->setId(1); + // move vertex away from origin + g2o::Isometry3 p2 = g2o::Isometry3::Identity(); + p2.translation() << 10., 10., 10.; + v->setEstimate(p2); + v->setFixed(false); + optimizer.addVertex(v); + + g2o::EdgeSE3* e = new g2o::EdgeSE3(); + e->setInformation(g2o::EdgeSE3::InformationType::Identity()); + e->setMeasurement(g2o::Isometry3::Identity()); + e->vertices()[0] = optimizer.vertex(0); + e->vertices()[1] = optimizer.vertex(1); + optimizer.addEdge(e); + + optimizer.initializeOptimization(); + optimizer.computeActiveErrors(); + + std::cout << "Chi2 before optimization: " << optimizer.chi2() << std::endl; + int numOptimization = optimizer.optimize(100); + std::cout << "Chi2 after optimization: " << optimizer.chi2() << std::endl; +} diff --git a/recipes/g2o/config.yml b/recipes/g2o/config.yml new file mode 100644 index 0000000000000..e8cbb30093632 --- /dev/null +++ b/recipes/g2o/config.yml @@ -0,0 +1,3 @@ +versions: + "20230806": + folder: all From 88dd3acbf8b7c5d70e88ad32e82e31f50d4828ac Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Mon, 15 Jan 2024 13:32:58 +0200 Subject: [PATCH 02/16] g2o: disable shared Windows builds --- recipes/g2o/all/conanfile.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/recipes/g2o/all/conanfile.py b/recipes/g2o/all/conanfile.py index 84e71a6078217..790340b580c27 100644 --- a/recipes/g2o/all/conanfile.py +++ b/recipes/g2o/all/conanfile.py @@ -142,6 +142,10 @@ def validate(self): f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support." ) + if self.settings.os == "Windows" and self.options.shared: + # Build fails with "unresolved external symbol "public: __cdecl g2o::internal::LoggerInterface::LoggerInterface(void)" + raise ConanInvalidConfiguration("g2o does not currently support shared libraries on Windows") + def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) From ea4da53540ecd38f238f689c943c19ea5c32546d Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Mon, 29 Apr 2024 18:08:00 +0300 Subject: [PATCH 03/16] g2o: add support for CHOLMOD and CSparse --- recipes/g2o/all/conanfile.py | 54 +++++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 16 deletions(-) diff --git a/recipes/g2o/all/conanfile.py b/recipes/g2o/all/conanfile.py index 790340b580c27..84901225499e1 100644 --- a/recipes/g2o/all/conanfile.py +++ b/recipes/g2o/all/conanfile.py @@ -4,7 +4,7 @@ from conan.errors import ConanInvalidConfiguration from conan.tools.build import check_min_cppstd from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout -from conan.tools.files import copy, get, rm, rmdir, save, export_conandata_patches, apply_conandata_patches +from conan.tools.files import copy, get, rm, rmdir, save, export_conandata_patches, apply_conandata_patches, replace_in_file from conan.tools.microsoft import is_msvc from conan.tools.scm import Version @@ -42,6 +42,8 @@ class G2oConan(ConanFile): "sse4_2": [True, False], "sse4_a": [True, False], "with_openmp": [True, False], + "with_cholmod": [True, False], + "with_csparse": [True, False], } default_options = { "shared": False, @@ -66,6 +68,8 @@ class G2oConan(ConanFile): "sse4_2": True, "sse4_a": False, "with_openmp": False, + "with_cholmod": False, + "with_csparse": False, } @property @@ -120,16 +124,16 @@ def requirements(self): self.requires("spdlog/1.13.0", transitive_headers=True, transitive_libs=True) # Used in stuff/opengl_wrapper.h self.requires("opengl/system", transitive_headers=True, transitive_libs=True) - self.requires("glu/system", transitive_headers=True, transitive_libs=True) - if self.options.build_slam2d_types and self.options.build_data_types: - self.requires("freeglut/3.4.0") + self.requires("freeglut/3.4.0", transitive_headers=True, transitive_libs=True) if self.options.with_openmp and self.settings.compiler in ["clang", "apple-clang"]: # Used in core/openmp_mutex.h, also '#pragma omp' is used in several core public headers self.requires("llvm-openmp/17.0.6", transitive_headers=True, transitive_libs=True) + if self.options.with_cholmod: + self.requires("suitesparse-cholmod/5.2.1") + if self.options.with_csparse: + self.requires("suitesparse-cxsparse/4.4.0") # TODO: optional dependencies - # self.requires("suitesparse/x.y.z") - # self.requires("csparse/x.y.z") # self.requires("qt/5.15.12") # self.requires("libqglviewer/x.y.z") @@ -154,8 +158,8 @@ def generate(self): tc.variables["G2O_BUILD_EXAMPLES"] = False tc.variables["G2O_BUILD_APPS"] = False tc.variables["G2O_USE_OPENMP"] = self.options.with_openmp - tc.variables["G2O_USE_CHOLMOD"] = False # not available in CCI yet - tc.variables["G2O_USE_CSPARSE"] = False # not available in CCI yet + tc.variables["G2O_USE_CHOLMOD"] = self.options.with_cholmod + tc.variables["G2O_USE_CSPARSE"] = self.options.with_csparse tc.variables["G2O_USE_OPENGL"] = True tc.variables["G2O_USE_LOGGING"] = True tc.variables["G2O_BUILD_SLAM2D_TYPES"] = self.options.build_slam2d_types @@ -175,15 +179,31 @@ def generate(self): tc.variables["DISABLE_SSE4_1"] = not self.options.sse4_1 tc.variables["DISABLE_SSE4_2"] = not self.options.sse4_2 tc.variables["DISABLE_SSE4_A"] = not self.options.sse4_a + + if self.options.with_cholmod: + tc.variables["CMAKE_FIND_LIBRARY_PREFIXES"] = ";".join([ + dep.package_folder.replace("\\", "/") + for dep_name, dep in self.dependencies.items() if dep_name.ref.name.startswith("suitesparse-") + ]) + # Newest CHOLMOD uses vendored METIS with renamed symbols, which FindSuiteSparse.cmake fails to detect + tc.variables["SuiteSparse_CHOLMOD_USES_METIS"] = True + tc.generate() deps = CMakeDeps(self) deps.set_property("freeglut", "cmake_target_name", "FreeGLUT::freeglut") + # CXSparse is a compatible extension of CSparse + deps.set_property("suitesparse-cxsparse", "cmake_file_name", "CSPARSE") deps.generate() def _patch_sources(self): apply_conandata_patches(self) save(self, os.path.join(self.source_folder, "g2o", "EXTERNAL", "CMakeLists.txt"), "") + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), + "find_package(CSparse)", "find_package(CSPARSE)") + replace_in_file(self, os.path.join(self.source_folder, "g2o", "solvers", "csparse", "CMakeLists.txt"), + "$", + '"$"') def build(self): self._patch_sources() @@ -200,9 +220,11 @@ def package(self): rm(self, "*.pdb", self.package_folder, recursive=True) def package_info(self): + self.cpp_info.set_property("cmake_find_mode", "both") + # https://github.com/RainerKuemmerle/g2o/blob/20230806_git/cmake_modules/FindG2O.cmake + self.cpp_info.set_property("cmake_module_file_name", "G2O") + # https://github.com/RainerKuemmerle/g2o/blob/20230806_git/CMakeLists.txt#L495 self.cpp_info.set_property("cmake_file_name", "g2o") - # The project does not export an official aggregate target - self.cpp_info.set_property("cmake_target_name", "g2o::g2o") def _add_component(name, requires=None): self.cpp_info.components[name].set_property("cmake_target_name", f"g2o::{name}") @@ -213,7 +235,7 @@ def _add_component(name, requires=None): self.cpp_info.components["g2o_ceres_ad"].set_property("cmake_target_name", "g2o::g2o_ceres_ad") _add_component("stuff", requires=["spdlog::spdlog", "eigen::eigen"]) _add_component("core", requires=["stuff", "eigen::eigen", "g2o_ceres_ad"]) - _add_component("opengl_helper", requires=["opengl::opengl", "glu::glu", "eigen::eigen"]) + _add_component("opengl_helper", requires=["opengl::opengl", "freeglut::freeglut", "eigen::eigen"]) # Solvers _add_component("solver_dense", requires=["core"]) @@ -222,10 +244,10 @@ def _add_component(name, requires=None): _add_component("solver_structure_only", requires=["core"]) if self.options.build_slam2d_types: _add_component("solver_slam2d_linear", requires=["core", "solver_eigen", "types_slam2d"]) - if self.options.get_safe("with_suitesparse"): - _add_component("solver_cholmod", requires=["core", "SuiteSparse::CHOLMOD"]) - if self.options.get_safe("with_csparse"): - _add_component("csparse_extension", requires=["stuff", "csparse::csparse", "eigen::eigen"]) + if self.options.with_cholmod: + _add_component("solver_cholmod", requires=["core", "suitesparse-cholmod::suitesparse-cholmod"]) + if self.options.with_csparse: + _add_component("csparse_extension", requires=["stuff", "suitesparse-cxsparse::suitesparse-cxsparse", "eigen::eigen"]) _add_component("solver_csparse", requires=["core", "csparse_extension"]) # Types @@ -236,7 +258,7 @@ def _add_component(name, requires=None): if self.options.build_sclam2d_types: _add_component("types_sclam2d", requires=["core", "opengl_helper", "types_slam2d"]) if self.options.build_data_types: - _add_component("types_data", requires=["core", "types_slam2d", "opengl_helper", "freeglut::freeglut"]) + _add_component("types_data", requires=["core", "types_slam2d", "opengl_helper"]) if self.options.build_slam3d_types: _add_component("types_slam3d", requires=["core", "opengl_helper"]) if self.options.build_slam3d_addon_types: From f88b2cff153b8f0017b6f9e03710043869414ff5 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Mon, 6 May 2024 13:31:48 +0300 Subject: [PATCH 04/16] g2o: more robust SuiteSparse detection --- recipes/g2o/all/FindSuiteSparse.cmake | 8 ++++++++ recipes/g2o/all/conanfile.py | 10 ++-------- 2 files changed, 10 insertions(+), 8 deletions(-) create mode 100644 recipes/g2o/all/FindSuiteSparse.cmake diff --git a/recipes/g2o/all/FindSuiteSparse.cmake b/recipes/g2o/all/FindSuiteSparse.cmake new file mode 100644 index 0000000000000..a1acea1be9535 --- /dev/null +++ b/recipes/g2o/all/FindSuiteSparse.cmake @@ -0,0 +1,8 @@ +# Simplified replacement for https://github.com/RainerKuemmerle/g2o/blob/master/cmake_modules/FindSuiteSparse.cmake + +if (G2O_USE_CHOLMOD) + find_package(CHOLMOD REQUIRED CONFIG) + add_library(SuiteSparse::Partition ALIAS SuiteSparse::CHOLMOD) + set(SuiteSparse_FOUND TRUE) + set(SuiteSparse_CHOLMOD_FOUND TRUE) +endif() diff --git a/recipes/g2o/all/conanfile.py b/recipes/g2o/all/conanfile.py index 84901225499e1..c7b0628d29b1d 100644 --- a/recipes/g2o/all/conanfile.py +++ b/recipes/g2o/all/conanfile.py @@ -88,6 +88,7 @@ def _compilers_minimum_version(self): def export_sources(self): export_conandata_patches(self) + copy(self, "FindSuiteSparse.cmake", self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": @@ -180,14 +181,6 @@ def generate(self): tc.variables["DISABLE_SSE4_2"] = not self.options.sse4_2 tc.variables["DISABLE_SSE4_A"] = not self.options.sse4_a - if self.options.with_cholmod: - tc.variables["CMAKE_FIND_LIBRARY_PREFIXES"] = ";".join([ - dep.package_folder.replace("\\", "/") - for dep_name, dep in self.dependencies.items() if dep_name.ref.name.startswith("suitesparse-") - ]) - # Newest CHOLMOD uses vendored METIS with renamed symbols, which FindSuiteSparse.cmake fails to detect - tc.variables["SuiteSparse_CHOLMOD_USES_METIS"] = True - tc.generate() deps = CMakeDeps(self) @@ -198,6 +191,7 @@ def generate(self): def _patch_sources(self): apply_conandata_patches(self) + copy(self, "FindSuiteSparse.cmake", self.export_sources_folder, os.path.join(self.source_folder, "cmake_modules")) save(self, os.path.join(self.source_folder, "g2o", "EXTERNAL", "CMakeLists.txt"), "") replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), "find_package(CSparse)", "find_package(CSPARSE)") From deb9dcef3c898d57c85f8c45bb5eff50532a3fc0 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Mon, 6 May 2024 19:27:02 +0300 Subject: [PATCH 05/16] g2o: bump spdlog --- recipes/g2o/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/g2o/all/conanfile.py b/recipes/g2o/all/conanfile.py index c7b0628d29b1d..15a9945d0320d 100644 --- a/recipes/g2o/all/conanfile.py +++ b/recipes/g2o/all/conanfile.py @@ -122,7 +122,7 @@ def requirements(self): # Used in public core/eigen_types.h self.requires("eigen/3.4.0", transitive_headers=True, transitive_libs=True) # Used in stuff/logger.h - self.requires("spdlog/1.13.0", transitive_headers=True, transitive_libs=True) + self.requires("spdlog/1.14.1", transitive_headers=True, transitive_libs=True) # Used in stuff/opengl_wrapper.h self.requires("opengl/system", transitive_headers=True, transitive_libs=True) self.requires("freeglut/3.4.0", transitive_headers=True, transitive_libs=True) From ace757bc17cdc5c7fd9040fb15c7570b294cdbd6 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Mon, 6 May 2024 20:20:33 +0300 Subject: [PATCH 06/16] g2o: fix CSparse support --- recipes/g2o/all/conanfile.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/recipes/g2o/all/conanfile.py b/recipes/g2o/all/conanfile.py index 15a9945d0320d..5dc07cd9925ad 100644 --- a/recipes/g2o/all/conanfile.py +++ b/recipes/g2o/all/conanfile.py @@ -198,6 +198,8 @@ def _patch_sources(self): replace_in_file(self, os.path.join(self.source_folder, "g2o", "solvers", "csparse", "CMakeLists.txt"), "$", '"$"') + replace_in_file(self, os.path.join(self.source_folder, "g2o", "solvers", "csparse", "CMakeLists.txt"), + "${CSPARSE_LIBRARY}", "${CSPARSE_LIBRARIES}") def build(self): self._patch_sources() From 47b54914ed48d07a935c9636b9cf209581ffac57 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Mon, 8 Jul 2024 15:56:58 +0300 Subject: [PATCH 07/16] g2o: update and enable OpenMP --- recipes/g2o/all/conanfile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes/g2o/all/conanfile.py b/recipes/g2o/all/conanfile.py index 5dc07cd9925ad..ef6c617f1a545 100644 --- a/recipes/g2o/all/conanfile.py +++ b/recipes/g2o/all/conanfile.py @@ -67,7 +67,7 @@ class G2oConan(ConanFile): "sse4_1": True, "sse4_2": True, "sse4_a": False, - "with_openmp": False, + "with_openmp": True, "with_cholmod": False, "with_csparse": False, } @@ -128,7 +128,7 @@ def requirements(self): self.requires("freeglut/3.4.0", transitive_headers=True, transitive_libs=True) if self.options.with_openmp and self.settings.compiler in ["clang", "apple-clang"]: # Used in core/openmp_mutex.h, also '#pragma omp' is used in several core public headers - self.requires("llvm-openmp/17.0.6", transitive_headers=True, transitive_libs=True) + self.requires("llvm-openmp/18.1.8", transitive_headers=True, transitive_libs=True) if self.options.with_cholmod: self.requires("suitesparse-cholmod/5.2.1") if self.options.with_csparse: From 3c8078bd76bd4e1251369d9e9220ee95717d5d1c Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Sun, 25 Aug 2024 22:06:59 +0300 Subject: [PATCH 08/16] g2o: fix llvm-openmp incompatibility --- recipes/g2o/all/conandata.yml | 3 +++ .../all/patches/002-use-openmp-target.patch | 20 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 recipes/g2o/all/patches/002-use-openmp-target.patch diff --git a/recipes/g2o/all/conandata.yml b/recipes/g2o/all/conandata.yml index 0c06419d672f6..d3793feffe489 100644 --- a/recipes/g2o/all/conandata.yml +++ b/recipes/g2o/all/conandata.yml @@ -7,3 +7,6 @@ patches: - patch_file: "patches/001-unvendor-freeglut.patch" patch_description: "Replace vendored FreeGLUT with a Conan version" patch_type: "conan" + - patch_file: "patches/002-use-openmp-target.patch" + patch_description: "Require OpenMP if enabled, use a target instead of plain compiler flags" + patch_type: "portability" diff --git a/recipes/g2o/all/patches/002-use-openmp-target.patch b/recipes/g2o/all/patches/002-use-openmp-target.patch new file mode 100644 index 0000000000000..33fb339dff762 --- /dev/null +++ b/recipes/g2o/all/patches/002-use-openmp-target.patch @@ -0,0 +1,20 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -138,13 +138,10 @@ + # OPENMP is experimental. We experienced some slowdown with it + option(G2O_USE_OPENMP "Build g2o with OpenMP support (EXPERIMENTAL)" OFF) + if(G2O_USE_OPENMP) +- find_package(OpenMP) +- if(OPENMP_FOUND) +- set (G2O_OPENMP 1) +- set(g2o_C_FLAGS "${g2o_C_FLAGS} ${OpenMP_C_FLAGS}") +- set(g2o_CXX_FLAGS "${g2o_CXX_FLAGS} -DEIGEN_DONT_PARALLELIZE ${OpenMP_CXX_FLAGS}") +- message(STATUS "Compiling with OpenMP support") +- endif(OPENMP_FOUND) ++ find_package(OpenMP REQUIRED) ++ set(G2O_OPENMP 1) ++ set(g2o_CXX_FLAGS "${g2o_CXX_FLAGS} -DEIGEN_DONT_PARALLELIZE") ++ link_libraries(OpenMP::OpenMP_CXX) + endif(G2O_USE_OPENMP) + + # OpenGL is used in the draw actions for the different types, as well From 3b1e4fc7591712ac7cd97e7c7d299fcc03d25107 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Wed, 28 Aug 2024 12:59:23 +0300 Subject: [PATCH 09/16] Update all SuiteSparse packages --- recipes/g2o/all/conanfile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes/g2o/all/conanfile.py b/recipes/g2o/all/conanfile.py index ef6c617f1a545..8ff62fa7ab73e 100644 --- a/recipes/g2o/all/conanfile.py +++ b/recipes/g2o/all/conanfile.py @@ -130,9 +130,9 @@ def requirements(self): # Used in core/openmp_mutex.h, also '#pragma omp' is used in several core public headers self.requires("llvm-openmp/18.1.8", transitive_headers=True, transitive_libs=True) if self.options.with_cholmod: - self.requires("suitesparse-cholmod/5.2.1") + self.requires("suitesparse-cholmod/5.3.0") if self.options.with_csparse: - self.requires("suitesparse-cxsparse/4.4.0") + self.requires("suitesparse-cxsparse/4.4.1") # TODO: optional dependencies # self.requires("qt/5.15.12") From bef63fe229c116d98fb2ea5940830a1f1768da92 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Wed, 28 Aug 2024 15:52:12 +0300 Subject: [PATCH 10/16] Use a version range for Qt dependencies --- recipes/g2o/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/g2o/all/conanfile.py b/recipes/g2o/all/conanfile.py index 8ff62fa7ab73e..8896d061e5c31 100644 --- a/recipes/g2o/all/conanfile.py +++ b/recipes/g2o/all/conanfile.py @@ -135,7 +135,7 @@ def requirements(self): self.requires("suitesparse-cxsparse/4.4.1") # TODO: optional dependencies - # self.requires("qt/5.15.12") + # self.requires("qt/[~5.15]") # self.requires("libqglviewer/x.y.z") def validate(self): From cf614e064f4f18b8715474b71d42631c4240a167 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Tue, 15 Oct 2024 00:15:31 +0300 Subject: [PATCH 11/16] g2o: C++20 is not compatible --- recipes/g2o/all/conanfile.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/recipes/g2o/all/conanfile.py b/recipes/g2o/all/conanfile.py index 8896d061e5c31..fc24c4bc1d57f 100644 --- a/recipes/g2o/all/conanfile.py +++ b/recipes/g2o/all/conanfile.py @@ -2,7 +2,7 @@ from conan import ConanFile from conan.errors import ConanInvalidConfiguration -from conan.tools.build import check_min_cppstd +from conan.tools.build import check_min_cppstd, check_max_cppstd from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout from conan.tools.files import copy, get, rm, rmdir, save, export_conandata_patches, apply_conandata_patches, replace_in_file from conan.tools.microsoft import is_msvc @@ -76,6 +76,10 @@ class G2oConan(ConanFile): def _min_cppstd(self): return 17 + @property + def _max_cppstd(self): + return 17 + @property def _compilers_minimum_version(self): return { @@ -141,6 +145,9 @@ def requirements(self): def validate(self): if self.settings.compiler.cppstd: check_min_cppstd(self, self._min_cppstd) + # C++20 fails with + # error: call to non-‘constexpr’ function ‘void fmt::v10::detail::throw_format_error(const char*)’ + check_max_cppstd(self, self._max_cppstd) minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) if minimum_version and Version(self.settings.compiler.version) < minimum_version: raise ConanInvalidConfiguration( From 0d32650fbc9a84082b26b136fdae95ed4ebd291d Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Fri, 30 Aug 2024 10:34:26 +0300 Subject: [PATCH 12/16] List only the C component of libtiff under requires --- recipes/gdal/post_3.5.0/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/gdal/post_3.5.0/conanfile.py b/recipes/gdal/post_3.5.0/conanfile.py index 49c2e7d3e5d6e..6512a5cf804aa 100644 --- a/recipes/gdal/post_3.5.0/conanfile.py +++ b/recipes/gdal/post_3.5.0/conanfile.py @@ -680,7 +680,7 @@ def package_info(self): self.cpp_info.requires.extend(["json-c::json-c"]) self.cpp_info.requires.extend(["libgeotiff::libgeotiff"]) - self.cpp_info.requires.extend(["libtiff::libtiff"]) + self.cpp_info.requires.extend(["libtiff::tiff"]) self.cpp_info.requires.extend(["proj::projlib"]) self.cpp_info.requires.extend(["zlib::zlib"]) if self.options.with_armadillo: From e684401bc314ce21370f46d622cad0493bf5a6d1 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Wed, 16 Oct 2024 09:01:50 +0300 Subject: [PATCH 13/16] gdal: use a pre-release of qhull --- recipes/gdal/post_3.5.0/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/gdal/post_3.5.0/conanfile.py b/recipes/gdal/post_3.5.0/conanfile.py index 6512a5cf804aa..d626c0223209b 100644 --- a/recipes/gdal/post_3.5.0/conanfile.py +++ b/recipes/gdal/post_3.5.0/conanfile.py @@ -282,7 +282,7 @@ def requirements(self): if self.options.with_poppler: self.requires("poppler/21.07.0") if self.options.with_qhull: - self.requires("qhull/8.0.1") + self.requires("qhull/cci.20231130") if self.options.with_rasterlite2: self.requires("librasterlite2/1.1.0-beta1") if self.options.with_spatialite: From 0bc8a4a59f76d68583bc70dd26450f0dcd166cf7 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Thu, 17 Oct 2024 23:16:36 +0300 Subject: [PATCH 14/16] Use a version range for sqlite3 to match qt/6.x recipe --- recipes/gdal/post_3.5.0/conanfile.py | 2 +- recipes/gdal/pre_3.5.0/conanfile.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes/gdal/post_3.5.0/conanfile.py b/recipes/gdal/post_3.5.0/conanfile.py index d626c0223209b..7f56b80fb0e9c 100644 --- a/recipes/gdal/post_3.5.0/conanfile.py +++ b/recipes/gdal/post_3.5.0/conanfile.py @@ -288,7 +288,7 @@ def requirements(self): if self.options.with_spatialite: self.requires("libspatialite/5.0.1") if self.options.with_sqlite3: - self.requires("sqlite3/3.44.2") + self.requires("sqlite3/[>=3.45.0 <4]") if self.options.with_tiledb: self.requires("tiledb/2.17.4") if self.options.with_webp: diff --git a/recipes/gdal/pre_3.5.0/conanfile.py b/recipes/gdal/pre_3.5.0/conanfile.py index 0270a1825c5cf..1ad10228df70d 100644 --- a/recipes/gdal/pre_3.5.0/conanfile.py +++ b/recipes/gdal/pre_3.5.0/conanfile.py @@ -284,7 +284,7 @@ def requirements(self): # if self.options.with_spatialite: # self.requires("libspatialite/4.3.0a") if self.options.get_safe("with_sqlite3"): - self.requires("sqlite3/3.44.2") + self.requires("sqlite3/[>=3.45.0 <4]") # if self.options.with_rasterlite2: # self.requires("rasterlite2/x.x.x") if self.options.get_safe("with_pcre"): From c005d993846c9f6f079c3cd2fc6c9c6ebd784990 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Sun, 3 Nov 2024 23:41:09 +0200 Subject: [PATCH 15/16] Use the latest hdf5 for cross-compilation support --- recipes/gdal/post_3.5.0/conanfile.py | 2 +- recipes/gdal/pre_3.5.0/conanfile.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes/gdal/post_3.5.0/conanfile.py b/recipes/gdal/post_3.5.0/conanfile.py index 7f56b80fb0e9c..691086c5797ee 100644 --- a/recipes/gdal/post_3.5.0/conanfile.py +++ b/recipes/gdal/post_3.5.0/conanfile.py @@ -222,7 +222,7 @@ def requirements(self): if self.options.with_hdf4: self.requires("hdf4/4.2.16-2") if self.options.with_hdf5: - self.requires("hdf5/1.14.3") + self.requires("hdf5/1.14.5") if self.options.with_heif: self.requires("libheif/1.16.2") if self.options.with_jpeg == "libjpeg": diff --git a/recipes/gdal/pre_3.5.0/conanfile.py b/recipes/gdal/pre_3.5.0/conanfile.py index 1ad10228df70d..81691007db15a 100644 --- a/recipes/gdal/pre_3.5.0/conanfile.py +++ b/recipes/gdal/pre_3.5.0/conanfile.py @@ -252,7 +252,7 @@ def requirements(self): if self.options.with_hdf4: self.requires("hdf4/4.2.15") if self.options.with_hdf5: - self.requires("hdf5/1.14.0") + self.requires("hdf5/1.14.5") if self.options.with_kea: self.requires("kealib/1.4.14") if self.options.with_netcdf: From b20fbf70e14c86742e344aef19dc5a7e07d0ce22 Mon Sep 17 00:00:00 2001 From: Tom Deblauwe Date: Wed, 20 Nov 2024 09:25:59 +0100 Subject: [PATCH 16/16] add with_opengl option --- recipes/g2o/all/conanfile.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/recipes/g2o/all/conanfile.py b/recipes/g2o/all/conanfile.py index fc24c4bc1d57f..4099f9d068d35 100644 --- a/recipes/g2o/all/conanfile.py +++ b/recipes/g2o/all/conanfile.py @@ -44,6 +44,7 @@ class G2oConan(ConanFile): "with_openmp": [True, False], "with_cholmod": [True, False], "with_csparse": [True, False], + "with_opengl": [True, False], } default_options = { "shared": False, @@ -70,6 +71,7 @@ class G2oConan(ConanFile): "with_openmp": True, "with_cholmod": False, "with_csparse": False, + "with_opengl": True, } @property @@ -127,9 +129,10 @@ def requirements(self): self.requires("eigen/3.4.0", transitive_headers=True, transitive_libs=True) # Used in stuff/logger.h self.requires("spdlog/1.14.1", transitive_headers=True, transitive_libs=True) - # Used in stuff/opengl_wrapper.h - self.requires("opengl/system", transitive_headers=True, transitive_libs=True) - self.requires("freeglut/3.4.0", transitive_headers=True, transitive_libs=True) + if self.options.with_opengl: + # Used in stuff/opengl_wrapper.h + self.requires("opengl/system", transitive_headers=True, transitive_libs=True) + self.requires("freeglut/3.4.0", transitive_headers=True, transitive_libs=True) if self.options.with_openmp and self.settings.compiler in ["clang", "apple-clang"]: # Used in core/openmp_mutex.h, also '#pragma omp' is used in several core public headers self.requires("llvm-openmp/18.1.8", transitive_headers=True, transitive_libs=True) @@ -168,7 +171,7 @@ def generate(self): tc.variables["G2O_USE_OPENMP"] = self.options.with_openmp tc.variables["G2O_USE_CHOLMOD"] = self.options.with_cholmod tc.variables["G2O_USE_CSPARSE"] = self.options.with_csparse - tc.variables["G2O_USE_OPENGL"] = True + tc.variables["G2O_USE_OPENGL"] = self.options.with_opengl tc.variables["G2O_USE_LOGGING"] = True tc.variables["G2O_BUILD_SLAM2D_TYPES"] = self.options.build_slam2d_types tc.variables["G2O_BUILD_SLAM2D_ADDON_TYPES"] = self.options.build_slam2d_addon_types @@ -230,6 +233,8 @@ def package_info(self): self.cpp_info.set_property("cmake_file_name", "g2o") def _add_component(name, requires=None): + if not self.options.with_opengl and "opengl_helper" in requires: + requires.remove("opengl_helper") self.cpp_info.components[name].set_property("cmake_target_name", f"g2o::{name}") self.cpp_info.components[name].libs = [f"g2o_{name}"] self.cpp_info.components[name].requires = requires or [] @@ -238,7 +243,8 @@ def _add_component(name, requires=None): self.cpp_info.components["g2o_ceres_ad"].set_property("cmake_target_name", "g2o::g2o_ceres_ad") _add_component("stuff", requires=["spdlog::spdlog", "eigen::eigen"]) _add_component("core", requires=["stuff", "eigen::eigen", "g2o_ceres_ad"]) - _add_component("opengl_helper", requires=["opengl::opengl", "freeglut::freeglut", "eigen::eigen"]) + if self.options.with_opengl: + _add_component("opengl_helper", requires=["opengl::opengl", "freeglut::freeglut", "eigen::eigen"]) # Solvers _add_component("solver_dense", requires=["core"])