Skip to content
Snippets Groups Projects
Commit dfd91208 authored by Christoph Grüninger's avatar Christoph Grüninger
Browse files

[cmake] Introduce targets for Find SuperLU

parent 8f458c76
No related branches found
No related tags found
No related merge requests found
......@@ -13,26 +13,20 @@
# set HAVE_SUPERLU for config.h
set(HAVE_SUPERLU ${SUPERLU_FOUND})
# register all superlu related flags
# register all SuperLU related flags
if(SUPERLU_FOUND)
dune_register_package_flags(COMPILE_DEFINITIONS "ENABLE_SUPERLU=1"
LIBRARIES "${SUPERLU_DUNE_LIBRARIES}"
INCLUDE_DIRS "${SUPERLU_INCLUDE_DIRS}")
dune_register_package_flags(
COMPILE_DEFINITIONS "ENABLE_SUPERLU=1"
LIBRARIES SuperLU::SuperLU)
endif()
# Provide function to set target properties for linking to SuperLU
function(add_dune_superlu_flags)
function(add_dune_superlu_flags _targets)
if(SUPERLU_FOUND)
cmake_parse_arguments(_add_superlu "OBJECT" "" "" ${ARGN})
foreach(_target ${_add_superlu_UNPARSED_ARGUMENTS})
if(NOT _add_superlu_OBJECT)
target_link_libraries(${_target} ${SUPERLU_DUNE_LIBRARIES})
endif()
get_target_property(_props ${_target} COMPILE_FLAGS)
string(REPLACE "_props-NOTFOUND" "" _props "${_props}")
set_target_properties(${_target} PROPERTIES COMPILE_FLAGS
"${_props} ${SUPERLU_DUNE_COMPILE_FLAGS} -DENABLE_SUPERLU=1")
foreach(_target ${_targets})
target_link_libraries(${_target} SuperLU::SuperLU)
target_compile_definitions(${_target} PUBLIC ENABLE_SUPERLU=1)
endforeach()
endif(SUPERLU_FOUND)
endif()
endfunction(add_dune_superlu_flags)
......@@ -13,9 +13,19 @@
#
# :code:`SUPERLU_INCLUDE_DIRS`
# Path to the SuperLU include dirs.
# .. deprecated:: 2.8
# Use target SuperLU::SuperLU instead.
#
# :code:`SUPERLU_LIBRARIES`
# Name to the SuperLU library.
# .. deprecated:: 2.8
# Use target SuperLU::SuperLU instead.
#
#
# This module provides the following imported targets, if found:
#
# :code:`SuperLU:SuperLU`
# Library and include directories for the found SuperLU.
#
#
# This module provides the following imported targets, if found:
......@@ -99,8 +109,24 @@ find_package_handle_standard_args(
mark_as_advanced(SUPERLU_INCLUDE_DIR SUPERLU_LIBRARY SUPERLU_MIN_VERSION_5)
# if both headers and library are found, store results
if(SUPERLU_FOUND)
if(NOT TARGET SuperLU::SuperLU)
add_library(SuperLU::SuperLU UNKNOWN IMPORTED)
set_target_properties(SuperLU::SuperLU
PROPERTIES
IMPORTED_LOCATION ${SUPERLU_LIBRARY}
INTERFACE_INCLUDE_DIRECTORIES "${SUPERLU_INCLUDE_DIR}")
# Link BLAS library
if(TARGET BLAS::BLAS)
target_link_libraries(SuperLU::SuperLU
INTERFACE BLAS::BLAS)
else()
target_link_libraries(SuperLU::SuperLU
INTERFACE ${BLAS_LINKER_FLAGS} ${BLAS_LIBRARIES})
endif()
endif()
set(SUPERLU_INCLUDE_DIRS ${SUPERLU_INCLUDE_DIR})
set(SUPERLU_LIBRARIES ${SUPERLU_LIBRARY})
# log result
......@@ -112,7 +138,7 @@ if(SUPERLU_FOUND)
CACHE STRING "Compile flags used by DUNE when compiling SuperLU programs")
set(SUPERLU_DUNE_LIBRARIES ${SUPERLU_LIBRARIES} ${BLAS_LIBRARIES}
CACHE STRING "Libraries used by DUNE when linking SuperLU programs")
else(SUPERLU_FOUND)
else()
# log errornous result
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determining location of SuperLU failed:\n"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment