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

Work around missing GLOBAL option of find_package in older CMake versions #670

Merged
merged 1 commit into from
Jan 1, 2024
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
6 changes: 5 additions & 1 deletion CHOLMOD/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ if ( NOT SUITESPARSE_USE_OPENMP )
set ( CHOLMOD_USE_OPENMP "OFF" CACHE STRING "" FORCE )
endif ( )
if ( CHOLMOD_USE_OPENMP )
find_package ( OpenMP COMPONENTS C GLOBAL )
if ( CMAKE_VERSION VERSION_LESS 3.24 )
find_package ( OpenMP COMPONENTS C )
else ( )
find_package ( OpenMP COMPONENTS C GLOBAL )
endif ( )
else ( )
# OpenMP has been disabled
set ( OpenMP_C_FOUND OFF )
Expand Down
17 changes: 17 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,23 @@ else ( )
endif ( )
endif ( )


if ( CMAKE_VERSION VERSION_LESS 3.24 )
# work around missing GLOBAL option of find_package in older CMake versions
# If SuiteSparse is included as a sub-project in other projects, they might
# need to manually import the OpenMP targets for older CMake versions, too.
if ( "suitesparse_config" IN_LIST SUITESPARSE_ENABLE_PROJECTS
OR "cholmod" IN_LIST SUITESPARSE_ENABLE_PROJECTS
OR "graphblas" IN_LIST SUITESPARSE_ENABLE_PROJECTS
OR "paru" IN_LIST SUITESPARSE_ENABLE_PROJECTS )
find_package ( OpenMP COMPONENTS C )
endif ( )
if ( "paru" IN_LIST SUITESPARSE_ENABLE_PROJECTS )
find_package ( OpenMP COMPONENTS CXX )
endif ( )
endif ( )


#-------------------------------------------------------------------------------
# include selected projects
#-------------------------------------------------------------------------------
Expand Down
6 changes: 5 additions & 1 deletion GraphBLAS/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ if ( NOT SUITESPARSE_USE_OPENMP )
set ( GRAPHBLAS_USE_OPENMP "OFF" CACHE STRING "" FORCE )
endif ( )
if ( GRAPHBLAS_USE_OPENMP )
find_package ( OpenMP COMPONENTS C GLOBAL )
if ( CMAKE_VERSION VERSION_LESS 3.24 )
find_package ( OpenMP COMPONENTS C )
else ( )
find_package ( OpenMP COMPONENTS C GLOBAL )
endif ( )
else ( )
# OpenMP has been disabled.
set ( OpenMP_C_FOUND OFF )
Expand Down
6 changes: 5 additions & 1 deletion LAGraph/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,11 @@ if ( COVERAGE )
message ( STATUS "OpenMP disabled for test coverage" )
else ( )
if ( LAGRAPH_USE_OPENMP )
find_package ( OpenMP COMPONENTS C GLOBAL )
if ( CMAKE_VERSION VERSION_LESS 3.24 )
find_package ( OpenMP COMPONENTS C )
else ( )
find_package ( OpenMP COMPONENTS C GLOBAL )
endif ( )
if ( OpenMP_C_FOUND AND BUILD_STATIC_LIBS )
list ( APPEND LAGRAPH_STATIC_LIBS ${OpenMP_C_LIBRARIES} )
endif ( )
Expand Down
6 changes: 5 additions & 1 deletion ParU/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ endif ( )

if ( PARU_USE_OPENMP )
# OpenMP 4.5 or later is required
find_package ( OpenMP COMPONENTS C CXX GLOBAL )
if ( CMAKE_VERSION VERSION_LESS 3.24 )
find_package ( OpenMP COMPONENTS C CXX )
else ( )
find_package ( OpenMP COMPONENTS C CXX GLOBAL )
endif ( )
if ( OpenMP_CXX_FOUND AND OpenMP_C_FOUND )
set ( PARU_HAS_OPENMP ON )
if (( OpenMP_CXX_VERSION VERSION_LESS 4.5 ) OR
Expand Down
11 changes: 0 additions & 11 deletions SPQR/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -198,17 +198,6 @@ else ( )
set ( SPQR_CFLAGS "" )
endif ( )

# OpenMP:
if ( OpenMP_CXX_FOUND )
if ( BUILD_SHARED_LIBS )
target_link_libraries ( SPQR PRIVATE OpenMP::OpenMP_CXX )
endif ( )
if ( BUILD_STATIC_LIBS )
target_link_libraries ( SPQR_static PRIVATE OpenMP::OpenMP_CXX )
list ( APPEND SPQR_STATIC_LIBS ${OpenMP_CXX_LIBRARIES} )
endif ( )
endif ( )

# libm:
if ( NOT WIN32 )
if ( BUILD_SHARED_LIBS )
Expand Down
6 changes: 5 additions & 1 deletion SuiteSparse_config/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ if ( NOT SUITESPARSE_USE_OPENMP )
set ( SUITESPARSE_CONFIG_USE_OPENMP "OFF" CACHE STRING "" FORCE )
endif ( )
if ( SUITESPARSE_CONFIG_USE_OPENMP OR SUITESPARSE_USE_OPENMP )
find_package ( OpenMP COMPONENTS C GLOBAL )
if ( CMAKE_VERSION VERSION_LESS 3.24 )
find_package ( OpenMP COMPONENTS C )
else ( )
find_package ( OpenMP COMPONENTS C GLOBAL )
endif ( )
else ( )
# OpenMP has been disabled
set ( OpenMP_C_FOUND OFF )
Expand Down
Loading