Raise dependency baselines to Ubuntu 24.04 and Abseil 20260817.0 Align minimum dependency versions with Ubuntu 24.04 LTS, with Abseil on the latest 20260817.0 LTS release: - CMake >= 3.28 (up from 3.22), dropping legacy CMake < 3.24 guards in CeresConfig.cmake.in, EnableSanitizer.cmake, FindSuiteSparse.cmake, and internal/ceres/CMakeLists.txt. Sanitize check variable names in EnableSanitizer.cmake so hyphenated sanitizers work reliably. - Eigen >= 3.4.0 (up from 3.3.4), keeping Eigen 5 support. - SuiteSparse >= 7.6.1 (up from 4.5.6), removing CERES_NO_CHOLMOD_FLOAT and WITH_CHOLMOD_FLOAT now that single-precision CHOLMOD is always available, removing legacy SPQR TBB probing, supporting *_static.lib names on MSVC, and detecting CHOLMOD's Partition module via cholmod.h and vendored SuiteSparse_metis without requiring external METIS. - Google Benchmark >= 1.8.3 (up from 1.3). - Abseil 20260817.0 across CMake (enforcing the version floor properly instead of passing the version after REQUIRED), the abseil-cpp submodule, and MODULE.bazel (alongside googletest 1.18.0 to match abseil-cpp's direct dependency). - Guard METIS version string reporting in solver_utils.cc on CERES_METIS_VERSION and emit METIS_DEPENDENCY in CeresConfig.cmake only when external METIS is actually linked. Change-Id: Ic2091a69a6bd7f55965ff5fdd245a02da191a4fc
diff --git a/.gitmodules b/.gitmodules index 61f7064..e539a03 100644 --- a/.gitmodules +++ b/.gitmodules
@@ -5,4 +5,4 @@ [submodule "third_party/abseil-cpp"] path = third_party/abseil-cpp url = https://github.com/abseil/abseil-cpp - branch = lts_2025_01_27 + branch = lts_2026_08_17
diff --git a/CMakeLists.txt b/CMakeLists.txt index e054c11..5ab5de5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt
@@ -29,7 +29,7 @@ # Authors: keir@google.com (Keir Mierle) # alexs.mac@gmail.com (Alex Stewart) -cmake_minimum_required(VERSION 3.22...4.4) +cmake_minimum_required(VERSION 3.28...4.4) # Opt into the experimental software bill of materials (SBOM) generation of # CMake 4.3 and 4.4. CMake enables an experimental feature only if its gate @@ -154,11 +154,10 @@ # Discover dependencies. if (NOT EXISTS "${Ceres_SOURCE_DIR}/third_party/abseil-cpp/CMakeLists.txt") - find_package(absl REQUIRED 20240116) + find_package(absl REQUIRED) endif() find_package(AccelerateSparse) -# Version 1.3 was first to provide import targets. -find_package(benchmark 1.3) +find_package(benchmark 1.8.3) find_package(BLAS) find_package(LAPACK) find_package(CUDAToolkit) @@ -171,12 +170,12 @@ set (_Ceres_Eigen3_DIR "${Eigen3_DIR}") endif (Eigen3_DIR) -find_package(Eigen3 3.3.4...5 NO_MODULE) +find_package(Eigen3 3.4.0...5 NO_MODULE) if (NOT Eigen3_FOUND) if (_Ceres_Eigen3_DIR) set (Eigen3_DIR "${_Ceres_Eigen3_DIR}") endif (_Ceres_Eigen3_DIR) - find_package(Eigen3 3.3.4 REQUIRED NO_MODULE) + find_package(Eigen3 3.4.0 REQUIRED NO_MODULE) endif (NOT Eigen3_FOUND) unset (_Ceres_Eigen3_DIR) @@ -186,8 +185,8 @@ find_package(METIS) find_package(Sphinx COMPONENTS furo) -# Ubuntu 22.04 provides SuiteSparse 5.10.1, which remains supported. -find_package(SuiteSparse 4.5.6 COMPONENTS CHOLMOD SPQR +# Ubuntu 24.04 provides SuiteSparse 7.6.1. +find_package(SuiteSparse 7.6.1 COMPONENTS CHOLMOD SPQR OPTIONAL_COMPONENTS Partition) find_package(Threads REQUIRED) @@ -233,12 +232,6 @@ # Abseil does not handle symbol visibility correctly. As a workaround, we let it # expose all the symbols to avoid linker errors. set(CMAKE_CXX_VISIBILITY_PRESET default) - # ABSL plans to enable this flag to be on by default in the future. If it is not - # set, then it issues a warning. We force enable it, both to silence the warning - # but to also be safe going forward. - - option(ABSL_PROPAGATE_CXX_STD "Use CMake C++ standard meta features - (e.g. cxx_std_14) that propagate to targets that link to Abseil" ON) option(ABSL_ENABLE_INSTALL "Enable install rules" ON) add_subdirectory(third_party/abseil-cpp) @@ -258,8 +251,10 @@ # which case we check for vlog_is_on, which is a feature we need # before being able to use abseil. if (NOT TARGET absl::absl_vlog_is_on) - message(FATAL_ERROR "The version of abseil installed on the system provides no version info and is missing TARGET 'absl::absl_vlog_is_on', need at least 20240116") + message(FATAL_ERROR "The version of abseil installed on the system provides no version info and is missing TARGET 'absl::absl_vlog_is_on', need at least 20260817") endif() + elseif (absl_VERSION VERSION_LESS 20260817) + message(FATAL_ERROR "Found Abseil version ${absl_VERSION}, but Ceres requires Abseil 20260817 or newer.") endif() set(CERES_USE_SYSTEM_ABSL YES) endif() @@ -378,12 +373,6 @@ set(_Ceres_FEATURE_BENCHMARKS ON) endif() -set(WITH_CHOLMOD_FLOAT OFF) -if (_Ceres_FEATURE_SUITESPARSE AND - SuiteSparse_VERSION VERSION_GREATER_EQUAL 7.4.0) - set(WITH_CHOLMOD_FLOAT ON) -endif() - unset(CERES_COMPILE_OPTIONS) if (_Ceres_FEATURE_EIGEN_SPARSE) @@ -462,9 +451,6 @@ # support. set(SuiteSparse_DEPENDENCY "find_dependency(SuiteSparse ${SuiteSparse_VERSION})") - if (NOT WITH_CHOLMOD_FLOAT) - list(APPEND CERES_COMPILE_OPTIONS CERES_NO_CHOLMOD_FLOAT) - endif() if (SuiteSparse_NO_CMAKE OR NOT SuiteSparse_DIR) list(APPEND _Ceres_CONFIG_DEPENDENCY_MODULES ${Ceres_SOURCE_DIR}/cmake/FindSuiteSparse.cmake @@ -478,18 +464,22 @@ list (APPEND CERES_COMPILE_OPTIONS CERES_NO_CHOLMOD_PARTITION) endif() -if (_Ceres_FEATURE_EIGEN_METIS) - # Since METIS is a private dependency of Ceres, it requires access to the - # link-only METIS::METIS target to avoid undefined linker errors in projects - # relying on Ceres. We do not actually need to propagate anything besides - # the link libraries (such as include directories.) - set(METIS_DEPENDENCY "find_dependency(METIS ${METIS_VERSION})") - # METIS find module must be installed unless a package config is being used. - if (NOT METIS_DIR) - list(APPEND _Ceres_CONFIG_DEPENDENCY_MODULES - ${Ceres_SOURCE_DIR}/cmake/FindMETIS.cmake) - endif (NOT METIS_DIR) -else() +if (_Ceres_FEATURE_EIGEN_METIS OR + (_Ceres_FEATURE_CHOLMOD_PARTITION AND + SuiteSparse_CHOLMOD_NEEDS_EXTERNAL_METIS)) + # Since METIS is a private dependency of Ceres, it requires access to the + # link-only METIS::METIS target to avoid undefined linker errors in projects + # relying on Ceres. We do not actually need to propagate anything besides + # the link libraries (such as include directories.) + set(METIS_DEPENDENCY "find_dependency(METIS ${METIS_VERSION})") + # METIS find module must be installed unless a package config is being used. + if (NOT METIS_DIR) + list(APPEND _Ceres_CONFIG_DEPENDENCY_MODULES + ${Ceres_SOURCE_DIR}/cmake/FindMETIS.cmake) + endif (NOT METIS_DIR) +endif () + +if (NOT _Ceres_FEATURE_EIGEN_METIS) list (APPEND CERES_COMPILE_OPTIONS CERES_NO_EIGEN_METIS) endif() @@ -889,8 +879,6 @@ "METIS ordering for Eigen sparse solvers") add_feature_info("CHOLMOD partitioning" _Ceres_FEATURE_CHOLMOD_PARTITION "CHOLMOD graph partitioning") -add_feature_info("CHOLMOD single precision" WITH_CHOLMOD_FLOAT - "Single-precision CHOLMOD factorization") add_feature_info("Use LAPACK" _Ceres_FEATURE_LAPACK "Use LAPACK directly for linear algebra operations") add_feature_info("Custom BLAS" WITH_CUSTOM_BLAS @@ -934,8 +922,6 @@ "Documentation generator" "${Sphinx_VERSION}") ceres_dependency_description(CERES_SUITESPARSE_DESCRIPTION "A suite of sparse matrix algorithms" "${SuiteSparse_VERSION}") -ceres_dependency_description(CERES_TBB_DESCRIPTION - "Threading Building Blocks" "${TBB_VERSION}") set_package_properties(absl PROPERTIES DESCRIPTION "${CERES_ABSL_DESCRIPTION}" @@ -984,9 +970,6 @@ DESCRIPTION "${CERES_SUITESPARSE_DESCRIPTION}" TYPE RECOMMENDED URL "https://github.com/DrTimothyAldenDavis/SuiteSparse") -set_package_properties(TBB PROPERTIES - DESCRIPTION "${CERES_TBB_DESCRIPTION}" - PURPOSE "SuiteSparseQR dependency") set_package_properties(Threads PROPERTIES DESCRIPTION "Native platform threading support" PURPOSE "Multithreading support")
diff --git a/MODULE.bazel b/MODULE.bazel index 4523c36..730c921 100644 --- a/MODULE.bazel +++ b/MODULE.bazel
@@ -2,8 +2,8 @@ module(name = "ceres-solver", version = "head") -bazel_dep(name = "abseil-cpp", version = "20250814.2") -bazel_dep(name = "googletest", version = "1.17.0.bcr.2") +bazel_dep(name = "abseil-cpp", version = "20260817.0") +bazel_dep(name = "googletest", version = "1.18.0") bazel_dep(name = "eigen", version = "3.4.0.bcr.3") bazel_dep(name = "google_benchmark", version = "1.9.5") bazel_dep(name = "rules_cc", version = "0.2.22")
diff --git a/cmake/CeresConfig.cmake.in b/cmake/CeresConfig.cmake.in index cfc866c..34e095a 100644 --- a/cmake/CeresConfig.cmake.in +++ b/cmake/CeresConfig.cmake.in
@@ -114,7 +114,7 @@ # As imported CMake targets are not re-exported when a dependent target is # exported, we must invoke find_package(XXX) here to reload the definition # of their targets. Without this, the dependency target names (e.g. -# 'gflags-shared') which will be present in the ceres target would not be +# 'absl::log') which will be present in the ceres target would not be # defined, and so CMake will assume that they refer to a library name and # fail to link correctly. @@ -230,9 +230,7 @@ add_library(ceres INTERFACE IMPORTED) set_target_properties(ceres PROPERTIES INTERFACE_LINK_LIBRARIES Ceres::ceres) - if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.17) - set_target_properties(ceres PROPERTIES DEPRECATION + set_target_properties(ceres PROPERTIES DEPRECATION "The unscoped import target `ceres' is deprecated and will be removed in a \ future Ceres Solver release. Please use the Ceres::ceres import target instead.") - endif (CMAKE_VERSION VERSION_GREATER_EQUAL 3.17) endif()
diff --git a/cmake/EnableSanitizer.cmake b/cmake/EnableSanitizer.cmake index 8e7031f..081e771 100644 --- a/cmake/EnableSanitizer.cmake +++ b/cmake/EnableSanitizer.cmake
@@ -65,23 +65,19 @@ "exclusive: ${PRETTY_INCOMPATIBLE_SANITIZERS}") endif() - # Until CMake 3.14 and CMAKE_REQUIRED_LINK_OPTIONS there was no equivalent to - # CMAKE_REQUIRED_FLAGS for try_compile() for linker flags. However, in CMake - # 3.2 CMP0056 was introduced that when enabled passes CMAKE_EXE_LINKER_FLAGS - # to try_compile() which allows us to achieve the same effect. - cmake_policy(SET CMP0056 NEW) include(CheckCXXCompilerFlag) + include(CMakePushCheckState) unset(ADDED_SANITIZER) foreach(REQUESTED_SANITIZER ${ARGN}) set(SANITIZER_FLAG -fsanitize=${REQUESTED_SANITIZER}) - # Save the current CMAKE_EXE_LINKER_FLAGS before modifying it to test for - # the existence of the sanitizer flag so that we can revert after the test. - set(INITIAL_CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${SANITIZER_FLAG}") - check_cxx_compiler_flag(${SANITIZER_FLAG} HAVE_SANITIZER) - set(CMAKE_EXE_LINKER_FLAGS "${INITIAL_CMAKE_EXE_LINKER_FLAGS}") - if (NOT HAVE_SANITIZER) + string(MAKE_C_IDENTIFIER "HAVE_SANITIZER_${REQUESTED_SANITIZER}" + SANITIZER_CHECK_VAR) + cmake_push_check_state() + list(APPEND CMAKE_REQUIRED_LINK_OPTIONS ${SANITIZER_FLAG}) + check_cxx_compiler_flag(${SANITIZER_FLAG} ${SANITIZER_CHECK_VAR}) + cmake_pop_check_state() + if (NOT ${SANITIZER_CHECK_VAR}) message(FATAL_ERROR "Specified sanitizer: ${REQUESTED_SANITIZER} is not " "supported by the compiler.") endif()
diff --git a/cmake/FindSuiteSparse.cmake b/cmake/FindSuiteSparse.cmake index 63bb387..ec8f831 100644 --- a/cmake/FindSuiteSparse.cmake +++ b/cmake/FindSuiteSparse.cmake
@@ -35,9 +35,9 @@ Module for locating SuiteSparse libraries and its dependencies. -SuiteSparse 7 and later provide a unified CMake package configuration. This -module retains a component-based fallback for older supported releases such as -SuiteSparse 5.10.1 in Ubuntu 22.04. +If a native ``SuiteSparse`` CMake package configuration is installed, this +module delegates to it unless ``SuiteSparse_NO_CMAKE`` is set. Otherwise, it +locates the SuiteSparse components directly. This module defines the following variables: @@ -45,16 +45,16 @@ ``TRUE`` iff SuiteSparse and all dependencies have been found. ``SuiteSparse_VERSION`` - Extracted from ``SuiteSparse_config.h`` (>= v4). + Extracted from ``SuiteSparse_config.h``. ``SuiteSparse_VERSION_MAJOR`` - Equal to 4 if ``SuiteSparse_VERSION`` = 4.2.1 + Equal to 7 if ``SuiteSparse_VERSION`` = 7.6.1 ``SuiteSparse_VERSION_MINOR`` - Equal to 2 if ``SuiteSparse_VERSION`` = 4.2.1 + Equal to 6 if ``SuiteSparse_VERSION`` = 7.6.1 ``SuiteSparse_VERSION_PATCH`` - Equal to 1 if ``SuiteSparse_VERSION`` = 4.2.1 + Equal to 1 if ``SuiteSparse_VERSION`` = 7.6.1 The following variables control the behaviour of this module: @@ -89,7 +89,7 @@ Multifrontal Sparse QR (SuiteSparseQR) ``SuiteSparse::Config`` - Common configuration for all but CSparse (SuiteSparse version >= 4). + Common configuration for all SuiteSparse components. Optional SuiteSparse dependencies: @@ -121,11 +121,6 @@ endif (SuiteSparse_FOUND) endif (NOT SuiteSparse_NO_CMAKE) -# Push CMP0057 to enable support for IN_LIST, when cmake_minimum_required is -# set to <3.3. -cmake_policy (PUSH) -cmake_policy (SET CMP0057 NEW) - if (NOT SuiteSparse_FIND_COMPONENTS) set (SuiteSparse_FIND_COMPONENTS AMD @@ -160,12 +155,8 @@ endif () endmacro (suitesparse_find_dependency) -# SuiteSparseQR optionally depends on TBB. Find it here so that it is treated -# as a SuiteSparse dependency rather than as a Ceres dependency. -suitesparse_find_dependency(TBB NO_MODULE) - +include (CheckCXXSourceCompiles) include (CheckLibraryExists) -include (CheckSymbolExists) include (CMakePushCheckState) # Config is a base component and thus always required @@ -236,7 +227,6 @@ # suitesparse_find_component(<component> [FILES name1 [name2 ...]] # [LIBRARIES name1 [name2 ...]]) macro(suitesparse_find_component COMPONENT) - include(CMakeParseArguments) set(MULTI_VALUE_ARGS FILES LIBRARIES) cmake_parse_arguments(SuiteSparse_FIND_COMPONENT_${COMPONENT} "" "" "${MULTI_VALUE_ARGS}" ${ARGN}) @@ -332,23 +322,28 @@ set (component_header ${component_library}.h) endif (component STREQUAL "Config") + set (component_libraries ${component_library}) + if (MSVC OR CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC") + # Upstream SuiteSparse 7 names static MSVC libraries <name>_static.lib. + list (APPEND component_libraries ${component_library}_static) + endif () + suitesparse_find_component(${component} FILES ${component_header} - LIBRARIES ${component_library}) + LIBRARIES ${component_libraries}) + unset (component_libraries) endforeach (component IN LISTS SuiteSparse_FIND_COMPONENTS) check_library_exists(rt shm_open "" HAVE_LIBRT) if (TARGET SuiteSparse::Config) - # SuiteSparse version >= 4. set(SuiteSparse_VERSION_FILE ${SuiteSparse_Config_INCLUDE_DIR}/SuiteSparse_config.h) if (NOT EXISTS ${SuiteSparse_VERSION_FILE}) list(APPEND SuiteSparse_REQUIRED_VARS SuiteSparse_VERSION) suitesparse_report_not_found( - "Could not find file: ${SuiteSparse_VERSION_FILE} containing version " - "information for >= v4 SuiteSparse installs, but SuiteSparse_config was " - "found (only present in >= v4 installs).") + "Could not find file: ${SuiteSparse_VERSION_FILE} containing " + "SuiteSparse version information.") else (NOT EXISTS ${SuiteSparse_VERSION_FILE}) file(READ ${SuiteSparse_VERSION_FILE} Config_CONTENTS) @@ -472,13 +467,6 @@ set (SuiteSparse_LAPACK_LINK ${LAPACK_LIBRARIES}) endif () -set (SuiteSparse_TBB_LINK) -if (TARGET TBB::tbb) - set (SuiteSparse_TBB_LINK TBB::tbb) -elseif (TBB_LIBRARIES) - set (SuiteSparse_TBB_LINK ${TBB_LIBRARIES}) -endif () - set (SuiteSparse_RT_LINK) if (HAVE_LIBRT) set (SuiteSparse_RT_LINK rt) @@ -491,9 +479,6 @@ if (SuiteSparse_LAPACK_LINK) list (APPEND SuiteSparse_OPTIONAL_DEPENDENCIES LAPACK) endif () -if (TARGET SuiteSparse::SPQR AND SuiteSparse_TBB_LINK) - list (APPEND SuiteSparse_OPTIONAL_DEPENDENCIES TBB) -endif () if (SuiteSparse_RT_LINK) list (APPEND SuiteSparse_OPTIONAL_DEPENDENCIES RT) endif () @@ -504,13 +489,6 @@ if (SuiteSparse_ORIGINAL_CONFIG_LINK MATCHES "-NOTFOUND$") set (SuiteSparse_ORIGINAL_CONFIG_LINK) endif () - if (TARGET SuiteSparse::SPQR) - get_target_property(SuiteSparse_ORIGINAL_SPQR_LINK - SuiteSparse::SPQR INTERFACE_LINK_LIBRARIES) - if (SuiteSparse_ORIGINAL_SPQR_LINK MATCHES "-NOTFOUND$") - set (SuiteSparse_ORIGINAL_SPQR_LINK) - endif () - endif () function (suitesparse_set_link_dependencies) set (SuiteSparse_CONFIG_LINK ${SuiteSparse_ORIGINAL_CONFIG_LINK}) @@ -525,15 +503,6 @@ endif () set_property (TARGET SuiteSparse::Config PROPERTY INTERFACE_LINK_LIBRARIES "${SuiteSparse_CONFIG_LINK}") - - if (TARGET SuiteSparse::SPQR) - set (SuiteSparse_SPQR_LINK ${SuiteSparse_ORIGINAL_SPQR_LINK}) - if (TBB IN_LIST ARGN) - list (APPEND SuiteSparse_SPQR_LINK ${SuiteSparse_TBB_LINK}) - endif () - set_property (TARGET SuiteSparse::SPQR PROPERTY - INTERFACE_LINK_LIBRARIES "${SuiteSparse_SPQR_LINK}") - endif () endfunction (suitesparse_set_link_dependencies) suitesparse_set_link_dependencies(${SuiteSparse_OPTIONAL_DEPENDENCIES}) @@ -564,9 +533,6 @@ if (NOT SuiteSparse_LAPACK_LINK) list (APPEND SuiteSparse_MISSING_DEPENDENCIES LAPACK) endif () - if (TARGET SuiteSparse::SPQR AND NOT SuiteSparse_TBB_LINK) - list (APPEND SuiteSparse_MISSING_DEPENDENCIES TBB) - endif () if (NOT SuiteSparse_RT_LINK) list (APPEND SuiteSparse_MISSING_DEPENDENCIES RT) endif () @@ -591,48 +557,70 @@ endif () endif () -# Check whether CHOLMOD was compiled with METIS support. The check can be -# performed only after the main components have been set up. -if (TARGET SuiteSparse::CHOLMOD) - # NOTE If SuiteSparse was compiled as a static library we'll need to link - # against METIS already during the check. Otherwise, the check can fail due to - # undefined references even though SuiteSparse was compiled with METIS. - # - # Other METIS find modules may define METIS_FOUND without providing the - # METIS::METIS target required for linking. - if (NOT TARGET METIS::METIS) - find_package (METIS) - endif (NOT TARGET METIS::METIS) +# Check whether CHOLMOD was compiled with the Partition module (METIS support). +# The check can be performed only after the main components have been set up. +# +# SuiteSparse 7 / CHOLMOD 5 bundles SuiteSparse_metis inside CHOLMOD itself +# rather than requiring an external METIS library, and defines NPARTITION in +# cholmod.h when the Partition module is disabled (while still exporting a stub +# cholmod_metis symbol). Test linking CHOLMOD alone first, and fall back to +# external METIS only if needed. +if (SuiteSparse_FOUND AND TARGET SuiteSparse::CHOLMOD) + set (_SuiteSparse_PARTITION_CHECK_SOURCE + "#include <cholmod.h>\n#ifdef NPARTITION\n#error CHOLMOD built without Partition module\n#endif\ntemplate <typename T>\nstatic int check_symbol(T* fn) {\n T* volatile p = fn;\n return p ? 0 : 1;\n}\nint main() { return check_symbol(&cholmod_metis); }\n") - if (TARGET METIS::METIS) - cmake_push_check_state (RESET) - set (CMAKE_REQUIRED_LIBRARIES SuiteSparse::CHOLMOD METIS::METIS) - check_symbol_exists (cholmod_metis cholmod.h SuiteSparse_CHOLMOD_USES_METIS) - cmake_pop_check_state () + cmake_push_check_state (RESET) + set (CMAKE_REQUIRED_LIBRARIES SuiteSparse::CHOLMOD) + check_cxx_source_compiles ("${_SuiteSparse_PARTITION_CHECK_SOURCE}" + SuiteSparse_CHOLMOD_HAS_PARTITION) + cmake_pop_check_state () - if (NOT SuiteSparse_CHOLMOD_USES_METIS AND SuiteSparse_FIND_REQUIRED_Partition) - list (APPEND CMAKE_FIND_PACKAGE_REASON - "Partition: CHOLMOD was not compiled with METIS support.") - endif (NOT SuiteSparse_CHOLMOD_USES_METIS AND SuiteSparse_FIND_REQUIRED_Partition) + set (SuiteSparse_CHOLMOD_USES_METIS ${SuiteSparse_CHOLMOD_HAS_PARTITION}) + set (SuiteSparse_CHOLMOD_NEEDS_EXTERNAL_METIS FALSE) - if (SuiteSparse_CHOLMOD_USES_METIS) + if (NOT SuiteSparse_CHOLMOD_USES_METIS) + # Other METIS find modules may define METIS_FOUND without providing the + # METIS::METIS target required for linking. + if (NOT TARGET METIS::METIS) + suitesparse_find_dependency (METIS) + endif (NOT TARGET METIS::METIS) + + if (TARGET METIS::METIS) + cmake_push_check_state (RESET) + set (CMAKE_REQUIRED_LIBRARIES SuiteSparse::CHOLMOD METIS::METIS) + check_cxx_source_compiles ("${_SuiteSparse_PARTITION_CHECK_SOURCE}" + SuiteSparse_CHOLMOD_HAS_PARTITION_EXTERNAL_METIS) + cmake_pop_check_state () + + if (SuiteSparse_CHOLMOD_HAS_PARTITION_EXTERNAL_METIS) + set (SuiteSparse_CHOLMOD_USES_METIS TRUE) + set (SuiteSparse_CHOLMOD_NEEDS_EXTERNAL_METIS TRUE) + endif () + endif (TARGET METIS::METIS) + endif () + unset (_SuiteSparse_PARTITION_CHECK_SOURCE) + + if (NOT SuiteSparse_CHOLMOD_USES_METIS AND SuiteSparse_FIND_REQUIRED_Partition) + list (APPEND CMAKE_FIND_PACKAGE_REASON + "Partition: CHOLMOD was not compiled with METIS support.") + endif (NOT SuiteSparse_CHOLMOD_USES_METIS AND SuiteSparse_FIND_REQUIRED_Partition) + + if (SuiteSparse_CHOLMOD_USES_METIS) + if (SuiteSparse_CHOLMOD_NEEDS_EXTERNAL_METIS) set_property (TARGET SuiteSparse::CHOLMOD APPEND PROPERTY INTERFACE_LINK_LIBRARIES $<LINK_ONLY:METIS::METIS>) + endif () - # Provide the SuiteSparse::Partition component whose availability indicates - # that CHOLMOD was compiled with the Partition module. - if (NOT TARGET SuiteSparse::Partition) - add_library (SuiteSparse::Partition IMPORTED INTERFACE) - endif (NOT TARGET SuiteSparse::Partition) + # Provide the SuiteSparse::Partition component whose availability indicates + # that CHOLMOD was compiled with the Partition module. + if (NOT TARGET SuiteSparse::Partition) + add_library (SuiteSparse::Partition IMPORTED INTERFACE) + endif (NOT TARGET SuiteSparse::Partition) - set_property (TARGET SuiteSparse::Partition APPEND PROPERTY - INTERFACE_LINK_LIBRARIES SuiteSparse::CHOLMOD) - endif (SuiteSparse_CHOLMOD_USES_METIS) - elseif (SuiteSparse_FIND_REQUIRED_Partition) - list (APPEND CMAKE_FIND_PACKAGE_REASON - "Partition: METIS could not be found.") - endif (TARGET METIS::METIS) -endif (TARGET SuiteSparse::CHOLMOD) + set_property (TARGET SuiteSparse::Partition APPEND PROPERTY + INTERFACE_LINK_LIBRARIES SuiteSparse::CHOLMOD) + endif (SuiteSparse_CHOLMOD_USES_METIS) +endif (SuiteSparse_FOUND AND TARGET SuiteSparse::CHOLMOD) # We do not use suitesparse_find_component to find Partition and therefore must # handle the availability in an extra step. @@ -656,6 +644,3 @@ VERSION_VAR SuiteSparse_VERSION REASON_FAILURE_MESSAGE "${CMAKE_FIND_PACKAGE_REASON}" HANDLE_COMPONENTS) - -# Pop CMP0057. -cmake_policy (POP)
diff --git a/cmake/config.h.in b/cmake/config.h.in index 1924f48..b824489 100644 --- a/cmake/config.h.in +++ b/cmake/config.h.in
@@ -80,10 +80,6 @@ // the Partition module (requires METIS). @CERES_NO_CHOLMOD_PARTITION@ -// If defined Ceres was compiled with a version of SuiteSparse that does not -// support single precision solves in CHOLMOD. -@CERES_NO_CHOLMOD_FLOAT@ - // If defined Ceres was compiled without support for METIS via Eigen. @CERES_NO_EIGEN_METIS@
diff --git a/internal/ceres/CMakeLists.txt b/internal/ceres/CMakeLists.txt index 043848a..f62f148 100644 --- a/internal/ceres/CMakeLists.txt +++ b/internal/ceres/CMakeLists.txt
@@ -32,26 +32,18 @@ list(APPEND CERES_LIBRARY_PRIVATE_DEPENDENCIES Threads::Threads) -# Generator expressions were introduced in CMake version 3.24. Without -# them including absl::log_flags as an internal dependency causes -# linking problems on some platforms. So for platforms with an older -# CMake version we make absl::log_flags a public dependency. -if(CMAKE_VERSION VERSION_LESS "3.24.0") - list(APPEND CERES_LIBRARY_PUBLIC_DEPENDENCIES absl::log_flags) +# Apply $<LINK_LIBRARY:...> generator expression only if the corresponding +# target is a static library. Otherwise link only to the target. The library +# type is determined at configure time because SBOM generation does not +# support generator expressions in link libraries. +get_target_property(_Ceres_ABSL_LOG_FLAGS_TYPE absl::log_flags TYPE) +if (_Ceres_ABSL_LOG_FLAGS_TYPE STREQUAL STATIC_LIBRARY) + list(APPEND CERES_LIBRARY_PRIVATE_DEPENDENCIES + $<LINK_LIBRARY:WHOLE_ARCHIVE,absl::log_flags>) else() - # Apply $<LINK_LIBRARY:...> generator expression only if the corresponding - # target is a static library. Otherwise link only to the target. The library - # type is determined at configure time because SBOM generation does not - # support generator expressions in link libraries. - get_target_property(_Ceres_ABSL_LOG_FLAGS_TYPE absl::log_flags TYPE) - if (_Ceres_ABSL_LOG_FLAGS_TYPE STREQUAL STATIC_LIBRARY) - list(APPEND CERES_LIBRARY_PRIVATE_DEPENDENCIES - $<LINK_LIBRARY:WHOLE_ARCHIVE,absl::log_flags>) - else() - list(APPEND CERES_LIBRARY_PRIVATE_DEPENDENCIES absl::log_flags) - endif() - unset(_Ceres_ABSL_LOG_FLAGS_TYPE) + list(APPEND CERES_LIBRARY_PRIVATE_DEPENDENCIES absl::log_flags) endif() +unset(_Ceres_ABSL_LOG_FLAGS_TYPE) list(APPEND CERES_LIBRARY_PRIVATE_DEPENDENCIES absl::strings) list(APPEND CERES_LIBRARY_PRIVATE_DEPENDENCIES absl::time) @@ -125,11 +117,13 @@ # environment. CHOLMOD and METIS are linked explicitly instead. endif (_Ceres_FEATURE_SUITESPARSE) -if (_Ceres_FEATURE_CHOLMOD_PARTITION OR _Ceres_FEATURE_EIGEN_METIS) +if (_Ceres_FEATURE_EIGEN_METIS OR + (_Ceres_FEATURE_CHOLMOD_PARTITION AND + SuiteSparse_CHOLMOD_NEEDS_EXTERNAL_METIS)) # Define version information for use in Solver::FullReport. add_definitions(-DCERES_METIS_VERSION="${METIS_VERSION}") list(APPEND CERES_LIBRARY_PRIVATE_DEPENDENCIES METIS::METIS) -endif (_Ceres_FEATURE_CHOLMOD_PARTITION OR _Ceres_FEATURE_EIGEN_METIS) +endif () if (_Ceres_FEATURE_ACCELERATE) list(APPEND CERES_LIBRARY_PRIVATE_DEPENDENCIES AccelerateSparse::Accelerate)
diff --git a/internal/ceres/generate_bundle_adjustment_tests.py b/internal/ceres/generate_bundle_adjustment_tests.py index 126ecde..ac5c447 100644 --- a/internal/ceres/generate_bundle_adjustment_tests.py +++ b/internal/ceres/generate_bundle_adjustment_tests.py
@@ -250,10 +250,6 @@ preprocessor_conditions_begin.append('#ifndef CERES_NO_CUDA') preprocessor_conditions_end.insert(0, '#endif // CERES_NO_CUDA') - if mixed_precision and sparse_backend == 'SUITE_SPARSE': - preprocessor_conditions_begin.append('#ifndef CERES_NO_CHOLMOD_FLOAT') - preprocessor_conditions_end.insert(0, '#endif // CERES_NO_CHOLMOD_FLOAT') - # If there are #ifdefs, put newlines around them. if preprocessor_conditions_begin: preprocessor_conditions_begin.insert(0, '')
diff --git a/internal/ceres/generated_bundle_adjustment_tests/ba_sparsecholesky_suitesparse_auto_mixed_test.cc b/internal/ceres/generated_bundle_adjustment_tests/ba_sparsecholesky_suitesparse_auto_mixed_test.cc index 0c40fea..c571509 100644 --- a/internal/ceres/generated_bundle_adjustment_tests/ba_sparsecholesky_suitesparse_auto_mixed_test.cc +++ b/internal/ceres/generated_bundle_adjustment_tests/ba_sparsecholesky_suitesparse_auto_mixed_test.cc
@@ -44,7 +44,6 @@ #ifndef CERES_NO_SUITESPARSE -#ifndef CERES_NO_CHOLMOD_FLOAT namespace ceres::internal { @@ -69,5 +68,4 @@ } // namespace ceres::internal -#endif // CERES_NO_CHOLMOD_FLOAT #endif // CERES_NO_SUITESPARSE
diff --git a/internal/ceres/generated_bundle_adjustment_tests/ba_sparsecholesky_suitesparse_auto_threads_mixed_test.cc b/internal/ceres/generated_bundle_adjustment_tests/ba_sparsecholesky_suitesparse_auto_threads_mixed_test.cc index 332ae88..9fd1ac9 100644 --- a/internal/ceres/generated_bundle_adjustment_tests/ba_sparsecholesky_suitesparse_auto_threads_mixed_test.cc +++ b/internal/ceres/generated_bundle_adjustment_tests/ba_sparsecholesky_suitesparse_auto_threads_mixed_test.cc
@@ -44,7 +44,6 @@ #ifndef CERES_NO_SUITESPARSE -#ifndef CERES_NO_CHOLMOD_FLOAT namespace ceres::internal { @@ -69,5 +68,4 @@ } // namespace ceres::internal -#endif // CERES_NO_CHOLMOD_FLOAT #endif // CERES_NO_SUITESPARSE
diff --git a/internal/ceres/generated_bundle_adjustment_tests/ba_sparsecholesky_suitesparse_user_mixed_test.cc b/internal/ceres/generated_bundle_adjustment_tests/ba_sparsecholesky_suitesparse_user_mixed_test.cc index e5df8ae..abc6286 100644 --- a/internal/ceres/generated_bundle_adjustment_tests/ba_sparsecholesky_suitesparse_user_mixed_test.cc +++ b/internal/ceres/generated_bundle_adjustment_tests/ba_sparsecholesky_suitesparse_user_mixed_test.cc
@@ -44,7 +44,6 @@ #ifndef CERES_NO_SUITESPARSE -#ifndef CERES_NO_CHOLMOD_FLOAT namespace ceres::internal { @@ -69,5 +68,4 @@ } // namespace ceres::internal -#endif // CERES_NO_CHOLMOD_FLOAT #endif // CERES_NO_SUITESPARSE
diff --git a/internal/ceres/generated_bundle_adjustment_tests/ba_sparsecholesky_suitesparse_user_threads_mixed_test.cc b/internal/ceres/generated_bundle_adjustment_tests/ba_sparsecholesky_suitesparse_user_threads_mixed_test.cc index 4d5853f..d9eea32 100644 --- a/internal/ceres/generated_bundle_adjustment_tests/ba_sparsecholesky_suitesparse_user_threads_mixed_test.cc +++ b/internal/ceres/generated_bundle_adjustment_tests/ba_sparsecholesky_suitesparse_user_threads_mixed_test.cc
@@ -44,7 +44,6 @@ #ifndef CERES_NO_SUITESPARSE -#ifndef CERES_NO_CHOLMOD_FLOAT namespace ceres::internal { @@ -69,5 +68,4 @@ } // namespace ceres::internal -#endif // CERES_NO_CHOLMOD_FLOAT #endif // CERES_NO_SUITESPARSE
diff --git a/internal/ceres/generated_bundle_adjustment_tests/ba_sparseschur_suitesparse_auto_mixed_test.cc b/internal/ceres/generated_bundle_adjustment_tests/ba_sparseschur_suitesparse_auto_mixed_test.cc index 435e9a7..00d68bd 100644 --- a/internal/ceres/generated_bundle_adjustment_tests/ba_sparseschur_suitesparse_auto_mixed_test.cc +++ b/internal/ceres/generated_bundle_adjustment_tests/ba_sparseschur_suitesparse_auto_mixed_test.cc
@@ -44,7 +44,6 @@ #ifndef CERES_NO_SUITESPARSE -#ifndef CERES_NO_CHOLMOD_FLOAT namespace ceres::internal { @@ -69,5 +68,4 @@ } // namespace ceres::internal -#endif // CERES_NO_CHOLMOD_FLOAT #endif // CERES_NO_SUITESPARSE
diff --git a/internal/ceres/generated_bundle_adjustment_tests/ba_sparseschur_suitesparse_auto_threads_mixed_test.cc b/internal/ceres/generated_bundle_adjustment_tests/ba_sparseschur_suitesparse_auto_threads_mixed_test.cc index f153ba1..a7b1485 100644 --- a/internal/ceres/generated_bundle_adjustment_tests/ba_sparseschur_suitesparse_auto_threads_mixed_test.cc +++ b/internal/ceres/generated_bundle_adjustment_tests/ba_sparseschur_suitesparse_auto_threads_mixed_test.cc
@@ -44,7 +44,6 @@ #ifndef CERES_NO_SUITESPARSE -#ifndef CERES_NO_CHOLMOD_FLOAT namespace ceres::internal { @@ -69,5 +68,4 @@ } // namespace ceres::internal -#endif // CERES_NO_CHOLMOD_FLOAT #endif // CERES_NO_SUITESPARSE
diff --git a/internal/ceres/generated_bundle_adjustment_tests/ba_sparseschur_suitesparse_user_mixed_test.cc b/internal/ceres/generated_bundle_adjustment_tests/ba_sparseschur_suitesparse_user_mixed_test.cc index fb504ef..7009375 100644 --- a/internal/ceres/generated_bundle_adjustment_tests/ba_sparseschur_suitesparse_user_mixed_test.cc +++ b/internal/ceres/generated_bundle_adjustment_tests/ba_sparseschur_suitesparse_user_mixed_test.cc
@@ -44,7 +44,6 @@ #ifndef CERES_NO_SUITESPARSE -#ifndef CERES_NO_CHOLMOD_FLOAT namespace ceres::internal { @@ -69,5 +68,4 @@ } // namespace ceres::internal -#endif // CERES_NO_CHOLMOD_FLOAT #endif // CERES_NO_SUITESPARSE
diff --git a/internal/ceres/generated_bundle_adjustment_tests/ba_sparseschur_suitesparse_user_threads_mixed_test.cc b/internal/ceres/generated_bundle_adjustment_tests/ba_sparseschur_suitesparse_user_threads_mixed_test.cc index 03934ce..4a2e1d8 100644 --- a/internal/ceres/generated_bundle_adjustment_tests/ba_sparseschur_suitesparse_user_threads_mixed_test.cc +++ b/internal/ceres/generated_bundle_adjustment_tests/ba_sparseschur_suitesparse_user_threads_mixed_test.cc
@@ -44,7 +44,6 @@ #ifndef CERES_NO_SUITESPARSE -#ifndef CERES_NO_CHOLMOD_FLOAT namespace ceres::internal { @@ -69,5 +68,4 @@ } // namespace ceres::internal -#endif // CERES_NO_CHOLMOD_FLOAT #endif // CERES_NO_SUITESPARSE
diff --git a/internal/ceres/solver.cc b/internal/ceres/solver.cc index 97c1d87..8823d34 100644 --- a/internal/ceres/solver.cc +++ b/internal/ceres/solver.cc
@@ -192,17 +192,6 @@ return false; } -#ifdef CERES_NO_CHOLMOD_FLOAT - if (options.use_mixed_precision_solves && - options.sparse_linear_algebra_library_type == SUITE_SPARSE) { - *error = - "This version of SuiteSparse does not support single precision " - "Cholesky factorization. So use_mixed_precision_solves is not " - "supported with SUITE_SPARSE"; - return false; - } -#endif - if (options.dynamic_sparsity && options.sparse_linear_algebra_library_type == ACCELERATE_SPARSE) { *error = absl::StrFormat(kDynamicSparsityFormat, library_name);
diff --git a/internal/ceres/solver_test.cc b/internal/ceres/solver_test.cc index 22043f9..f1a866b 100644 --- a/internal/ceres/solver_test.cc +++ b/internal/ceres/solver_test.cc
@@ -607,11 +607,7 @@ options.sparse_linear_algebra_library_type)) { options.use_mixed_precision_solves = true; options.dynamic_sparsity = false; -#ifdef CERES_NO_CHOLMOD_FLOAT - EXPECT_FALSE(options.IsValid(&message)); -#else EXPECT_TRUE(options.IsValid(&message)) << message; -#endif options.use_mixed_precision_solves = false; options.dynamic_sparsity = true; @@ -619,11 +615,7 @@ options.use_mixed_precision_solves = true; options.dynamic_sparsity = true; -#ifdef CERES_NO_CHOLMOD_FLOAT - EXPECT_FALSE(options.IsValid(&message)); -#else EXPECT_TRUE(options.IsValid(&message)) << message; -#endif } #ifndef CERES_NO_CHOLMOD_PARTITION @@ -636,11 +628,7 @@ options.use_mixed_precision_solves = true; options.dynamic_sparsity = false; -#ifdef CERES_NO_CHOLMOD_FLOAT - EXPECT_FALSE(options.IsValid(&message)); -#else EXPECT_TRUE(options.IsValid(&message)) << message; -#endif options.use_mixed_precision_solves = false; options.dynamic_sparsity = true; @@ -648,11 +636,7 @@ options.use_mixed_precision_solves = true; options.dynamic_sparsity = true; -#ifdef CERES_NO_CHOLMOD_FLOAT - EXPECT_FALSE(options.IsValid(&message)); -#else EXPECT_TRUE(options.IsValid(&message)) << message; -#endif } #else options.linear_solver_ordering_type = NESDIS; @@ -841,11 +825,7 @@ options.sparse_linear_algebra_library_type)) { options.use_mixed_precision_solves = true; options.dynamic_sparsity = false; -#ifdef CERES_NO_CHOLMOD_FLOAT - EXPECT_FALSE(options.IsValid(&message)); -#else EXPECT_TRUE(options.IsValid(&message)) << message; -#endif options.use_mixed_precision_solves = false; options.dynamic_sparsity = true; @@ -866,11 +846,7 @@ options.use_mixed_precision_solves = true; options.dynamic_sparsity = false; -#ifdef CERES_NO_CHOLMOD_FLOAT - EXPECT_FALSE(options.IsValid(&message)); -#else EXPECT_TRUE(options.IsValid(&message)) << message; -#endif options.use_mixed_precision_solves = false; options.dynamic_sparsity = true;
diff --git a/internal/ceres/solver_utils.cc b/internal/ceres/solver_utils.cc index 4162b46..6f319da 100644 --- a/internal/ceres/solver_utils.cc +++ b/internal/ceres/solver_utils.cc
@@ -60,7 +60,7 @@ "-suitesparse-(" CERES_SUITESPARSE_VERSION ")" #endif -#if !defined(CERES_NO_EIGEN_METIS) || !defined(CERES_NO_CHOLMOD_PARTITION) +#ifdef CERES_METIS_VERSION "-metis-(" CERES_METIS_VERSION ")" #endif
diff --git a/internal/ceres/sparse_cholesky_test.cc b/internal/ceres/sparse_cholesky_test.cc index ac1aaff..6985dbc 100644 --- a/internal/ceres/sparse_cholesky_test.cc +++ b/internal/ceres/sparse_cholesky_test.cc
@@ -226,11 +226,7 @@ #ifndef CERES_NO_SUITESPARSE const auto SuiteSparseCholeskyParameters = ::testing::Combine( ::testing::Values(SUITE_SPARSE), -#if defined(CERES_NO_CHOLMOD_FLOAT) - ::testing::Values(false), -#else ::testing::Values(false, true), -#endif // defined(CERES_NO_CHOLMOD_FLOAT) #if defined(CERES_NO_CHOLMOD_PARTITION) ::testing::Values(OrderingType::AMD, OrderingType::NATURAL), #else
diff --git a/internal/ceres/suitesparse.cc b/internal/ceres/suitesparse.cc index 2cc9ff3..a158918 100644 --- a/internal/ceres/suitesparse.cc +++ b/internal/ceres/suitesparse.cc
@@ -466,8 +466,6 @@ return LinearSolverTerminationType::SUCCESS; } -#ifndef CERES_NO_CHOLMOD_FLOAT - std::unique_ptr<SparseCholesky> FloatSuiteSparseCholesky::Create( const OrderingType ordering_type) { return std::unique_ptr<SparseCholesky>( @@ -568,52 +566,6 @@ return LinearSolverTerminationType::SUCCESS; } -#else - -std::unique_ptr<SparseCholesky> FloatSuiteSparseCholesky::Create( - const OrderingType ordering_type) { - return nullptr; -} - -FloatSuiteSparseCholesky::FloatSuiteSparseCholesky( - const OrderingType ordering_type) - : ordering_type_(ordering_type), factor_(nullptr) {} - -FloatSuiteSparseCholesky::~FloatSuiteSparseCholesky() { - if (factor_ != nullptr) { - ss_.Free(factor_); - } -} - -LinearSolverTerminationType FloatSuiteSparseCholesky::Factorize( - CompressedRowSparseMatrix* lhs, std::string* message) { - *message = - "Single precision Cholesky factorization is not supported. If " - "you are seeing this failure, then you have discovered a Ceres " - "Solver bug. Please get in touch with the Ceres Solver team at " - "ceres-solver@googlegroups.com"; - return LinearSolverTerminationType::FATAL_ERROR; -} - -CompressedRowSparseMatrix::StorageType FloatSuiteSparseCholesky::StorageType() - const { - return ((ordering_type_ == OrderingType::NATURAL) - ? CompressedRowSparseMatrix::StorageType::UPPER_TRIANGULAR - : CompressedRowSparseMatrix::StorageType::LOWER_TRIANGULAR); -} - -LinearSolverTerminationType FloatSuiteSparseCholesky::Solve( - const double* rhs, double* solution, std::string* message) { - *message = - "Single precision Cholesky factorization is not supported. If " - "you are seeing this failure, then you have discovered a Ceres " - "Solver bug. Please get in touch with the Ceres Solver team at " - "ceres-solver@googlegroups.com"; - return LinearSolverTerminationType::FATAL_ERROR; -} - -#endif // CERES_NO_CHOLMOD_FLOAT - } // namespace ceres::internal #endif // CERES_NO_SUITESPARSE
diff --git a/third_party/abseil-cpp b/third_party/abseil-cpp index 9ac7062..2065f4d 160000 --- a/third_party/abseil-cpp +++ b/third_party/abseil-cpp
@@ -1 +1 @@ -Subproject commit 9ac7062b1860d895fb5a8cbf58c3e9ef8f674b5f +Subproject commit 2065f4ded0558c6f89fee67c8e5228feb4eb960e