Вопрос

I require libffi to build my C++ project. The problem is that there exists no premade script to find libffi and ffi.h is located at strange locations depending on the version of the library and the Linux distribution.

The is my attempt:

# Look for the header file.
Find_Path(LIBFFI_INCLUDE_DIR NAMES ffi.h)
Mark_As_Advanced(LIBFFI_INCLUDE_DIR)

# Look for the library.
Find_Library(LIBFFI_LIBRARY NAMES
    ffi
)
Mark_As_Advanced(LIBFFI_LIBRARY)

# handle the QUIETLY and REQUIRED arguments and set LIBFFI_FOUND to TRUE
# if all listed variables are TRUE
Include(FindPackageHandleStandardArgs)
Find_Package_Handle_Standard_Args(libffi DEFAULT_MSG
    LIBFFI_LIBRARY LIBFFI_INCLUDE_DIR)

If(LIBFFI_FOUND)
  SET(LIBFFI_LIBRARIES ${LIBFFI_LIBRARY})
  SET(LIBFFI_INCLUDE_DIRS ${LIBFFI_INCLUDE_DIR})
Endif(LIBFFI_FOUND)

But it obviously doesn't work because Find_Path() doesn't search recursivly. How to do it better?

I tried to use CMake's pkg-config module, but pkg-config can't find it either.

[ethon@Fleckstation Paper]$ pkg-config --cflags libffi Package libffi was not found in the pkg-config search path. Perhaps you should add the directory containing `libffi.pc' to the PKG_CONFIG_PATH environment variable No package 'libffi' found

Thanks!

Это было полезно?

Решение

I am the author of libffi. pkg-config should find it. What system are you working on? Do you have a libffi.pc file anywhere on your system?

Другие советы

Take a look at how it's implemented in LLVM project. Search for if( LLVM_ENABLE_FFI ) line.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top