@@ -41,50 +41,67 @@ message( "Auto-detected ${PROC_MAX} CPU cores available for build parallelism."
4141set ( PLATFORM_LIST linux macos windows android ios web )
4242
4343# List of known architectures
44- set ( ARCH_LIST universal x86_32 x86_64 arm32 arm64 rv64 ppc32 ppc64 wasm32 )
44+ set ( ARCH_LIST x86_32 x86_64 arm32 arm64 rv64 ppc32 ppc64 wasm32 )
4545
4646# Function to map processors to known architectures
47- function ( godot_arch_map ALIAS PROC )
48- string ( TOLOWER "${PROC} " PROC )
47+ function ( godot_arch_name OUTVAR )
48+
49+ # Special case for macos universal builds that target both x86_64 and arm64
50+ if ( DEFINED CMAKE_OSX_ARCHITECTURES)
51+ if ( "x86_64" IN_LIST CMAKE_OSX_ARCHITECTURES AND "arm64" IN_LIST CMAKE_OSX_ARCHITECTURES)
52+ set (${OUTVAR} "universal" PARENT_SCOPE )
53+ return ()
54+ endif ()
55+ endif ()
4956
50- if ( "${PROC} " IN_LIST ARCH_LIST )
51- set ( ${ALIAS} "${PROC} " PARENT_SCOPE)
57+ # Direct match early out.
58+ string ( TOLOWER "${CMAKE_SYSTEM_PROCESSOR} " ARCH )
59+ if ( ARCH IN_LIST ARCH_LIST )
60+ set ( ${OUTVAR} "${ARCH} " PARENT_SCOPE)
5261 return ()
5362 endif ()
5463
55- set ( x86_64 "w64;amd64" )
56- set ( arm32 "armv7" )
57- set ( arm64 "armv8;arm64v8;aarch64" )
64+ # Known aliases
65+ set ( x86_64 "w64;amd64;x86-64" )
66+ set ( arm32 "armv7;armv7-a" )
67+ set ( arm64 "armv8;arm64v8;aarch64;armv8-a" )
5868 set ( rv64 "rv;riscv;riscv64" )
5969 set ( ppc32 "ppcle;ppc" )
6070 set ( ppc64 "ppc64le" )
6171
62- if ( PROC IN_LIST x86_64 )
63- set (${ALIAS} "x86_64" PARENT_SCOPE )
72+ if ( ARCH IN_LIST x86_64 )
73+ set (${OUTVAR} "x86_64" PARENT_SCOPE )
74+
75+ elseif ( ARCH IN_LIST arm32 )
76+ set (${OUTVAR} "arm32" PARENT_SCOPE )
6477
65- elseif ( PROC IN_LIST arm32 )
66- set (${ALIAS } "arm32 " PARENT_SCOPE )
78+ elseif ( ARCH IN_LIST arm64 )
79+ set (${OUTVAR } "arm64 " PARENT_SCOPE )
6780
68- elseif ( PROC IN_LIST arm64 )
69- set (${ALIAS } "arm64 " PARENT_SCOPE )
81+ elseif ( ARCH IN_LIST rv64 )
82+ set (${OUTVAR } "rv64 " PARENT_SCOPE )
7083
71- elseif ( PROC IN_LIST rv64 )
72- set (${ALIAS } "rv64 " PARENT_SCOPE )
84+ elseif ( ARCH IN_LIST ppc32 )
85+ set (${OUTVAR } "ppc32 " PARENT_SCOPE )
7386
74- elseif ( PROC IN_LIST ppc32 )
75- set (${ALIAS } "ppc32 " PARENT_SCOPE )
87+ elseif ( ARCH IN_LIST ppc64 )
88+ set (${OUTVAR } "ppc64 " PARENT_SCOPE )
7689
77- elseif ( PROC IN_LIST ppc64 )
78- set (${ALIAS} "ppc64" PARENT_SCOPE )
90+ elseif ( ARCH MATCHES "86" )
91+ # Catches x86, i386, i486, i586, i686, etc.
92+ set (${OUTVAR} "x86_32" PARENT_SCOPE )
7993
8094 else ()
81- set (${ALIAS} "unknown" PARENT_SCOPE )
95+ # Default value is whatever the processor is.
96+ set (${OUTVAR} ${CMAKE_SYSTEM_PROCESSOR} PARENT_SCOPE )
8297 endif ()
8398endfunction ()
8499
85100# Function to define all the options.
86101function ( godotcpp_options )
87102 #NOTE: platform is managed using toolchain files.
103+ #NOTE: arch is managed by using toolchain files.
104+ # Except for macos universal, which can be set by GODOT_MACOS_UNIVERSAL=YES
88105
89106 # Input from user for GDExtension interface header and the API JSON file
90107 set (GODOT_GDEXTENSION_DIR "gdextension" CACHE PATH
@@ -102,11 +119,6 @@ function( godotcpp_options )
102119 set (GODOT_PRECISION "single" CACHE STRING
103120 "Set the floating-point precision level (single|double)" )
104121
105- # The arch is typically set by the toolchain
106- # however for Apple multi-arch setting it here will override.
107- set ( GODOT_ARCH "" CACHE STRING "Target CPU Architecture" )
108- set_property ( CACHE GODOT_ARCH PROPERTY STRINGS ${ARCH_LIST} )
109-
110122 set ( GODOT_THREADS ON CACHE BOOL "Enable threading support" )
111123
112124 #TODO compiledb
@@ -251,12 +263,8 @@ function( godotcpp_generate )
251263 "$<$<PLATFORM_ID:Msys>:windows>"
252264 )
253265
254- ### Use the arch from the toolchain if it isn't set manually
255- if ( GODOT_ARCH )
256- set (SYSTEM_ARCH ${GODOT_ARCH} )
257- else ()
258- godot_arch_map( SYSTEM_ARCH ${CMAKE_SYSTEM_PROCESSOR} )
259- endif ()
266+ # Process CPU architecture argument.
267+ godot_arch_name( ARCH_NAME )
260268
261269 # Transform options into generator expressions
262270 set ( HOT_RELOAD-UNSET "$<STREQUAL:${GODOT_USE_HOT_RELOAD} ,>" )
@@ -289,7 +297,7 @@ function( godotcpp_generate )
289297 "$<1:.${TARGET_ALIAS} >"
290298 "$<${IS_DEV_BUILD} :.dev>"
291299 "$<$<STREQUAL:${GODOT_PRECISION} ,double>:.double>"
292- "$<1:.${SYSTEM_ARCH } >"
300+ "$<1:.${ARCH_NAME } >"
293301 # TODO IOS_SIMULATOR
294302 "$<$<NOT:${THREADS_ENABLED} >:.nothreads>"
295303 )
@@ -330,7 +338,7 @@ function( godotcpp_generate )
330338 # Things that are handy to know for dependent targets
331339 GODOT_PLATFORM "${SYSTEM_NAME} "
332340 GODOT_TARGET "${TARGET_ALIAS} "
333- GODOT_ARCH "${SYSTEM_ARCH } "
341+ GODOT_ARCH "${ARCH_NAME } "
334342 GODOT_PRECISION "${GODOT_PRECISION} "
335343 GODOT_SUFFIX "${GODOT_SUFFIX} "
336344
0 commit comments