Skip to content
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
14 changes: 12 additions & 2 deletions llvm/cmake/modules/FindFFI.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# FFI_FOUND
# FFI_INCLUDE_DIRS
# FFI_LIBRARIES
# FFI_STATIC_LIBRARIES
# HAVE_FFI_CALL
#
# HAVE_FFI_H or HAVE_FFI_FFI_H is defined depending on the ffi.h include path.
Expand All @@ -34,7 +35,8 @@ else()
endif()
endif()

find_library(FFI_LIBRARIES ffi PATHS ${FFI_LIBRARY_DIR})
find_library(FFI_LIBRARIES NAMES ffi PATHS ${FFI_LIBRARY_DIR})
find_library(FFI_STATIC_LIBRARIES NAMES libffi.a PATHS ${FFI_LIBRARY_DIR})

if(FFI_LIBRARIES)
include(CMakePushCheckState)
Expand Down Expand Up @@ -76,18 +78,26 @@ find_package_handle_standard_args(FFI
${required_includes}
HAVE_FFI_CALL)
mark_as_advanced(FFI_LIBRARIES
FFI_STATIC_LIBRARIES
FFI_INCLUDE_DIRS
HAVE_FFI_CALL
FFI_HEADER
HAVE_FFI_H
HAVE_FFI_FFI_H)

if(FFI_FOUND)
if(NOT TARGET FFI::ffi)
if(NOT TARGET FFI::ffi AND FFI_LIBRARIES)
add_library(FFI::ffi UNKNOWN IMPORTED)
set_target_properties(FFI::ffi PROPERTIES IMPORTED_LOCATION "${FFI_LIBRARIES}")
if(FFI_INCLUDE_DIRS)
set_target_properties(FFI::ffi PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFI_INCLUDE_DIRS}")
endif()
endif()
if(NOT TARGET FFI::ffi_static AND FFI_STATIC_LIBRARIES)
add_library(FFI::ffi_static UNKNOWN IMPORTED)
set_target_properties(FFI::ffi_static PROPERTIES IMPORTED_LOCATION "${FFI_STATIC_LIBRARIES}")
if(FFI_INCLUDE_DIRS)
set_target_properties(FFI::ffi_static PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFI_INCLUDE_DIRS}")
endif()
endif()
endif()
13 changes: 8 additions & 5 deletions openmp/libomptarget/plugins-nextgen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,14 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "${tmachine}$")
)

if(LIBOMPTARGET_DEP_LIBFFI_FOUND)
libomptarget_say("Building ${tmachine_libname} plugin linked with libffi")
target_link_libraries("omptarget.rtl.${tmachine_libname}" PRIVATE
${FFI_LIBRARIES})
target_include_directories("omptarget.rtl.${tmachine_libname}" PRIVATE
${FFI_INCLUDE_DIRS})
libomptarget_say("Building ${tmachine_libname} plugin linked with libffi")
if(FFI_STATIC_LIBRARIES)
target_link_libraries(
"omptarget.rtl.${tmachine_libname}" PRIVATE FFI::ffi_static)
else()
target_link_libraries(
"omptarget.rtl.${tmachine_libname}" PRIVATE FFI::ffi)
endif()
else()
libomptarget_say("Building ${tmachine_libname} plugie for dlopened libffi")
target_sources("omptarget.rtl.${tmachine_libname}" PRIVATE
Expand Down