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