Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FindSleef: Use OpenMP in static builds #12295

Merged
merged 3 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cleaning up this logic also has the side effect of making this dependency slightly more elegant.

)
endif()
endif()
Expand Down
Loading