Skip to content

Commit dfc8147

Browse files
authored
Merge pull request #2420 from SCIInstitute/2419-suitesparse
Add support for suitesparse when detected by geometry central.
2 parents fcf9209 + 08a21b1 commit dfc8147

File tree

3 files changed

+72
-3
lines changed

3 files changed

+72
-3
lines changed

Libs/Mesh/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ target_link_libraries(Mesh PUBLIC
4646
igl::core
4747
Particles
4848
TBB::tbb
49-
${GEOMETRYCENTRAL_LIBRARY}
49+
${GEOMETRYCENTRAL_LIBRARIES}
5050
Boost::filesystem
5151
acvd::acvd
5252
)

Libs/Optimize/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ target_link_libraries(Optimize PUBLIC
3434
${ITK_LIBRARIES}
3535
igl::core
3636
${Boost_LIBRARIES}
37-
${GEOMETRYCENTRAL_LIBRARY}
37+
${GEOMETRYCENTRAL_LIBRARIES}
3838
nlohmann_json::nlohmann_json
3939
${SW_PYTHON_LIBS}
4040
)

cmake/FindGEOMETRYCENTRAL.cmake

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
set(GEOMETRYCENTRAL_DIR "$ENV{GEOMETRYCENTRAL_DIR}" CACHE PATH "GEOMETRYCENTRAL root directory.")
32
message(STATUS "Looking for GEOMETRYCENTRAL in ${GEOMETRYCENTRAL_DIR}")
43

@@ -34,6 +33,70 @@ if(GEOMETRYCENTRAL_FOUND)
3433
message("-- Found GEOMETRYCENTRAL under ${GEOMETRYCENTRAL_INCLUDE_DIR}")
3534
set(GEOMETRYCENTRAL_INCLUDE_DIRS ${GEOMETRYCENTRAL_INCLUDE_DIR})
3635
set(GEOMETRYCENTRAL_LIBRARIES ${GEOMETRYCENTRAL_LIBRARY})
36+
37+
# Check if geometry-central was built with SuiteSparse support
38+
# by looking for CHOLMOD symbols in the static library
39+
if(UNIX AND NOT APPLE)
40+
execute_process(
41+
COMMAND nm "${GEOMETRYCENTRAL_LIBRARY}"
42+
COMMAND grep -q "cholmod"
43+
RESULT_VARIABLE CHOLMOD_CHECK
44+
OUTPUT_QUIET ERROR_QUIET
45+
)
46+
47+
if(CHOLMOD_CHECK EQUAL 0)
48+
message(STATUS "Geometry-central appears to use SuiteSparse, adding dependencies")
49+
50+
# Find SuiteSparse libraries
51+
find_library(CHOLMOD_LIB cholmod)
52+
find_library(SUITESPARSE_CONFIG_LIB suitesparseconfig)
53+
find_library(AMD_LIB amd)
54+
find_library(COLAMD_LIB colamd)
55+
find_library(CAMD_LIB camd)
56+
find_library(CCOLAMD_LIB ccolamd)
57+
find_library(METIS_LIB metis)
58+
59+
# Find BLAS and LAPACK
60+
find_package(BLAS)
61+
find_package(LAPACK)
62+
63+
# Build the complete library list
64+
set(SUITESPARSE_DEPS "")
65+
66+
if(CHOLMOD_LIB)
67+
list(APPEND SUITESPARSE_DEPS ${CHOLMOD_LIB})
68+
endif()
69+
if(SUITESPARSE_CONFIG_LIB)
70+
list(APPEND SUITESPARSE_DEPS ${SUITESPARSE_CONFIG_LIB})
71+
endif()
72+
if(AMD_LIB)
73+
list(APPEND SUITESPARSE_DEPS ${AMD_LIB})
74+
endif()
75+
if(COLAMD_LIB)
76+
list(APPEND SUITESPARSE_DEPS ${COLAMD_LIB})
77+
endif()
78+
if(CAMD_LIB)
79+
list(APPEND SUITESPARSE_DEPS ${CAMD_LIB})
80+
endif()
81+
if(CCOLAMD_LIB)
82+
list(APPEND SUITESPARSE_DEPS ${CCOLAMD_LIB})
83+
endif()
84+
if(METIS_LIB)
85+
list(APPEND SUITESPARSE_DEPS ${METIS_LIB})
86+
endif()
87+
if(BLAS_FOUND)
88+
list(APPEND SUITESPARSE_DEPS ${BLAS_LIBRARIES})
89+
endif()
90+
if(LAPACK_FOUND)
91+
list(APPEND SUITESPARSE_DEPS ${LAPACK_LIBRARIES})
92+
endif()
93+
94+
# Append dependencies to GEOMETRYCENTRAL_LIBRARIES
95+
list(APPEND GEOMETRYCENTRAL_LIBRARIES ${SUITESPARSE_DEPS})
96+
97+
message(STATUS "Added SuiteSparse dependencies: ${SUITESPARSE_DEPS}")
98+
endif()
99+
endif()
37100
endif(GEOMETRYCENTRAL_FOUND)
38101

39102
mark_as_advanced(GEOMETRYCENTRAL_LIBRARY GEOMETRYCENTRAL_INCLUDE_DIR)
@@ -50,4 +113,10 @@ if(GEOMETRYCENTRAL_FOUND AND NOT (TARGET geometrycentral))
50113
# add the transitive includes property
51114
set_target_properties(geometrycentral PROPERTIES
52115
INTERFACE_INCLUDE_DIRECTORIES "${GEOMETRYCENTRAL_INCLUDE_DIR}")
116+
117+
# Add interface link libraries for proper dependency propagation
118+
if(SUITESPARSE_DEPS)
119+
set_target_properties(geometrycentral PROPERTIES
120+
INTERFACE_LINK_LIBRARIES "${SUITESPARSE_DEPS}")
121+
endif()
53122
endif()

0 commit comments

Comments
 (0)