# 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=. 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=." ) 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)")