From 8a6fdce45e440760d45fab690297301edf563cb6 Mon Sep 17 00:00:00 2001 From: fwcd Date: Sun, 12 Nov 2023 16:53:39 +0000 Subject: [PATCH] FindSleef: Use OpenMP in static builds --- cmake/modules/FindSleef.cmake | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/cmake/modules/FindSleef.cmake b/cmake/modules/FindSleef.cmake index 9f54fcad4057..97193082aee4 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,26 @@ 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) + find_package(OpenMP) + if(OpenMP_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