From 62fc1a9afdeef267c684a52adb59b4eaa6757400 Mon Sep 17 00:00:00 2001 From: partic <1596067968@qq.com> Date: Sun, 21 May 2023 20:55:39 +0800 Subject: [PATCH] support to be included by add_subdirectory remove TRYRUN to allow cross compile fix windows 32bit build --- CMakeLists.txt | 8 ++++++++ configure_options.cmake | 12 +----------- configure_platform.cmake | 7 ++++--- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ddc373b15..791fc6f67 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,10 @@ set_property(TARGET objlib PROPERTY POSITION_INDEPENDENT_CODE 1) add_library(ffi_static STATIC $) +target_include_directories( + ffi_static PUBLIC + "$") + if(MSVC) add_definitions(-DFFI_BUILDING_DLL) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) @@ -38,6 +42,10 @@ elseif(CMAKE_SYSTEM_NAME MATCHES Darwin) endif() add_library(ffi_shared SHARED $ ${OBJECTS_LIST}) +target_include_directories( + ffi_shared PUBLIC + "$") + set_target_properties(ffi_static PROPERTIES OUTPUT_NAME ffi) set_target_properties(ffi_shared PROPERTIES OUTPUT_NAME ffi) diff --git a/configure_options.cmake b/configure_options.cmake index 5459febcf..df1575c55 100644 --- a/configure_options.cmake +++ b/configure_options.cmake @@ -136,17 +136,7 @@ check_function_exists (mmap HAVE_MMAP) check_symbol_exists (MAP_ANON sys/mman.h HAVE_MMAP_ANON) -check_c_source_runs( - " - #include - #include - #include - #include - - int main(void) { - int devzero = open(\"/dev/zero\", O_RDWR); - return devzero == -1 || mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, devzero, 0) == (void *)-1 ? 1 : 0; - }" HAVE_MMAP_DEV_ZERO) +set(HAVE_MMAP_DEV_ZERO OFF) check_include_file(alloca.h HAVE_ALLOCA_H) diff --git a/configure_platform.cmake b/configure_platform.cmake index bc57a65cc..8dd1091d4 100644 --- a/configure_platform.cmake +++ b/configure_platform.cmake @@ -4,6 +4,7 @@ else() set(HOST_ARCH ${CMAKE_C_COMPILER_ARCHITECTURE_ID}) endif() + if("${TARGET_PLATFORM}" STREQUAL "") if(HOST_ARCH MATCHES x64|x86_64|AMD64|amd64) if(CMAKE_SYSTEM_NAME STREQUAL Windows) @@ -12,7 +13,7 @@ if("${TARGET_PLATFORM}" STREQUAL "") set(TARGET_PLATFORM X86_64) endif() elseif(HOST_ARCH MATCHES i.*86.*|X86|x86) - if(MSVC) + if(CMAKE_SYSTEM_NAME MATCHES Windows) set(TARGET_PLATFORM X86_WIN32) else() set(TARGET_PLATFORM X86) @@ -24,13 +25,13 @@ if("${TARGET_PLATFORM}" STREQUAL "") set(TARGET_PLATFORM X86_FREEBSD) endif() elseif(HOST_ARCH MATCHES aarch64|ARM64|arm64) - if(MSVC) + if(CMAKE_SYSTEM_NAME MATCHES Windows) set(TARGET_PLATFORM ARM_WIN64) else() set(TARGET_PLATFORM AARCH64) endif() elseif(HOST_ARCH MATCHES arm.*|ARM.*) - if(MSVC) + if(CMAKE_SYSTEM_NAME MATCHES Windows) set(TARGET_PLATFORM ARM_WIN32) else() set(TARGET_PLATFORM ARM)