Skip to content

Commit

Permalink
SuiteSparse_config: Link to OpenMP target
Browse files Browse the repository at this point in the history
  • Loading branch information
mmuetzel committed Dec 2, 2023
1 parent 98656e6 commit 6e548c8
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 7 deletions.
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ foreach ( proj ${SUITESPARSE_ENABLE_PROJECTS} )
endif ( )
endforeach ( )

# Use OpenMP in CHOLMOD, GraphBLAS, LAGraph, and SuiteSparse_config
option ( NOPENMP "ON: do not use OpenMP. OFF (default): use OpenMP" OFF )

# CHOLMOD options affecting dependencies
option ( NCAMD "ON: do not use CAMD/CCOLAMD. OFF (default): use CAMD/CCOLAMD" OFF )

Expand Down Expand Up @@ -96,6 +99,14 @@ set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}

include ( SuiteSparsePolicy )

if ( NOPENMP )
# OpenMP has been disabled
message ( STATUS "OpenMP disabled" )
set ( OpenMP_C_FOUND OFF )
else ( )
find_package ( OpenMP )
endif ( )

#-------------------------------------------------------------------------------
# check/add project dependencies
#-------------------------------------------------------------------------------
Expand Down
14 changes: 7 additions & 7 deletions SuiteSparse_config/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ endif ( )
# find library dependencies
#-------------------------------------------------------------------------------

option ( NOPENMP "ON: do not use OpenMP. OFF (default): use OpenMP" off )
option ( NOPENMP "ON: do not use OpenMP. OFF (default): use OpenMP" OFF )
if ( NOPENMP )
# OpenMP has been disabled
message ( STATUS "OpenMP disabled" )
set ( OPENMP_FOUND false )
set ( OpenMP_C_FOUND OFF )
else ( )
find_package ( OpenMP )
endif ( )
Expand Down Expand Up @@ -139,18 +139,18 @@ if ( NOT WIN32 )
endif ( )

# OpenMP:
if ( OPENMP_FOUND )
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 ( SuiteSparseConfig PRIVATE ${OpenMP_C_LIBRARIES} )
target_link_libraries ( SuiteSparseConfig PRIVATE OpenMP::OpenMP_C )
target_include_directories ( SuiteSparseConfig PUBLIC
"$<TARGET_PROPERTY:OpenMP::OpenMP_C,INTERFACE_INCLUDE_DIRECTORIES>" )
endif ( )
if ( BUILD_STATIC_LIBS )
target_link_libraries ( SuiteSparseConfig_static PUBLIC ${OpenMP_C_LIBRARIES} )
target_link_libraries ( SuiteSparseConfig_static PUBLIC OpenMP::OpenMP_C )
endif ( )
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS} " )
include_directories ( ${OpenMP_C_INCLUDE_DIRS} )
endif ( )

# BLAS:
Expand Down
19 changes: 19 additions & 0 deletions SuiteSparse_config/Config/SuiteSparse_configConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,25 @@ set ( SUITESPARSE_CONFIG_VERSION_MINOR @SUITESPARSE_VERSION_MINOR@ )
set ( SUITESPARSE_CONFIG_VERSION_PATCH @SUITESPARSE_VERSION_SUB@ )
set ( SUITESPARSE_CONFIG_VERSION "@SUITESPARSE_VERSION_MAJOR@.@SUITESPARSE_VERSION_MINOR@.@SUITESPARSE_VERSION_SUB@" )

# Check for dependent targets
include ( CMakeFindDependencyMacro )
set ( _dependencies_found ON )

# Look for OpenMP
message ( STATUS "OpenMP_C_FOUND: ${OpenMP_C_FOUND}" )
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 ( SuiteSparse_config_FOUND OFF )
return ( )
endif ( )


include ( ${CMAKE_CURRENT_LIST_DIR}/SuiteSparse_configTargets.cmake )

# The following is only for backward compatibility with FindSuiteSparse_config.
Expand Down

0 comments on commit 6e548c8

Please sign in to comment.