8000 On Linux, uses external libffi for python >= 3.7 · jcfr/python-cmake-buildsystem@f8c152d · GitHub
[go: up one dir, main page]

Skip to content

Commit f8c152d

Browse files
Dan Deesjcfr
authored andcommitted
On Linux, uses external libffi for python >= 3.7
Since python/cpython@f40d4ddff (Closes python/cpython#27979: Remove bundled copy of libffi), external version of libffi is required on linux.
1 parent 16ec310 commit f8c152d

File tree

1 file changed

+49
-36
lines changed

1 file changed

+49
-36
lines changed

cmake/extensions/CMakeLists.txt

Lines changed: 49 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -338,47 +338,60 @@ else()
338338
DEFINITIONS MACOSX
339339
)
340340
else()
341-
set(_libffi_sources)
342-
set(_libffi_include_dirs)
343341
if(PY_VERSION VERSION_LESS "3.7")
344-
if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64")
345-
set(_libffi_system_extra_src
346-
_ctypes/libffi/src/${_libffi_system_dir}/ffi64.c
347-
_ctypes/libffi/src/${_libffi_system_dir}/unix64.S
342+
set(_libffi_sources)
343+
set(_libffi_include_dirs)
344+
if(PY_VERSION VERSION_LESS "3.7")
345+
if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64")
346+
set(_libffi_system_extra_src
347+
_ctypes/libffi/src/${_libffi_system_dir}/ffi64.c
348+
_ctypes/libffi/src/${_libffi_system_dir}/unix64.S
349+
)
350+
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "i686")
351+
set(_libffi_system_extra_src
352+
_ctypes/libffi/src/${_libffi_system_dir}/win32.S
353+
)
354+
endif()
355+
# To facilitate an eventual contribution of the configuration
356+
# of fficonfig.h to the upstream project, corresponding tests
357+
# in ConfigureChecks.cmake are labeled using this convention:
358+
# * "libffi specific"
359+
# * "libffi and cpython"
360+
set(LIBFFI_VERSION "3.1")
361+
configure_file(
362+
${PROJECT_SOURCE_DIR}/cmake/fficonfig.h.in
363+
${INCLUDE_BUILD_DIR}/fficonfig.h
348364
)
349-
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "i686")
350-
set(_libffi_system_extra_src
351-
_ctypes/libffi/src/${_libffi_system_dir}/win32.S
365+
set(_libffi_sources
366+
_ctypes/libffi/src/closures.c
367+
_ctypes/libffi/src/prep_cif.c
368+
_ctypes/libffi/src/${_libffi_system_dir}/ffi.c
369+
_ctypes/libffi/src/${_libffi_system_dir}/sysv.S
370+
${_libffi_system_extra_src}
371+
)
372+
set(_libffi_include_dirs
373+
INCLUDEDIRS ${SRC_DIR}/Modules/_ctypes/libffi/src/${_libffi_system_dir}
374+
${SRC_DIR}/Modules/_ctypes/libffi/include
375+
${INCLUDE_BUILD_DIR} # For fficonfig.h
376+
${PROJECT_SOURCE_DIR}/cmake # For ffi.h
352377
)
353378
endif()
354-
# To facilitate an eventual contribution of the configuration
355-
# of fficonfig.h to the upstream project, corresponding tests
356-
# in ConfigureChecks.cmake are labeled using this convention:
357-
# * "libffi specific"
358-
# * "libffi and cpython"
359-
set(LIBFFI_VERSION "3.1")
360-
configure_file(
361-
${PROJECT_SOURCE_DIR}/cmake/fficonfig.h.in
362-
${INCLUDE_BUILD_DIR}/fficonfig.h
363-
)
364-
set(_libffi_sources
365-
_ctypes/libffi/src/closures.c
366-
_ctypes/libffi/src/prep_cif.c
367-
_ctypes/libffi/src/${_libffi_system_dir}/ffi.c
368-
_ctypes/libffi/src/${_libffi_system_dir}/sysv.S
369-
${_libffi_system_extra_src}
370-
)
371-
set(_libffi_include_dirs
372-
INCLUDEDIRS ${SRC_DIR}/Modules/_ctypes/libffi/src/${_libffi_system_dir}
373-
${SRC_DIR}/Modules/_ctypes/libffi/include
374-
${INCLUDE_BUILD_DIR} # For fficonfig.h
375-
${PROJECT_SOURCE_DIR}/cmake # For ffi.h
376-
)
379+
add_python_extension(_ctypes
380+
SOURCES ${ctypes_COMMON_SOURCES} ${_libffi_sources}
381+
${_libffi_include_dirs}
382+
)
383+
384+
else()
385+
# get libffi
386+
find_path(FFI_INCLUDE_DIR ffi.h)
387+
find_library(FFI_LIBRARY NAMES ffi libffi)
388+
add_python_extension(_ctypes
389+
REQUIRES FFI_INCLUDE_DIR FFI_LIBRARY
390+
SOURCES ${ctypes_COMMON_SOURCES}
391+
INCLUDEDIRS ${FFI_INCLUDE_DIR}
392+
LIBRARIES ${FFI_LIBRARY}
393+
)
377394
endif()
378-
add_python_extension(_ctypes
379-
SOURCES ${ctypes_COMMON_SOURCES} ${_libffi_sources}
380-
${_libffi_include_dirs}
381-
)
382395
endif()
383396
endif()
384397

0 commit comments

Comments
 (0)