update FindSuiteSparse module

quells a warning with newer cmake
This commit is contained in:
Arne Morten Kvarving 2022-05-11 10:08:46 +02:00
parent 33325c1690
commit ee5454dbc4

View File

@ -259,9 +259,9 @@ foreach (module IN LISTS SuiteSparse_FIND_COMPONENTS)
set (SuiteSparse_FOUND FALSE) set (SuiteSparse_FOUND FALSE)
# use empty string instead of zero, so it can be tested with #ifdef # use empty string instead of zero, so it can be tested with #ifdef
# as well as #if in the source code # as well as #if in the source code
set (HAVE_SUITESPARSE_${MODULE}_H "" CACHE INTERNAL "Is ${module} header present?") set (HAVE_SUITESPARSE_${MODULE}_H "" CACHE STRING "Is ${module} header present?")
else (NOT SuiteSparse_${MODULE}_FOUND) else (NOT SuiteSparse_${MODULE}_FOUND)
set (HAVE_SUITESPARSE_${MODULE}_H 1 CACHE INTERNAL "Is ${module} header present?") set (HAVE_SUITESPARSE_${MODULE}_H 1 CACHE STRING "Is ${module} header present?")
list (APPEND SuiteSparse_LIBRARIES "${${MODULE}_LIBRARIES}") list (APPEND SuiteSparse_LIBRARIES "${${MODULE}_LIBRARIES}")
list (APPEND SuiteSparse_LINKER_FLAGS "${${MODULE}_LINKER_FLAGS}") list (APPEND SuiteSparse_LINKER_FLAGS "${${MODULE}_LINKER_FLAGS}")
list (APPEND SuiteSparse_INCLUDE_DIRS "${${MODULE}_INCLUDE_DIRS}") list (APPEND SuiteSparse_INCLUDE_DIRS "${${MODULE}_INCLUDE_DIRS}")
@ -280,6 +280,32 @@ if (SuiteSparse_LIBRARIES)
list (REVERSE SuiteSparse_LIBRARIES) list (REVERSE SuiteSparse_LIBRARIES)
endif (SuiteSparse_LIBRARIES) endif (SuiteSparse_LIBRARIES)
if(SuiteSparse_FOUND)
if(NOT TARGET SuiteSparse::SuiteSparse)
add_library(SuiteSparse::SuiteSparse INTERFACE IMPORTED GLOBAL)
set_property(TARGET SuiteSparse::SuiteSparse PROPERTY
INTERFACE_INCLUDE_DIRECTORIES ${SuiteSparse_INCLUDE_DIRS})
if(config_LIBRARY)
set_property(TARGET SuiteSparse::SuiteSparse PROPERTY
INTERFACE_LINK_LIBRARIES ${config_LIBRARY})
endif()
endif()
foreach(_module ${SuiteSparse_MODULES})
string (TOUPPER ${_module} _MODULE)
if(SuiteSparse_${_MODULE}_FOUND)
if(NOT TARGET SuiteSparse::${_module})
message(STATUS "Creating target SuitSparse::${_module}")
add_library(SuiteSparse::${_module} UNKNOWN IMPORTED GLOBAL)
set_target_properties(SuiteSparse::${_module} PROPERTIES
IMPORTED_LOCATION ${${_MODULE}_LIBRARY}
INCLUDE_DIRECTORIES ${${_MODULE}_INCLUDE_DIRS}
INTERFACE_LINK_LIBRARIES "${config_LIBRARY}")
target_link_libraries(SuiteSparse::SuiteSparse
INTERFACE SuiteSparse::${_module})
endif()
endif()
endforeach(_module)
endif()
# print a message to indicate status of this package # print a message to indicate status of this package
include (FindPackageHandleStandardArgs) include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (SuiteSparse find_package_handle_standard_args (SuiteSparse