CMake: Enable cross-compiling for macos arm64 on x86

This commit is contained in:
Connor McLaughlin 2022-07-31 16:39:09 +10:00
parent 4f5722c932
commit d674014e30
3 changed files with 12 additions and 10 deletions

View File

@ -217,21 +217,24 @@ endif()
# Detect processor type.
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64" OR ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "amd64" OR
${CMAKE_SYSTEM_PROCESSOR} STREQUAL "AMD64")
if("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "arm64")
# Cross-compile on macos.
set(CPU_ARCH "aarch64")
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64" OR "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "amd64" OR
"${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "AMD64")
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(CPU_ARCH "x64")
else()
# Cross-compiling 32-bit build. 32-bit hosts are not supported.
set(CPU_ARCH "x86")
endif()
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86" OR ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i386" OR
${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i686")
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86" OR "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "i386" OR
"${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "i686")
set(CPU_ARCH "x86")
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64" OR ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm64")
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64" OR "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "arm64")
set(CPU_ARCH "aarch64")
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm" OR ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7-a" OR
${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7l")
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "arm" OR "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "armv7-a" OR
"${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "armv7l")
set(CPU_ARCH "aarch32")
if(ANDROID)
# Force ARM mode, since apparently ANDROID_ARM_MODE isn't working..
@ -243,7 +246,7 @@ elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm" OR ${CMAKE_SYSTEM_PROCESSOR} STR
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -marm -march=armv7-a")
endif()
else()
message(FATAL_ERROR "Unknown system processor: " ${CMAKE_SYSTEM_PROCESSOR})
message(FATAL_ERROR "Unknown system processor: ${CMAKE_SYSTEM_PROCESSOR}")
endif()

View File

@ -26,7 +26,7 @@ target_compile_definitions(soundtouch PRIVATE ${COMPILE_DEFINITIONS})
target_compile_options(soundtouch PRIVATE ${COMPILE_OPTIONS})
target_compile_definitions(soundtouch PRIVATE SOUNDTOUCH_FLOAT_SAMPLES)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(armv7.*|armv8.*|aarch64.*)$")
if("${CPU_ARCH}" STREQUAL "aarch32" OR "${CPU_ARCH}" STREQUAL "aarch64")
target_compile_definitions(soundtouch PRIVATE SOUNDTOUCH_USE_NEON)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(armv7.*)$")
target_compile_options(soundtouch PRIVATE -mfpu=neon)

View File

@ -215,7 +215,6 @@ if(APPLE)
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/data/resources")
file(GLOB_RECURSE resources RELATIVE "${CMAKE_SOURCE_DIR}/data/resources" "${CMAKE_SOURCE_DIR}/data/resources/*")
foreach(res ${resources})
message(STATUS "Resource: ${res}")
target_sources(duckstation-qt PRIVATE "${CMAKE_SOURCE_DIR}/data/resources/${res}")
get_filename_component(resdir "${res}" DIRECTORY)
set_source_files_properties("${CMAKE_SOURCE_DIR}/data/resources/${res}" PROPERTIES