Skip to content
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

support to be included by add_subdirectory, some win32 fix. #2

Open
wants to merge 1 commit into
base: feature/cmake-build-configs
Choose a base branch
from
Open
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ set_property(TARGET objlib PROPERTY POSITION_INDEPENDENT_CODE 1)

add_library(ffi_static STATIC $<TARGET_OBJECTS:objlib>)

target_include_directories(
ffi_static PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>")

if(MSVC)
add_definitions(-DFFI_BUILDING_DLL)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
Expand All @@ -38,6 +42,10 @@ elseif(CMAKE_SYSTEM_NAME MATCHES Darwin)
endif()
add_library(ffi_shared SHARED $<TARGET_OBJECTS:objlib> ${OBJECTS_LIST})

target_include_directories(
ffi_shared PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>")

set_target_properties(ffi_static PROPERTIES OUTPUT_NAME ffi)
set_target_properties(ffi_shared PROPERTIES OUTPUT_NAME ffi)

Expand Down
12 changes: 1 addition & 11 deletions configure_options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 <stdlib.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <fcntl.h>

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)

Expand Down
7 changes: 4 additions & 3 deletions configure_platform.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down