@@ -12,20 +12,28 @@ endif()
1212set (TARGET "TEMPLATE_DEBUG" CACHE STRING "Target platform (EDITOR, TEMPLATE_DEBUG, TEMPLATE_RELEASE)" )
1313# Auto-detect platform
1414if (CMAKE_SYSTEM_NAME STREQUAL "Linux" )
15- set (DEFAULT_PLATFORM "LINUX" )
15+ set (DEFAULT_GODOT_PLATFORM "LINUX" )
1616elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows" )
17- set (DEFAULT_PLATFORM "WINDOWS" )
17+ set (DEFAULT_GODOT_PLATFORM "WINDOWS" )
1818elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin" )
19- set (DEFAULT_PLATFORM "MACOS" )
19+ set (DEFAULT_GODOT_PLATFORM "MACOS" )
20+ elseif (CMAKE_SYSTEM_NAME STREQUAL "iOS" )
21+ set (DEFAULT_GODOT_PLATFORM "IOS" )
2022elseif (CMAKE_SYSTEM_NAME STREQUAL "Emscripten" ) # Set by providing Emscripten toolchain
21- set (DEFAULT_PLATFORM "WEB" )
23+ set (DEFAULT_GODOT_PLATFORM "WEB" )
2224elseif (CMAKE_SYSTEM_NAME STREQUAL "Android" ) # Set by providing Android toolchain
23- set (DEFAULT_PLATFORM "ANDROID" )
24- else ()
25- message (FATAL_ERROR "Could not auto-detect platform for \" ${CMAKE_SYSTEM_NAME} \" automatically, please specify with -DPLATFORM=<platform>" )
25+ set (DEFAULT_GODOT_PLATFORM "NOTFOUND" )
2626endif ()
27- set (PLATFORM "${DEFAULT_PLATFORM} " CACHE STRING "[Auto-detected] Target platform (LINUX, MACOS, WINDOWS, ANDROID, IOS, WEB)" )
2827
28+ set (GODOT_PLATFORM "${DEFAULT_GODOT_PLATFORM} " CACHE STRING "[Auto-detected] Target platform (LINUX, MACOS, WINDOWS, ANDROID, IOS, WEB)" )
29+
30+ if ("${GODOT_PLATFORM} " STREQUAL "NOTFOUND" )
31+ message (FATAL_ERROR "Could not auto-detect platform for \" ${CMAKE_SYSTEM_NAME} \" automatically, please specify with -DGODOT_PLATFORM=<platform>" )
32+ endif ()
33+
34+ set (GODOT_PLATFORM "${DEFAULT_GODOT_PLATFORM} " CACHE STRING "[Auto-detected] Target platform (LINUX, MACOS, WINDOWS, ANDROID, IOS, WEB)" )
35+
36+ message (STATUS "Platform detected: ${GODOT_PLATFORM} " )
2937set (GDEXTENSION_DIR "${CMAKE_CURRENT_SOURCE_DIR} /gdextension" CACHE FILEPATH "Path to a directory containing GDExtension interface header" )
3038
3139set (GDEXTENSION_API_FILE "${CMAKE_CURRENT_SOURCE_DIR} /gdextension/extension_api.json" CACHE FILEPATH "Path to GDExtension API JSON file" )
@@ -81,7 +89,7 @@ endif()
8189# Workaround of $<CONFIG> expanding to "" when default build set
8290set (CONFIG "$<IF:$<STREQUAL:,$<CONFIG>>,${CMAKE_BUILD_TYPE} ,$<CONFIG>>" )
8391
84- string (TOLOWER ".${PLATFORM } .${TARGET} " platform_target)
92+ string (TOLOWER ".${GODOT_PLATFORM } .${TARGET} " platform_target)
8593string (PREPEND LIBRARY_SUFFIX ${platform_target} )
8694
8795# Default optimization levels if OPTIMIZE=AUTO, for multi-config support
@@ -266,24 +274,24 @@ list(APPEND GODOT_LINK_FLAGS
266274)
267275
268276# Platform-specific options
269- if ("${PLATFORM } " STREQUAL "LINUX" )
277+ if ("${GODOT_PLATFORM } " STREQUAL "LINUX" )
270278 include (linux)
271- elseif ("${PLATFORM } " STREQUAL "MACOS" )
279+ elseif ("${GODOT_PLATFORM } " STREQUAL "MACOS" )
272280 include (macos)
273- elseif ("${PLATFORM } " STREQUAL "WINDOWS" )
281+ elseif ("${GODOT_PLATFORM } " STREQUAL "WINDOWS" )
274282 include (windows)
275- elseif ("${PLATFORM } " STREQUAL "ANDROID" )
283+ elseif ("${GODOT_PLATFORM } " STREQUAL "ANDROID" )
276284 include (android)
277- elseif ("${PLATFORM } " STREQUAL "IOS" )
285+ elseif ("${GODOT_PLATFORM } " STREQUAL "IOS" )
278286 include (ios)
279- elseif ("${PLATFORM } " STREQUAL "WEB" )
287+ elseif ("${GODOT_PLATFORM } " STREQUAL "WEB" )
280288 include (web)
281289else ()
282- message (FATAL_ERROR "Platform not supported: ${PLATFORM } " )
290+ message (FATAL_ERROR "Platform not supported: ${GODOT_PLATFORM } " )
283291endif ()
284292
285293# Mac/IOS use framework directory structure and don't need arch suffix
286- if ((NOT "${PLATFORM } " STREQUAL "MACOS" ) AND (NOT "${PLATFORM } " STREQUAL "IOS" ))
294+ if ((NOT "${GODOT_PLATFORM } " STREQUAL "MACOS" ) AND (NOT "${GODOT_PLATFORM } " STREQUAL "IOS" ))
287295 string (APPEND LIBRARY_SUFFIX ".${ARCH} " )
288296endif ()
289297
0 commit comments