Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CHOLMOD: Add dependency to system libraries after SuiteSparse libraries #555

Merged
merged 2 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 60 additions & 63 deletions CHOLMOD/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -357,40 +357,6 @@ if ( BUILD_STATIC_LIBS )
endif ( )
endif ( )

# OpenMP:
if ( OPENMP_FOUND )
message ( STATUS "OpenMP C libraries: ${OpenMP_C_LIBRARIES} ")
message ( STATUS "OpenMP C include: ${OpenMP_C_INCLUDE_DIRS} ")
message ( STATUS "OpenMP C flags: ${OpenMP_C_FLAGS} ")
if ( BUILD_SHARED_LIBS )
target_link_libraries ( CHOLMOD PRIVATE ${OpenMP_C_LIBRARIES} )
endif ( )
if ( BUILD_STATIC_LIBS )
target_link_libraries ( CHOLMOD_static PUBLIC ${OpenMP_C_LIBRARIES} )
list ( APPEND CHOLMOD_STATIC_LIBS ${OpenMP_C_LIBRARIES} )
endif ( )
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS} " )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_C_FLAGS} " )
include_directories ( ${OpenMP_C_INCLUDE_DIRS} )
else ( )
# to fix METIS: use threadprivate variables for GKRAND instead globals,
# so multiple user threads can call cholmod_analyze in parallel on
# different matrices, and avoid global locking of the system rand.
include ( SuiteSparse__thread )
endif ( )

# libm:
if ( NOT WIN32 )
if ( BUILD_SHARED_LIBS )
target_link_libraries ( CHOLMOD PRIVATE m )
endif ( )
if ( BUILD_STATIC_LIBS )
list ( APPEND CHOLMOD_STATIC_LIBS "m" )
target_link_libraries ( CHOLMOD_static PUBLIC m )
endif ( )
endif ( )
list ( APPEND CHOLMOD_STATIC_LIBS "m" )

# AMD:
if ( BUILD_SHARED_LIBS )
target_link_libraries ( CHOLMOD PRIVATE SuiteSparse::AMD )
Expand All @@ -415,35 +381,6 @@ if ( BUILD_STATIC_LIBS )
endif ( )
endif ( )

# BLAS and LAPACK: for the Supernodal Module
if ( NOT NSUPERNODAL )
# LAPACK:
message ( STATUS "LAPACK libraries: ${LAPACK_LIBRARIES} ")
message ( STATUS "LAPACK include: ${LAPACK_INCLUDE_DIRS} ")
message ( STATUS "LAPACK linker flags: ${LAPACK_LINKER_FLAGS} ")
if ( BUILD_SHARED_LIBS )
target_link_libraries ( CHOLMOD PRIVATE ${LAPACK_LIBRARIES} )
endif ( )
if ( BUILD_STATIC_LIBS )
list ( APPEND CHOLMOD_STATIC_LIBS ${LAPACK_LIBRARIES} )
target_link_libraries ( CHOLMOD_static PUBLIC ${LAPACK_LIBRARIES} )
endif ( )
include_directories ( ${LAPACK_INCLUDE_DIR} )

# BLAS:
message ( STATUS "BLAS libraries: ${BLAS_LIBRARIES} ")
message ( STATUS "BLAS include: ${BLAS_INCLUDE_DIRS} ")
message ( STATUS "BLAS linker flags: ${BLAS_LINKER_FLAGS} ")
if ( BUILD_SHARED_LIBS )
target_link_libraries ( CHOLMOD PRIVATE ${BLAS_LIBRARIES} )
endif ( )
if ( BUILD_STATIC_LIBS )
list ( APPEND CHOLMOD_STATIC_LIBS ${BLAS_LIBRARIES} )
target_link_libraries ( CHOLMOD_static PUBLIC ${BLAS_LIBRARIES} )
endif ( )
include_directories ( ${BLAS_INCLUDE_DIRS} )
endif ( )

# CAMD and CCOLAMD:
if ( NOT NCAMD )
if ( BUILD_SHARED_LIBS )
Expand Down Expand Up @@ -471,6 +408,66 @@ if ( NOT NCAMD )
endif ( )
endif ( )

