diff --git a/cmake/Triple.cmake b/cmake/Triple.cmake index c58b49f6d..1040c1847 100644 --- a/cmake/Triple.cmake +++ b/cmake/Triple.cmake @@ -34,32 +34,45 @@ MACRO (TRIPLE _PROCESSOR _PLATFORM _OS _VENDOR _TRIPLE) CHECK_TYPE_SIZE(void* SIZEOF_VOIDP) ENDIF() - # the code based on clang GetTriple.cmake - IF (${_PROCESSOR} STREQUAL "x86") - # CMake somehow does not detect proper processor on win64 - IF (SIZEOF_VOIDP EQUAL 4) - SET(${_PROCESSOR} "i686") - ELSE() - # assume it's x86_64 + # For MSVC cross compiler + IF (MSVC) + # Checking C compiler must be enough for our use case + MESSAGE(STATUS "MSVC architecture: ${MSVC_C_ARCHITECTURE_ID}") + IF (MSVC_C_ARCHITECTURE_ID MATCHES "^ARM") + STRING(TOLOWER ${MSVC_C_ARCHITECTURE_ID} ${_PROCESSOR}) + ELSEIF(MSVC_C_ARCHITECTURE_ID STREQUAL "x64") SET(${_PROCESSOR} "x86_64") - ENDIF() - ENDIF() - - # on 64 bit Linux but trying to compile with 32 bit - # CMake does not pretend to be 32 bit archtecture. - # We need to modify it manually - IF (${_PROCESSOR} STREQUAL "x86_64") - IF (SIZEOF_VOIDP EQUAL 4) + ELSE() SET(${_PROCESSOR} "i686") ENDIF() - ENDIF() - - # On Windows, if CMake works properly, the value must be this. - IF (${_PROCESSOR} STREQUAL "amd64") - IF (SIZEOF_VOIDP EQUAL 4) - SET(${_PROCESSOR} "i686") - ELSE() - SET(${_PROCESSOR} "x86_64") + ELSE() + # the code based on clang GetTriple.cmake + IF (${_PROCESSOR} STREQUAL "x86") + # CMake somehow does not detect proper processor on win64 + IF (SIZEOF_VOIDP EQUAL 4) + SET(${_PROCESSOR} "i686") + ELSE() + # assume it's x86_64 + SET(${_PROCESSOR} "x86_64") + ENDIF() + ENDIF() + + # on 64 bit Linux but trying to compile with 32 bit + # CMake does not pretend to be 32 bit archtecture. + # We need to modify it manually + IF (${_PROCESSOR} STREQUAL "x86_64") + IF (SIZEOF_VOIDP EQUAL 4) + SET(${_PROCESSOR} "i686") + ENDIF() + ENDIF() + + # On Windows, if CMake works properly, the value must be this. + IF (${_PROCESSOR} STREQUAL "amd64") + IF (SIZEOF_VOIDP EQUAL 4) + SET(${_PROCESSOR} "i686") + ELSE() + SET(${_PROCESSOR} "x86_64") + ENDIF() ENDIF() ENDIF() @@ -82,4 +95,4 @@ MACRO (TRIPLE _PROCESSOR _PLATFORM _OS _VENDOR _TRIPLE) ENDIF() SET(${_TRIPLE} "${${_PROCESSOR}}-${${_VENDOR}}-${${_OS}}") MESSAGE(STATUS "Architecture triple: ${${_TRIPLE}}") -ENDMACRO (TRIPLE) \ No newline at end of file +ENDMACRO (TRIPLE) diff --git a/ext/ffi/libffi/CMakeLists.txt b/ext/ffi/libffi/CMakeLists.txt index db248ecff..806482337 100644 --- a/ext/ffi/libffi/CMakeLists.txt +++ b/ext/ffi/libffi/CMakeLists.txt @@ -162,8 +162,6 @@ elseif (${arch} STREQUAL "arm64") endif() endif() -add_definitions(-D${TARGET}) - if (${TARGET} STREQUAL "X86_DARWIN") # It may be on all x86_64 architectures HAVE_LONG_DOUBLE must be 1, mustn't it? #if (${arch} STREQUAL "x86_64") @@ -176,9 +174,9 @@ if (${TARGETDIR} STREQUAL "unknown") message(STATUS "custom libffi has not been ported to ${host}") else () configure_file(cmake/ffi.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/ffi.h) - configure_file(cmake/fficonfig.h.in ${CMAKE_CURRENT_BINARY_DIR}/fficonfig.h) + configure_file(cmake/fficonfig.h.in + ${CMAKE_CURRENT_BINARY_DIR}/include/fficonfig.h) - include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) include_directories(${CMAKE_CURRENT_BINARY_DIR}/include)