mirror of
https://github.com/ceres-solver/ceres-solver.git
synced 2026-08-29 08:34:37 +08:00
Fix Abseil usage of installed cmake-config
Fix the generated cmake-config file to look for the used Abseil-cpp config files providing the needed targets. When using Abseil from system (or locally installed and set via `absl_DIR`) the used targets like `absl::log` need to be made available in downstream projects using `ceres-solver`. For system packages with no `absl_VERSION` info check for the required target `absl::absl_vlog_is_on`, just like we do in `CMakeLists.txt`. Error on installation/export of "no-absl-VERSION" as we can't check version mismatches. When using `abseil-cpp` as submodule the abseil-configs are added to the install target as well. Use these config files to make the needed Abseil targets available. In the submodule case extract the `absl_VERSION` variable from its `CMakeLists.txt` file for us to check against in the generated cmake-config-file. Fixes: https://github.com/ceres-solver/ceres-solver/issues/1089 Change-Id: I3e3d079ddf931e7fe1b57783471c32c19e4d31b6
This commit is contained in:
@@ -190,6 +190,29 @@ include(CMakeFindDependencyMacro)
|
||||
# defined, and so CMake will assume that they refer to a library name and
|
||||
# fail to link correctly.
|
||||
|
||||
# Abseil
|
||||
set(_CERES_ABSL_VERSION @absl_VERSION@)
|
||||
set(_CERES_USE_SYSTEM_ABSL @CERES_USE_SYSTEM_ABSL@)
|
||||
if (_CERES_USE_SYSTEM_ABSL)
|
||||
find_dependency(absl ${_CERES_ABSL_VERSION})
|
||||
if (NOT absl_VERSION)
|
||||
if (NOT TARGET absl::absl_vlog_is_on)
|
||||
ceres_report_not_found("The version of abseil installed on the system "
|
||||
"provides no version info and is missing TARGET 'absl::absl_vlog_is_on'")
|
||||
endif ()
|
||||
endif ()
|
||||
else ()
|
||||
# absl from submodule, configs installed with ceres-solver
|
||||
get_filename_component(_ABSL_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||
get_filename_component(_ABSL_IMPORT_PREFIX "${_ABSL_IMPORT_PREFIX}" PATH)
|
||||
set(_ABSL_IMPORT_PREFIX "${_ABSL_IMPORT_PREFIX}/absl")
|
||||
find_dependency(absl ${_CERES_ABSL_VERSION} HINTS "${_ABSL_IMPORT_PREFIX}")
|
||||
endif ()
|
||||
ceres_message(STATUS "Found required Ceres dependency: "
|
||||
"absl version ${_CERES_ABSL_VERSION} in ${absl_DIR}")
|
||||
unset(_CERES_ABSL_VERSION)
|
||||
unset(_CERES_USE_SYSTEM_ABSL)
|
||||
|
||||
# Eigen.
|
||||
# Flag set during configuration and build of Ceres.
|
||||
set(CERES_EIGEN_VERSION @Eigen3_VERSION@)
|
||||
|
||||
Reference in New Issue
Block a user