|
1 | 1 | # CMakeList.txt - Copyright (c) 2022 Ore Richard Muyiwa |
2 | 2 | # https://github.com/blade-lang/ffi |
3 | | -# Portions - Copyright (c) 2023 Kritzel Kratzel |
| 3 | +# Portions - Copyright (c) 2023-2026 The OneLuaPro project authors. |
4 | 4 |
|
5 | 5 | # Permission is hereby granted, free of charge, to any person obtaining |
6 | 6 | # a copy of this software and associated documentation files (the |
|
40 | 40 |
|
41 | 41 | cmake_minimum_required(VERSION 3.23) |
42 | 42 |
|
43 | | -# ------------------------------------------------------------------------------ |
44 | | -# find liblua installation and version info |
45 | | -# if(NOT LUA_HINTS) |
46 | | -# if(WIN32) |
47 | | -# set(LUA_HINTS "c:/Apps") |
48 | | -# endif() |
49 | | -# endif() |
50 | | -# find_package(liblua REQUIRED CONFIG HINTS ${LUA_HINTS}) |
51 | | -# if(liblua_FOUND) |
52 | | -# message(STATUS "liblua install prefix : ${LIBLUA_INSTALLDIR}") |
53 | | -# else() |
54 | | -# message(FATAL_ERROR "Unable to find liblua version ${liblua_VERSION}.") |
55 | | -# endif() |
56 | 43 | set(INSTALL_DIRECTORY ${CMAKE_INSTALL_PREFIX}) |
57 | 44 |
|
| 45 | +# ------------------------------------------------------------------------------ |
| 46 | +# Extract version number from configure.ac |
| 47 | +set(CONFIGURE_AC_PATH "${CMAKE_CURRENT_SOURCE_DIR}/configure.ac") |
| 48 | +if(EXISTS "${CONFIGURE_AC_PATH}") |
| 49 | + file(STRINGS "${CONFIGURE_AC_PATH}" FFI_VERSION_STR_LINE REGEX "^FFI_VERSION_STRING=") |
| 50 | + file(STRINGS "${CONFIGURE_AC_PATH}" FFI_VERSION_NUM_LINE REGEX "^FFI_VERSION_NUMBER=") |
| 51 | + if(FFI_VERSION_STR_LINE MATCHES "FFI_VERSION_STRING=\"([^\"]+)\"") |
| 52 | + set(FFI_VERSION_STRING "${CMAKE_MATCH_1}") |
| 53 | + message(STATUS "FFI_VERSION_STRING = ${FFI_VERSION_STRING}") |
| 54 | + else() |
| 55 | + message(FATAL_ERROR "Could not read FFI_VERSION_STRING from configure.ac") |
| 56 | + endif() |
| 57 | + if(FFI_VERSION_NUM_LINE MATCHES "FFI_VERSION_NUMBER=([0-9]+)") |
| 58 | + set(FFI_VERSION_NUMBER "${CMAKE_MATCH_1}") |
| 59 | + message(STATUS "FFI_VERSION_NUMBER = ${FFI_VERSION_NUMBER}") |
| 60 | + else() |
| 61 | + message(FATAL_ERROR "Could not read FFI_VERSION_NUMBER from configure.ac") |
| 62 | + endif() |
| 63 | +else() |
| 64 | + message(FATAL_ERROR "Could not read version info from configure.ac") |
| 65 | +endif() |
| 66 | + |
58 | 67 | # ------------------------------------------------------------------------------ |
59 | 68 | # Project defintion |
60 | 69 | project(libffi |
61 | 70 | LANGUAGES C ASM_MASM |
62 | | - VERSION 3.4.4 |
| 71 | + VERSION ${FFI_VERSION_STRING} |
63 | 72 | ) |
64 | 73 |
|
65 | 74 | # ------------------------------------------------------------------------------ |
66 | 75 | # set TARGET properly for Win32 and x64 |
67 | | -if(CMAKE_GENERATOR_PLATFORM STREQUAL "Win32") |
| 76 | +if(WIN32 AND CMAKE_SIZEOF_VOID_P EQUAL 4) |
68 | 77 | set(TARGET "X86_WIN32") |
69 | 78 | set(LIB_TYPE STATIC) |
70 | 79 | set(FFI_USE_SHARED_LIBS OFF) |
71 | 80 | set(BUILD_SHARED_LIBS OFF) |
72 | | - set(MSVC_OPTS /D_WINDLL /D_WIN32 /D_CRT_SECURE_NO_WARNINGS) |
73 | | -elseif(CMAKE_GENERATOR_PLATFORM STREQUAL "x64") |
| 81 | + set(MSVC_DEFS _WINDLL _WIN32 _CRT_SECURE_NO_WARNINGS) |
| 82 | +elseif(WIN32 AND CMAKE_SIZEOF_VOID_P EQUAL 8) |
74 | 83 | set(TARGET "X86_WIN64") |
75 | 84 | set(LIB_TYPE STATIC) |
76 | 85 | set(FFI_USE_SHARED_LIBS OFF) |
77 | 86 | set(BUILD_SHARED_LIBS OFF) |
78 | | - set(MSVC_OPTS /D_WINDLL /D_WIN32 /D_CRT_SECURE_NO_WARNINGS) |
| 87 | + set(MSVC_DEFS _WINDLL _WIN32 _CRT_SECURE_NO_WARNINGS) |
79 | 88 | else() |
80 | 89 | message(FATAL_ERROR "Invalid generator platform.") |
81 | 90 | endif() |
| 91 | +if(CMAKE_C_COMPILER_ID MATCHES "IntelLLVM") |
| 92 | + add_compile_options(-Wno-deprecated-declarations) |
| 93 | +endif() |
| 94 | + |
82 | 95 |
|
83 | 96 | # ------------------------------------------------------------------------------ |
84 | 97 | # For design reasons of this file CMAKE_BUILD_TYPE needs to be set from the |
@@ -134,6 +147,8 @@ endif() |
134 | 147 |
|
135 | 148 | # config variables for ffi.h.in |
136 | 149 | set(VERSION ${PROJECT_VERSION}) |
| 150 | +#set(FFI_VERSION_STRING "${PROJECT_VERSION}") |
| 151 | +#set(FFI_VERSION_NUMBER ${PROJECT_VERSION}) |
137 | 152 |
|
138 | 153 | set(KNOWN_PROCESSORS x86 x86_64 amd64 arm arm64 i386 i686 armv7l armv7-a aarch64) |
139 | 154 |
|
@@ -240,7 +255,7 @@ endif() |
240 | 255 |
|
241 | 256 | macro(add_assembly ASMFILE) |
242 | 257 | get_filename_component(ASMFILE_FULL "${ASMFILE}" ABSOLUTE) |
243 | | - if(MSVC) |
| 258 | + if(MSVC OR CMAKE_C_COMPILER_ID MATCHES "IntelLLVM") |
244 | 259 | if ("${TARGET}" STREQUAL "ARM_WIN64") |
245 | 260 | set(ARCH_ASSEMBLER armasm64) |
246 | 261 | elseif ("${TARGET}" STREQUAL "ARM_WIN32") |
@@ -348,7 +363,7 @@ if(WIN32 OR MINGW) |
348 | 363 | endif() |
349 | 364 |
|
350 | 365 | add_library(libffi ${LIB_TYPE} ${FFI_SOURCES}) |
351 | | -target_compile_options(libffi PRIVATE ${MSVC_OPTS}) |
| 366 | +target_compile_definitions(libffi PRIVATE ${MSVC_DEFS}) |
352 | 367 |
|
353 | 368 | install(TARGETS libffi |
354 | 369 | EXPORT ${PROJECT_NAME}Targets |
|
0 commit comments