Merge pull request #1708 from enetheru/arch_confusion
CMake: Fix unknown architecture and simplify OSX_ARCHITECTURESpull/1709/head
commit
79f9bc9600
|
@ -42,50 +42,67 @@ message( "Auto-detected ${PROC_MAX} CPU cores available for build parallelism."
|
||||||
set( PLATFORM_LIST linux macos windows android ios web )
|
set( PLATFORM_LIST linux macos windows android ios web )
|
||||||
|
|
||||||
# List of known architectures
|
# List of known architectures
|
||||||
set( ARCH_LIST universal x86_32 x86_64 arm32 arm64 rv64 ppc32 ppc64 wasm32 )
|
set( ARCH_LIST x86_32 x86_64 arm32 arm64 rv64 ppc32 ppc64 wasm32 )
|
||||||
|
|
||||||
# Function to map processors to known architectures
|
# Function to map processors to known architectures
|
||||||
function( godot_arch_map ALIAS PROC )
|
function( godot_arch_name OUTVAR )
|
||||||
string( TOLOWER "${PROC}" PROC )
|
|
||||||
|
|
||||||
if( "${PROC}" IN_LIST ARCH_LIST )
|
# Special case for macos universal builds that target both x86_64 and arm64
|
||||||
set( ${ALIAS} "${PROC}" PARENT_SCOPE)
|
if( DEFINED CMAKE_OSX_ARCHITECTURES)
|
||||||
|
if( "x86_64" IN_LIST CMAKE_OSX_ARCHITECTURES AND "arm64" IN_LIST CMAKE_OSX_ARCHITECTURES)
|
||||||
|
set(${OUTVAR} "universal" PARENT_SCOPE )
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Direct match early out.
|
||||||
|
string( TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" ARCH )
|
||||||
|
if( ARCH IN_LIST ARCH_LIST )
|
||||||
|
set( ${OUTVAR} "${ARCH}" PARENT_SCOPE)
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set( x86_64 "w64;amd64" )
|
# Known aliases
|
||||||
set( arm32 "armv7" )
|
set( x86_64 "w64;amd64;x86-64" )
|
||||||
set( arm64 "armv8;arm64v8;aarch64" )
|
set( arm32 "armv7;armv7-a" )
|
||||||
|
set( arm64 "armv8;arm64v8;aarch64;armv8-a" )
|
||||||
set( rv64 "rv;riscv;riscv64" )
|
set( rv64 "rv;riscv;riscv64" )
|
||||||
set( ppc32 "ppcle;ppc" )
|
set( ppc32 "ppcle;ppc" )
|
||||||
set( ppc64 "ppc64le" )
|
set( ppc64 "ppc64le" )
|
||||||
|
|
||||||
if( PROC IN_LIST x86_64 )
|
if( ARCH IN_LIST x86_64 )
|
||||||
set(${ALIAS} "x86_64" PARENT_SCOPE )
|
set(${OUTVAR} "x86_64" PARENT_SCOPE )
|
||||||
|
|
||||||
elseif( PROC IN_LIST arm32 )
|
elseif( ARCH IN_LIST arm32 )
|
||||||
set(${ALIAS} "arm32" PARENT_SCOPE )
|
set(${OUTVAR} "arm32" PARENT_SCOPE )
|
||||||
|
|
||||||
elseif( PROC IN_LIST arm64 )
|
elseif( ARCH IN_LIST arm64 )
|
||||||
set(${ALIAS} "arm64" PARENT_SCOPE )
|
set(${OUTVAR} "arm64" PARENT_SCOPE )
|
||||||
|
|
||||||
elseif( PROC IN_LIST rv64 )
|
elseif( ARCH IN_LIST rv64 )
|
||||||
set(${ALIAS} "rv64" PARENT_SCOPE )
|
set(${OUTVAR} "rv64" PARENT_SCOPE )
|
||||||
|
|
||||||
elseif( PROC IN_LIST ppc32 )
|
elseif( ARCH IN_LIST ppc32 )
|
||||||
set(${ALIAS} "ppc32" PARENT_SCOPE )
|
set(${OUTVAR} "ppc32" PARENT_SCOPE )
|
||||||
|
|
||||||
elseif( PROC IN_LIST ppc64 )
|
elseif( ARCH IN_LIST ppc64 )
|
||||||
set(${ALIAS} "ppc64" PARENT_SCOPE )
|
set(${OUTVAR} "ppc64" PARENT_SCOPE )
|
||||||
|
|
||||||
|
elseif( ARCH MATCHES "86")
|
||||||
|
# Catches x86, i386, i486, i586, i686, etc.
|
||||||
|
set(${OUTVAR} "x86_32" PARENT_SCOPE )
|
||||||
|
|
||||||
else()
|
else()
|
||||||
set(${ALIAS} "unknown" PARENT_SCOPE )
|
# Default value is whatever the processor is.
|
||||||
|
set(${OUTVAR} ${CMAKE_SYSTEM_PROCESSOR} PARENT_SCOPE )
|
||||||
endif ()
|
endif ()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
# Function to define all the options.
|
# Function to define all the options.
|
||||||
function( godotcpp_options )
|
function( godotcpp_options )
|
||||||
#NOTE: platform is managed using toolchain files.
|
#NOTE: platform is managed using toolchain files.
|
||||||
|
#NOTE: arch is managed by using toolchain files.
|
||||||
|
# Except for macos universal, which can be set by GODOT_MACOS_UNIVERSAL=YES
|
||||||
|
|
||||||
# Input from user for GDExtension interface header and the API JSON file
|
# Input from user for GDExtension interface header and the API JSON file
|
||||||
set(GODOT_GDEXTENSION_DIR "gdextension" CACHE PATH
|
set(GODOT_GDEXTENSION_DIR "gdextension" CACHE PATH
|
||||||
|
@ -103,11 +120,6 @@ function( godotcpp_options )
|
||||||
set(GODOT_PRECISION "single" CACHE STRING
|
set(GODOT_PRECISION "single" CACHE STRING
|
||||||
"Set the floating-point precision level (single|double)")
|
"Set the floating-point precision level (single|double)")
|
||||||
|
|
||||||
# The arch is typically set by the toolchain
|
|
||||||
# however for Apple multi-arch setting it here will override.
|
|
||||||
set( GODOT_ARCH "" CACHE STRING "Target CPU Architecture")
|
|
||||||
set_property( CACHE GODOT_ARCH PROPERTY STRINGS ${ARCH_LIST} )
|
|
||||||
|
|
||||||
set( GODOT_THREADS ON CACHE BOOL "Enable threading support" )
|
set( GODOT_THREADS ON CACHE BOOL "Enable threading support" )
|
||||||
|
|
||||||
#TODO compiledb
|
#TODO compiledb
|
||||||
|
@ -252,12 +264,8 @@ function( godotcpp_generate )
|
||||||
"$<$<PLATFORM_ID:Msys>:windows>"
|
"$<$<PLATFORM_ID:Msys>:windows>"
|
||||||
)
|
)
|
||||||
|
|
||||||
### Use the arch from the toolchain if it isn't set manually
|
# Process CPU architecture argument.
|
||||||
if( GODOT_ARCH )
|
godot_arch_name( ARCH_NAME )
|
||||||
set(SYSTEM_ARCH ${GODOT_ARCH})
|
|
||||||
else()
|
|
||||||
godot_arch_map( SYSTEM_ARCH ${CMAKE_SYSTEM_PROCESSOR} )
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Transform options into generator expressions
|
# Transform options into generator expressions
|
||||||
set( HOT_RELOAD-UNSET "$<STREQUAL:${GODOT_USE_HOT_RELOAD},>")
|
set( HOT_RELOAD-UNSET "$<STREQUAL:${GODOT_USE_HOT_RELOAD},>")
|
||||||
|
@ -290,7 +298,7 @@ function( godotcpp_generate )
|
||||||
"$<1:.${TARGET_ALIAS}>"
|
"$<1:.${TARGET_ALIAS}>"
|
||||||
"$<${IS_DEV_BUILD}:.dev>"
|
"$<${IS_DEV_BUILD}:.dev>"
|
||||||
"$<$<STREQUAL:${GODOT_PRECISION},double>:.double>"
|
"$<$<STREQUAL:${GODOT_PRECISION},double>:.double>"
|
||||||
"$<1:.${SYSTEM_ARCH}>"
|
"$<1:.${ARCH_NAME}>"
|
||||||
# TODO IOS_SIMULATOR
|
# TODO IOS_SIMULATOR
|
||||||
"$<$<NOT:${THREADS_ENABLED}>:.nothreads>"
|
"$<$<NOT:${THREADS_ENABLED}>:.nothreads>"
|
||||||
)
|
)
|
||||||
|
@ -331,7 +339,7 @@ function( godotcpp_generate )
|
||||||
# Things that are handy to know for dependent targets
|
# Things that are handy to know for dependent targets
|
||||||
GODOT_PLATFORM "${SYSTEM_NAME}"
|
GODOT_PLATFORM "${SYSTEM_NAME}"
|
||||||
GODOT_TARGET "${TARGET_ALIAS}"
|
GODOT_TARGET "${TARGET_ALIAS}"
|
||||||
GODOT_ARCH "${SYSTEM_ARCH}"
|
GODOT_ARCH "${ARCH_NAME}"
|
||||||
GODOT_PRECISION "${GODOT_PRECISION}"
|
GODOT_PRECISION "${GODOT_PRECISION}"
|
||||||
GODOT_SUFFIX "${GODOT_SUFFIX}"
|
GODOT_SUFFIX "${GODOT_SUFFIX}"
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,10 @@ MacOS
|
||||||
This file contains functions for options and configuration for targeting the
|
This file contains functions for options and configuration for targeting the
|
||||||
MacOS platform
|
MacOS platform
|
||||||
|
|
||||||
|
# To build universal binaries, ie targeting both x86_64 and arm64, use
|
||||||
|
# the CMAKE_OSX_ARCHITECTURES variable prior to any project calls.
|
||||||
|
# https://cmake.org/cmake/help/latest/variable/CMAKE_OSX_ARCHITECTURES.html
|
||||||
|
|
||||||
]=======================================================================]
|
]=======================================================================]
|
||||||
|
|
||||||
# Find Requirements
|
# Find Requirements
|
||||||
|
@ -17,28 +21,11 @@ IF(APPLE)
|
||||||
NO_DEFAULT_PATH)
|
NO_DEFAULT_PATH)
|
||||||
ENDIF (APPLE)
|
ENDIF (APPLE)
|
||||||
|
|
||||||
|
|
||||||
function( macos_options )
|
function( macos_options )
|
||||||
# macos options here
|
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
|
||||||
function( macos_generate )
|
function( macos_generate )
|
||||||
|
|
||||||
# OSX_ARCHITECTURES does not support generator expressions.
|
|
||||||
if( NOT GODOT_ARCH OR GODOT_ARCH STREQUAL universal )
|
|
||||||
set( OSX_ARCH "x86_64;arm64" )
|
|
||||||
set( SYSTEM_ARCH universal )
|
|
||||||
else()
|
|
||||||
set( OSX_ARCH ${GODOT_ARCH} )
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set_target_properties( ${TARGET_NAME}
|
|
||||||
PROPERTIES
|
|
||||||
|
|
||||||
OSX_ARCHITECTURES "${OSX_ARCH}"
|
|
||||||
)
|
|
||||||
|
|
||||||
target_compile_definitions(${TARGET_NAME}
|
target_compile_definitions(${TARGET_NAME}
|
||||||
PUBLIC
|
PUBLIC
|
||||||
MACOS_ENABLED
|
MACOS_ENABLED
|
||||||
|
|
Loading…
Reference in New Issue