@@ -42,50 +42,67 @@ message( "Auto-detected ${PROC_MAX} CPU cores available for build parallelism."
4242set ( PLATFORM_LIST linux macos windows android ios web )
4343
4444# List of known architectures 
45- set ( ARCH_LIST universal  x86_32 x86_64 arm32 arm64 rv64 ppc32 ppc64 wasm32 )
45+ set ( ARCH_LIST x86_32 x86_64 arm32 arm64 rv64 ppc32 ppc64 wasm32 )
4646
4747# Function to map processors to known architectures 
48- function ( godot_arch_map ALIAS PROC )
49-  string ( TOLOWER "${PROC} "  PROC )
48+ function ( godot_arch_name OUTVAR )
49+ 
50+  # Special case for macos universal builds that target both x86_64 and arm64 
51+  if ( DEFINED  CMAKE_OSX_ARCHITECTURES)
52+  if ( "x86_64"  IN_LIST  CMAKE_OSX_ARCHITECTURES AND  "arm64"  IN_LIST  CMAKE_OSX_ARCHITECTURES)
53+  set (${OUTVAR}  "universal"  PARENT_SCOPE )
54+  return ()
55+  endif ()
56+  endif ()
5057
51-  if ( "${PROC} "  IN_LIST  ARCH_LIST )
52-  set ( ${ALIAS}  "${PROC} "  PARENT_SCOPE)
58+  # Direct match early out. 
59+  string ( TOLOWER "${CMAKE_SYSTEM_PROCESSOR} "  ARCH )
60+  if ( ARCH IN_LIST  ARCH_LIST )
61+  set ( ${OUTVAR}  "${ARCH} "  PARENT_SCOPE)
5362 return ()
5463 endif ()
5564
56-  set ( x86_64 "w64;amd64"  )
57-  set ( arm32 "armv7"  )
58-  set ( arm64 "armv8;arm64v8;aarch64"  )
65+  # Known aliases 
66+  set ( x86_64 "w64;amd64;x86-64"  )
67+  set ( arm32 "armv7;armv7-a"  )
68+  set ( arm64 "armv8;arm64v8;aarch64;armv8-a"  )
5969 set ( rv64 "rv;riscv;riscv64"  )
6070 set ( ppc32 "ppcle;ppc"  )
6171 set ( ppc64 "ppc64le"  )
6272
63-  if ( PROC IN_LIST  x86_64 )
64-  set (${ALIAS}  "x86_64"  PARENT_SCOPE )
73+  if ( ARCH IN_LIST  x86_64 )
74+  set (${OUTVAR}  "x86_64"  PARENT_SCOPE )
75+ 
76+  elseif ( ARCH IN_LIST  arm32 )
77+  set (${OUTVAR}  "arm32"  PARENT_SCOPE )
6578
66-  elseif ( PROC  IN_LIST  arm32  )
67-  set (${ALIAS }  "arm32 "  PARENT_SCOPE )
79+  elseif ( ARCH  IN_LIST  arm64  )
80+  set (${OUTVAR }  "arm64 "  PARENT_SCOPE )
6881
69-  elseif ( PROC  IN_LIST  arm64  )
70-  set (${ALIAS }  "arm64 "  PARENT_SCOPE )
82+  elseif ( ARCH  IN_LIST  rv64  )
83+  set (${OUTVAR }  "rv64 "  PARENT_SCOPE )
7184
72-  elseif ( PROC  IN_LIST  rv64  )
73-  set (${ALIAS }  "rv64 "  PARENT_SCOPE )
85+  elseif ( ARCH  IN_LIST  ppc32  )
86+  set (${OUTVAR }  "ppc32 "  PARENT_SCOPE )
7487
75-  elseif ( PROC  IN_LIST  ppc32  )
76-  set (${ALIAS }  "ppc32 "  PARENT_SCOPE )
88+  elseif ( ARCH  IN_LIST  ppc64  )
89+  set (${OUTVAR }  "ppc64 "  PARENT_SCOPE )
7790
78-  elseif ( PROC IN_LIST  ppc64 )
79-  set (${ALIAS}  "ppc64"  PARENT_SCOPE )
91+  elseif ( ARCH MATCHES  "86" )
92+  # Catches x86, i386, i486, i586, i686, etc. 
93+  set (${OUTVAR}  "x86_32"  PARENT_SCOPE )
8094
8195 else ()
82-  set (${ALIAS}  "unknown"  PARENT_SCOPE )
96+  # Default value is whatever the processor is. 
97+  set (${OUTVAR}  ${CMAKE_SYSTEM_PROCESSOR}  PARENT_SCOPE )
8398 endif  ()
8499endfunction ()
85100
86101# Function to define all the options. 
87102function ( godotcpp_options )
88103 #NOTE: platform is managed using toolchain files. 
104+  #NOTE: arch is managed by using toolchain files. 
105+  # Except for macos universal, which can be set by GODOT_MACOS_UNIVERSAL=YES 
89106
90107 # Input from user for GDExtension interface header and the API JSON file 
91108 set (GODOT_GDEXTENSION_DIR "gdextension"  CACHE  PATH 
@@ -103,11 +120,6 @@ function( godotcpp_options )
103120 set (GODOT_PRECISION "single"  CACHE  STRING 
104121 "Set the floating-point precision level (single|double)" )
105122
106-  # The arch is typically set by the toolchain 
107-  # however for Apple multi-arch setting it here will override. 
108-  set ( GODOT_ARCH ""  CACHE  STRING  "Target CPU Architecture" )
109-  set_property ( CACHE  GODOT_ARCH PROPERTY STRINGS  ${ARCH_LIST}  )
110- 
111123 set ( GODOT_THREADS ON  CACHE  BOOL  "Enable threading support"  )
112124
113125 #TODO compiledb 
@@ -252,12 +264,8 @@ function( godotcpp_generate )
252264 "$<$<PLATFORM_ID:Msys>:windows>" 
253265 )
254266
255-  ### Use the arch from the toolchain if it isn't set manually 
256-  if ( GODOT_ARCH )
257-  set (SYSTEM_ARCH ${GODOT_ARCH} )
258-  else ()
259-  godot_arch_map( SYSTEM_ARCH ${CMAKE_SYSTEM_PROCESSOR}  )
260-  endif ()
267+  # Process CPU architecture argument. 
268+  godot_arch_name( ARCH_NAME )
261269
262270 # Transform options into generator expressions 
263271 set ( HOT_RELOAD-UNSET "$<STREQUAL:${GODOT_USE_HOT_RELOAD} ,>" )
@@ -290,7 +298,7 @@ function( godotcpp_generate )
290298 "$<1:.${TARGET_ALIAS} >" 
291299 "$<${IS_DEV_BUILD} :.dev>" 
292300 "$<$<STREQUAL:${GODOT_PRECISION} ,double>:.double>" 
293-  "$<1:.${SYSTEM_ARCH } >" 
301+  "$<1:.${ARCH_NAME } >" 
294302 # TODO IOS_SIMULATOR 
295303 "$<$<NOT:${THREADS_ENABLED} >:.nothreads>" 
296304 )
@@ -331,7 +339,7 @@ function( godotcpp_generate )
331339 # Things that are handy to know for dependent targets 
332340 GODOT_PLATFORM "${SYSTEM_NAME} " 
333341 GODOT_TARGET "${TARGET_ALIAS} " 
334-  GODOT_ARCH "${SYSTEM_ARCH } " 
342+  GODOT_ARCH "${ARCH_NAME } " 
335343 GODOT_PRECISION "${GODOT_PRECISION} " 
336344 GODOT_SUFFIX "${GODOT_SUFFIX} " 
337345
0 commit comments