From 944319c7890d2c187ba09f35ce2bb30e84938d1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=BCtzel?= Date: Sat, 2 Dec 2023 17:37:19 +0100 Subject: [PATCH] SuiteSparse_config: Link to OpenMP target --- SuiteSparse_config/CMakeLists.txt | 14 +++++++------- .../Config/SuiteSparse_configConfig.cmake.in | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/SuiteSparse_config/CMakeLists.txt b/SuiteSparse_config/CMakeLists.txt index 45b5cce0fe..6b4374e373 100644 --- a/SuiteSparse_config/CMakeLists.txt +++ b/SuiteSparse_config/CMakeLists.txt @@ -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 ( ) @@ -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 + "$" ) 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: diff --git a/SuiteSparse_config/Config/SuiteSparse_configConfig.cmake.in b/SuiteSparse_config/Config/SuiteSparse_configConfig.cmake.in index 88b06f8691..bc12f41c68 100644 --- a/SuiteSparse_config/Config/SuiteSparse_configConfig.cmake.in +++ b/SuiteSparse_config/Config/SuiteSparse_configConfig.cmake.in @@ -35,6 +35,24 @@ 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 +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.