Skip to content

Commit

Permalink
Merge pull request #12295 from fwcd/linux-static-sleef-openmp
Browse files Browse the repository at this point in the history
FindSleef: Use OpenMP in static builds
  • Loading branch information
daschuer authored Nov 13, 2023
2 parents 8a5855c + ce9572c commit 04b3ebc
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
31 changes: 31 additions & 0 deletions cmake/modules/FindSleef.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions cmake/modules/Findrubberband.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 04b3ebc

Please sign in to comment.