Skip to content

Commit d08ff4e

Browse files
hollowsunhcPatrick Laurin
authored andcommitted
refactor: Link to SuiteSparse targets
1 parent ca6ca18 commit d08ff4e

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

deps/CMakeLists.txt

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -117,26 +117,21 @@ else (SUITESPARSE)
117117
message("-- Building without SuiteSparse.")
118118
endif (SUITESPARSE)
119119

120-
# HACK BY NICK
121-
# The SuiteSparse logic above doesn't look for UMFpack, but we need it.
122-
# This code attempts to find if by assuming that it will be in the same place
123-
# as cholmod
124-
if(SUITESPARSE AND SUITESPARSE_FOUND)
125-
string(REGEX REPLACE "cholmod" "umfpack" UMFPACK_LIBRARY ${CHOLMOD_LIBRARY})
126-
message("-- Guesstimated umfpack location as: ${UMFPACK_LIBRARY}")
127-
if(EXISTS ${UMFPACK_LIBRARY})
128-
list(APPEND SUITESPARSE_LIBRARIES ${UMFPACK_LIBRARY})
129-
else()
130-
message(WARNING "UMFPack guess failed, so we don't actually have SUITESPARSE support.")
131-
set(SUITESPARSE_FOUND FALSE)
132-
endif()
133-
endif()
134-
135120
if(SUITESPARSE AND SUITESPARSE_FOUND)
136121
SET(GC_HAVE_SUITESPARSE TRUE)
137122
SET(GC_HAVE_SUITESPARSE TRUE PARENT_SCOPE)
138-
set(SUITESPARSE_INCLUDE_DIRS "${SUITESPARSE_INCLUDE_DIRS}" PARENT_SCOPE)
139-
set(SUITESPARSE_LIBRARIES "${SUITESPARSE_LIBRARIES}" PARENT_SCOPE)
123+
if(NOT TARGET SuiteSparse::cholmod)
124+
message(FATAL_ERROR "SuiteSparse::cholmod target not found.")
125+
endif()
126+
set_target_properties(SuiteSparse::cholmod PROPERTIES IMPORTED_GLOBAL TRUE)
127+
if(NOT TARGET SuiteSparse::spqr)
128+
message(FATAL_ERROR "SuiteSparse::spqr target not found.")
129+
endif()
130+
set_target_properties(SuiteSparse::spqr PROPERTIES IMPORTED_GLOBAL TRUE)
131+
if(NOT TARGET SuiteSparse::umfpack)
132+
message(FATAL_ERROR "SuiteSparse::umfpack target not found.")
133+
endif()
134+
set_target_properties(SuiteSparse::umfpack PROPERTIES IMPORTED_GLOBAL TRUE)
140135
else()
141136
SET(GC_HAVE_SUITESPARSE FALSE)
142137
SET(GC_HAVE_SUITESPARSE FALSE PARENT_SCOPE)

src/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,11 @@ target_compile_definitions(geometry-central PUBLIC NOMINMAX _USE_MATH_DEFINES)
187187
# Define CMAKE flag used in these sources (but should be kept OUT of headers)
188188
if(GC_HAVE_SUITESPARSE)
189189
target_compile_definitions(geometry-central PUBLIC GC_HAVE_SUITESPARSE)
190-
target_include_directories(geometry-central PRIVATE ${SUITESPARSE_INCLUDE_DIRS})
191-
target_link_libraries(geometry-central PRIVATE ${SUITESPARSE_LIBRARIES})
190+
target_link_libraries(geometry-central PRIVATE
191+
SuiteSparse::cholmod
192+
SuiteSparse::spqr
193+
SuiteSparse::umfpack
194+
)
192195
endif()
193196

194197
# Export symbols if DLL is requested

0 commit comments

Comments
 (0)