@@ -42,50 +42,67 @@ message( "Auto-detected ${PROC_MAX} CPU cores available for build parallelism."
42
42
set ( PLATFORM_LIST linux macos windows android ios web )
43
43
44
44
# 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 )
46
46
47
47
# 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 ()
50
57
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 )
53
62
return ()
54
63
endif ()
55
64
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" )
59
69
set ( rv64 "rv;riscv;riscv64" )
60
70
set ( ppc32 "ppcle;ppc" )
61
71
set ( ppc64 "ppc64le" )
62
72
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 )
65
78
66
- elseif ( PROC IN_LIST arm32 )
67
- set (${ALIAS } "arm32 " PARENT_SCOPE )
79
+ elseif ( ARCH IN_LIST arm64 )
80
+ set (${OUTVAR } "arm64 " PARENT_SCOPE )
68
81
69
- elseif ( PROC IN_LIST arm64 )
70
- set (${ALIAS } "arm64 " PARENT_SCOPE )
82
+ elseif ( ARCH IN_LIST rv64 )
83
+ set (${OUTVAR } "rv64 " PARENT_SCOPE )
71
84
72
- elseif ( PROC IN_LIST rv64 )
73
- set (${ALIAS } "rv64 " PARENT_SCOPE )
85
+ elseif ( ARCH IN_LIST ppc32 )
86
+ set (${OUTVAR } "ppc32 " PARENT_SCOPE )
74
87
75
- elseif ( PROC IN_LIST ppc32 )
76
- set (${ALIAS } "ppc32 " PARENT_SCOPE )
88
+ elseif ( ARCH IN_LIST ppc64 )
89
+ set (${OUTVAR } "ppc64 " PARENT_SCOPE )
77
90
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 )
80
94
81
95
else ()
82
- set (${ALIAS} "unknown" PARENT_SCOPE )
96
+ # Default value is whatever the processor is.
97
+ set (${OUTVAR} ${CMAKE_SYSTEM_PROCESSOR} PARENT_SCOPE )
83
98
endif ()
84
99
endfunction ()
85
100
86
101
# Function to define all the options.
87
102
function ( godotcpp_options )
88
103
#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
89
106
90
107
# Input from user for GDExtension interface header and the API JSON file
91
108
set (GODOT_GDEXTENSION_DIR "gdextension" CACHE PATH
@@ -103,11 +120,6 @@ function( godotcpp_options )
103
120
set (GODOT_PRECISION "single" CACHE STRING
104
121
"Set the floating-point precision level (single|double)" )
105
122
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
-
111
123
set ( GODOT_THREADS ON CACHE BOOL "Enable threading support" )
112
124
113
125
#TODO compiledb
@@ -252,12 +264,8 @@ function( godotcpp_generate )
252
264
"$<$<PLATFORM_ID:Msys>:windows>"
253
265
)
254
266
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 )
261
269
262
270
# Transform options into generator expressions
263
271
set ( HOT_RELOAD-UNSET "$<STREQUAL:${GODOT_USE_HOT_RELOAD} ,>" )
@@ -290,7 +298,7 @@ function( godotcpp_generate )
290
298
"$<1:.${TARGET_ALIAS} >"
291
299
"$<${IS_DEV_BUILD} :.dev>"
292
300
"$<$<STREQUAL:${GODOT_PRECISION} ,double>:.double>"
293
- "$<1:.${SYSTEM_ARCH } >"
301
+ "$<1:.${ARCH_NAME } >"
294
302
# TODO IOS_SIMULATOR
295
303
"$<$<NOT:${THREADS_ENABLED} >:.nothreads>"
296
304
)
@@ -331,7 +339,7 @@ function( godotcpp_generate )
331
339
# Things that are handy to know for dependent targets
332
340
GODOT_PLATFORM "${SYSTEM_NAME} "
333
341
GODOT_TARGET "${TARGET_ALIAS} "
334
- GODOT_ARCH "${SYSTEM_ARCH } "
342
+ GODOT_ARCH "${ARCH_NAME } "
335
343
GODOT_PRECISION "${GODOT_PRECISION} "
336
344
GODOT_SUFFIX "${GODOT_SUFFIX} "
337
345
0 commit comments