diff --git a/cmake/modules/FindSleef.cmake b/cmake/modules/FindSleef.cmake index 9f54fcad405..85491403607 100644 --- a/cmake/modules/FindSleef.cmake +++ b/cmake/modules/FindSleef.cmake @@ -43,6 +43,8 @@ The following cache variables may also be set: #]=======================================================================] +include(IsStaticLibrary) + find_package(PkgConfig QUIET) if(PkgConfig_FOUND) pkg_check_modules(PC_Sleef QUIET sleef) @@ -59,6 +61,11 @@ find_library(Sleef_LIBRARY PATHS ${PC_Sleef_LIBRARY_DIRS}) mark_as_advanced(Sleef_LIBRARY) +find_library(SleefDFT_LIBRARY + NAMES sleefdft + PATHS ${PC_Sleef_LIBRARY_DIRS}) +mark_as_advanced(SleefDFT_LIBRARY) + if(DEFINED PC_Sleef_VERSION AND NOT PC_Sleef_VERSION STREQUAL "") set(Sleef_VERSION "${PC_Sleef_VERSION}") else() @@ -100,6 +107,30 @@ if(Sleef_FOUND) set(Sleef_INCLUDE_DIRS "${Sleef_INCLUDE_DIR}") set(Sleef_DEFINITIONS ${PC_Sleef_CFLAGS_OTHER}) + if(SleefDFT_LIBRARY AND NOT TARGET Sleef::sleefdft) + add_library(Sleef::sleefdft UNKNOWN IMPORTED) + set_target_properties(Sleef::sleefdft + PROPERTIES + IMPORTED_LOCATION "${SleefDFT_LIBRARY}" + INTERFACE_COMPILE_OPTIONS "${PC_Sleef_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${Sleef_INCLUDE_DIR}" + ) + + is_static_library(SleefDFT_IS_STATIC Sleef::sleefdft) + if(SleefDFT_IS_STATIC) + set_property(TARGET Sleef::sleefdft APPEND PROPERTY INTERFACE_LINK_LIBRARIES + Sleef::sleef + ) + + find_package(OpenMP) + if(OpenMP_CXX_FOUND) + set_property(TARGET Sleef::sleefdft APPEND PROPERTY INTERFACE_LINK_LIBRARIES + OpenMP::OpenMP_CXX + ) + endif() + endif() + endif() + if(NOT TARGET Sleef::sleef) add_library(Sleef::sleef UNKNOWN IMPORTED) set_target_properties(Sleef::sleef diff --git a/cmake/modules/Findrubberband.cmake b/cmake/modules/Findrubberband.cmake index 66ea1242301..fd0ffa8fdda 100644 --- a/cmake/modules/Findrubberband.cmake +++ b/cmake/modules/Findrubberband.cmake @@ -99,10 +99,9 @@ if(rubberband_FOUND) endif() find_package(Sleef) if (Sleef_FOUND) - find_library(sleefdft_path sleefdft REQUIRED) set_property(TARGET rubberband::rubberband APPEND PROPERTY INTERFACE_LINK_LIBRARIES Sleef::sleef - ${sleefdft_path} + Sleef::sleefdft ) endif() endif()