Skip to content

Commit

Permalink
hunter: support SuiteSparse-metis v7.5.1-1 without SuiteSparse::metis
Browse files Browse the repository at this point in the history
Support the latest SuiteSparse-metis-for-windows `v7.5.1-1` release,
which doesn't provide the `SuiteSparse::metis` target anymore, as Metis
is now a private dependency of Cholmod.

Furthermore support finding `SuiteSparse-metis` with the non-Hunter
build, to use local dependencies with `-DSuiteSparse_DIR=...`.

Change-Id: I15dc9611efbd7ec7882773e92f4fa261c69bd669
  • Loading branch information
NeroBurner committed Jan 25, 2024
1 parent d6d24b4 commit d5dd601
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
12 changes: 9 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,17 @@ if (SUITESPARSE)
hunter_add_package(SuiteSparse)
set(SuiteSparse_NO_CMAKE OFF) # don't install FindSuiteSparse and FindMetis

# Check for SuiteSparse and dependencies.
if (HUNTER_ENABLED)
find_package(SuiteSparse CONFIG)
# first try to find SuideSparse-metis config
find_package(SuiteSparse CONFIG)
if (SuiteSparse_FOUND AND TARGET SuiteSparse::cholmod)
set(SuiteSparse_metis ON)
set(SuiteSparse_Partition_FOUND ON)
else ()
set(SuiteSparse_metis OFF)
set(SuiteSparse_FOUND OFF) # try again with COMPONENTS
endif ()
# Check for SuiteSparse and dependencies.
if (NOT SuiteSparse_FOUND)
find_package(SuiteSparse 4.5.6 COMPONENTS CHOLMOD SPQR
OPTIONAL_COMPONENTS Partition)
endif()
Expand Down
9 changes: 8 additions & 1 deletion internal/ceres/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ endif (NOT MINIGLOG AND GLOG_FOUND)
if (SUITESPARSE AND SuiteSparse_FOUND)
# Define version information for use in Solver::FullReport.
add_definitions(-DCERES_SUITESPARSE_VERSION="${SuiteSparse_VERSION}")
if (NOT HUNTER_ENABLED) # no indent to keep diffs small
if (NOT SuiteSparse_metis) # no indent to keep diffs small
list(APPEND CERES_LIBRARY_PRIVATE_DEPENDENCIES SuiteSparse::CHOLMOD
SuiteSparse::SPQR)

Expand Down Expand Up @@ -130,9 +130,16 @@ if (TARGET SuiteSparse::metis) # provided by SuiteSparse-metis-for-windows
message(STATUS "Linking against 'SuiteSparse::metis' with version '${SuiteSparse_METIS_VERSION}'")
else ()
if (SuiteSparse_Partition_FOUND OR EIGENMETIS)
if ("${METIS_VERSION}" STREQUAL "")
# if none provided set a default version string
# this is the case for SuiteSparse-metis 7.5.1-1
set(METIS_VERSION "5.1.0")
endif()
# Define version information for use in Solver::FullReport.
add_definitions(-DCERES_METIS_VERSION="${METIS_VERSION}")
if (TARGET METIS::METIS) # no indent to keep changes small
list(APPEND CERES_LIBRARY_PRIVATE_DEPENDENCIES METIS::METIS)
endif ()
endif (SuiteSparse_Partition_FOUND OR EIGENMETIS)
endif ()

Expand Down

0 comments on commit d5dd601

Please sign in to comment.