Files
dusk/cmake/determineplatform.cmake
T
YourWishesandClaude Sonnet 5.5 65c4a9c051 Add fresh CMake/platform scaffolding, core engine, and SDL3 window
Platform folders, cmake target/option/platform detection, Linux and PSP
scripts and Docker setup, assert/util/thread/error/log/perf/time/console/
engine/display modules, and an SDL3 window cleared to red.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-11-07 17:02:14 -06:00

46 lines
1.5 KiB
CMake

# Copyright (c) 2026 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Determines DUSK_TARGET_SYSTEM when it was not explicitly provided with
# -DDUSK_TARGET_SYSTEM=<target>. Must be included after project() so that the
# compiler and CMAKE_SYSTEM_NAME are known.
#
# Console toolchains all cross compile as "Generic", so they are recognised by
# the compiler they configure.
if(DUSK_TARGET_SYSTEM)
message(STATUS "Dusk target: ${DUSK_TARGET_SYSTEM} (explicit)")
return()
endif()
if(CMAKE_C_COMPILER MATCHES "psp-")
set(DUSK_DETECTED_SYSTEM "psp")
elseif(CMAKE_C_COMPILER MATCHES "arm-vita-eabi")
set(DUSK_DETECTED_SYSTEM "vita")
elseif(CMAKE_C_COMPILER MATCHES "powerpc-eabi")
set(DUSK_DETECTED_SYSTEM "dolphin")
elseif(CMAKE_C_COMPILER MATCHES "ps2")
set(DUSK_DETECTED_SYSTEM "ps2")
elseif(CMAKE_C_COMPILER MATCHES "sh-elf")
set(DUSK_DETECTED_SYSTEM "dreamcast")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(DUSK_DETECTED_SYSTEM "windows")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(DUSK_DETECTED_SYSTEM "linux")
else()
message(FATAL_ERROR
"Could not determine the target platform (system: ${CMAKE_SYSTEM_NAME}, "
"compiler: ${CMAKE_C_COMPILER}). Pass -DDUSK_TARGET_SYSTEM=<target>."
)
endif()
set(DUSK_TARGET_SYSTEM "${DUSK_DETECTED_SYSTEM}" CACHE STRING
"Target platform" FORCE
)
set_property(CACHE DUSK_TARGET_SYSTEM PROPERTY STRINGS
linux windows psp dolphin vita ps2 dreamcast
)
message(STATUS "Dusk target: ${DUSK_TARGET_SYSTEM} (detected)")