# OpenMP:
if ( OPENMP_C_FOUND )
message ( STATUS "OpenMP C libraries: ${OpenMP_C_LIBRARIES}" )
message ( STATUS "OpenMP C include: ${OpenMP_C_INCLUDE_DIRS}" )
message ( STATUS "OpenMP C flags: ${OpenMP_C_FLAGS}" )
if ( BUILD_SHARED_LIBS )
target_link_libraries ( CHOLMOD PRIVATE OpenMP::OpenMP_C )
endif ( )
if ( BUILD_STATIC_LIBS )
target_link_libraries ( CHOLMOD_static PUBLIC OpenMP::OpenMP_C )
list ( APPEND CHOLMOD_STATIC_LIBS ${OpenMP_C_LIBRARIES} )
endif ( )
else ( )
# to fix METIS: use threadprivate variables for GKRAND instead globals,
# so multiple user threads can call cholmod_analyze in parallel on
# different matrices, and avoid global locking of the system rand.
include ( SuiteSparse__thread )
endif ( )

# libm:
if ( NOT WIN32 )
if ( BUILD_SHARED_LIBS )
target_link_libraries ( CHOLMOD PRIVATE m )
endif ( )
if ( BUILD_STATIC_LIBS )
list ( APPEND CHOLMOD_STATIC_LIBS "m" )
target_link_libraries ( CHOLMOD_static PUBLIC m )
endif ( )
endif ( )
list ( APPEND CHOLMOD_STATIC_LIBS "m" )

# BLAS and LAPACK: for the Supernodal Module
if ( NOT NSUPERNODAL )
# LAPACK:
message ( STATUS "LAPACK libraries: ${LAPACK_LIBRARIES}" )
message ( STATUS "LAPACK include: ${LAPACK_INCLUDE_DIRS}" )
message ( STATUS "LAPACK linker flags: ${LAPACK_LINKER_FLAGS}" )
if ( BUILD_SHARED_LIBS )
target_link_libraries ( CHOLMOD PRIVATE ${LAPACK_LIBRARIES} )
endif ( )
if ( BUILD_STATIC_LIBS )
list ( APPEND CHOLMOD_STATIC_LIBS ${LAPACK_LIBRARIES} )
target_link_libraries ( CHOLMOD_static PUBLIC ${LAPACK_LIBRARIES} )
endif ( )
include_directories ( ${LAPACK_INCLUDE_DIR} )

# BLAS:
message ( STATUS "BLAS libraries: ${BLAS_LIBRARIES}" )
message ( STATUS "BLAS include: ${BLAS_INCLUDE_DIRS}" )
message ( STATUS "BLAS linker flags: ${BLAS_LINKER_FLAGS}" )
if ( BUILD_SHARED_LIBS )
target_link_libraries ( CHOLMOD PRIVATE ${BLAS_LIBRARIES} )
endif ( )
if ( BUILD_STATIC_LIBS )
list ( APPEND CHOLMOD_STATIC_LIBS ${BLAS_LIBRARIES} )
target_link_libraries ( CHOLMOD_static PUBLIC ${BLAS_LIBRARIES} )
endif ( )
include_directories ( ${BLAS_INCLUDE_DIRS} )
endif ( )

# METIS and the Partition module:
if ( NOT NPARTITION )
include_directories ( SuiteSparse_metis/GKlib )
Expand Down
13 changes: 13 additions & 0 deletions CHOLMOD/Config/CHOLMODConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,19 @@ if ( NOT _dependencies_found )
return ( )
endif ( )

# Look for OpenMP
if ( NOT @NOPENMP@ AND NOT OpenMP_C_FOUND )
find_dependency ( OpenMP )
if ( NOT OpenMP_C_FOUND )
set ( _dependencies_found OFF )
endif ( )
endif ( )

if ( NOT _dependencies_found )
set ( CHOLMOD_FOUND OFF )
return ( )
endif ( )

# Look for SuiteSparse_config, COLAMD, and AMD targets
if ( @SUITESPARSE_IN_BUILD_TREE@ )
if ( NOT TARGET SuiteSparse::SuiteSparseConfig )
Expand Down