Skip to content

[llvm] [cmake] Use pkg-config to obtain libffi search hints #144221

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

Merged
merged 1 commit into from
Jun 14, 2025
Merged
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
9 changes: 6 additions & 3 deletions llvm/cmake/modules/FindFFI.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
# Additionally, the following import target will be defined:
# FFI::ffi

find_path(FFI_INCLUDE_DIRS ffi.h PATHS ${FFI_INCLUDE_DIR})
find_package(PkgConfig QUIET)
pkg_check_modules(PC_LIBFFI QUIET libffi)

find_path(FFI_INCLUDE_DIRS ffi.h PATHS ${FFI_INCLUDE_DIR} ${PC_LIBFFI_INCLUDE_DIRS})
if( EXISTS "${FFI_INCLUDE_DIRS}/ffi.h" )
set(FFI_HEADER ffi.h CACHE INTERNAL "")
set(HAVE_FFI_H 1 CACHE INTERNAL "")
Expand All @@ -35,8 +38,8 @@ else()
endif()
endif()

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

if(FFI_LIBRARIES)
include(CMakePushCheckState)
Expand Down
Loading