Skip to content

Commit

Permalink
FindSleef: Use OpenMP in static builds
Browse files Browse the repository at this point in the history
  • Loading branch information
fwcd committed Nov 12, 2023
1 parent 30bca40 commit 941c765
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 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,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_CXX_FOUND)
set_property(TARGET Sleef::sleefdft APPEND PROPERTY INTERFACE_COMPILE_OPTIONS
${OpenMP_CXX_FLAGS}
)
endif()
endif()
endif()

if(NOT TARGET Sleef::sleef)
add_library(Sleef::sleef UNKNOWN IMPORTED)
set_target_properties(Sleef::sleef
Expand Down

0 comments on commit 941c765

Please sign in to comment.