2022-11-29 09:48:45 -07:00
|
|
|
macro(SDL_DetectCMakePlatform)
|
|
|
|
set(SDL_CMAKE_PLATFORM )
|
|
|
|
# Get the platform
|
|
|
|
if(WIN32)
|
2023-01-28 22:12:40 -07:00
|
|
|
set(SDL_CMAKE_PLATFORM Windows)
|
|
|
|
elseif(PSP)
|
|
|
|
set(SDL_CMAKE_PLATFORM psp)
|
2022-11-29 09:48:45 -07:00
|
|
|
elseif(APPLE)
|
|
|
|
if(CMAKE_SYSTEM_NAME MATCHES ".*Darwin.*")
|
2023-01-28 22:12:40 -07:00
|
|
|
set(SDL_CMAKE_PLATFORM Darwin)
|
2022-11-29 09:48:45 -07:00
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES ".*MacOS.*")
|
2023-01-28 22:12:40 -07:00
|
|
|
set(SDL_CMAKE_PLATFORM MacosX)
|
2022-11-29 09:48:45 -07:00
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES ".*tvOS.*")
|
2023-01-28 22:12:40 -07:00
|
|
|
set(SDL_CMAKE_PLATFORM tvOS)
|
2022-11-29 09:48:45 -07:00
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES ".*iOS.*")
|
|
|
|
# !!! FIXME: remove the version check when we start requiring >= 3.14.0
|
|
|
|
if(CMAKE_VERSION VERSION_LESS 3.14)
|
2023-01-28 22:12:40 -07:00
|
|
|
set(SDL_CMAKE_PLATFORM iOS)
|
2022-11-29 09:48:45 -07:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES "Haiku.*")
|
2023-01-28 22:12:40 -07:00
|
|
|
set(SDL_CMAKE_PLATFORM Haiku)
|
2022-11-29 09:48:45 -07:00
|
|
|
elseif(NINTENDO_3DS)
|
2023-01-28 22:12:40 -07:00
|
|
|
set(SDL_CMAKE_PLATFORM n3ds)
|
|
|
|
elseif(PS2)
|
|
|
|
set(SDL_CMAKE_PLATFORM ps2)
|
|
|
|
elseif(VITA)
|
|
|
|
set(SDL_CMAKE_PLATFORM Vita)
|
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES ".*Linux")
|
|
|
|
set(SDL_CMAKE_PLATFORM Linux)
|
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES "kFreeBSD.*")
|
|
|
|
set(SDL_CMAKE_PLATFORM FreeBSD)
|
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES "kNetBSD.*|NetBSD.*")
|
|
|
|
set(SDL_CMAKE_PLATFORM NetBSD)
|
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES "kOpenBSD.*|OpenBSD.*")
|
|
|
|
set(SDL_CMAKE_PLATFORM OpenBSD)
|
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES ".*GNU.*")
|
|
|
|
set(SDL_CMAKE_PLATFORM GNU)
|
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES ".*BSDI.*")
|
|
|
|
set(SDL_CMAKE_PLATFORM BSDi)
|
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES "DragonFly.*|FreeBSD")
|
|
|
|
set(SDL_CMAKE_PLATFORM FreeBSD)
|
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES "SYSV5.*")
|
|
|
|
set(SDL_CMAKE_PLATFORM SYSV5)
|
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES "Solaris.*|SunOS.*")
|
|
|
|
set(SDL_CMAKE_PLATFORM Solaris)
|
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES "HP-UX.*")
|
|
|
|
set(SDL_CMAKE_PLATFORM HPUX)
|
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES "AIX.*")
|
|
|
|
set(SDL_CMAKE_PLATFORM AIX)
|
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES "Minix.*")
|
|
|
|
set(SDL_CMAKE_PLATFORM Minix)
|
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES "Android.*")
|
|
|
|
set(SDL_CMAKE_PLATFORM Android)
|
2023-01-30 11:13:40 -07:00
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES "Emscripten.*")
|
|
|
|
set(SDL_CMAKE_PLATFORM Emscripten)
|
2023-01-28 22:12:40 -07:00
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES "BeOS.*")
|
|
|
|
message_error("BeOS support has been removed as of SDL 2.0.2.")
|
2022-11-29 09:48:45 -07:00
|
|
|
endif()
|
2023-01-28 22:12:40 -07:00
|
|
|
|
2022-11-29 09:48:45 -07:00
|
|
|
if(SDL_CMAKE_PLATFORM)
|
2023-01-28 22:12:40 -07:00
|
|
|
string(TOUPPER "${SDL_CMAKE_PLATFORM}" _upper_platform)
|
|
|
|
set(${_upper_platform} TRUE)
|
|
|
|
else()
|
|
|
|
set(SDL_CMAKE_PLATFORM} "unknown")
|
2022-11-29 09:48:45 -07:00
|
|
|
endif()
|
|
|
|
endmacro()
|
2023-01-09 07:06:45 -07:00
|
|
|
|
|
|
|
function(SDL_DetectCPUArchitecture)
|
2023-01-28 22:12:40 -07:00
|
|
|
set(sdl_cpu_names)
|
|
|
|
if(APPLE AND CMAKE_OSX_ARCHITECTURES)
|
|
|
|
foreach(osx_arch ${CMAKE_OSX_ARCHITECTURES})
|
|
|
|
if(osx_arch STREQUAL "x86_64")
|
|
|
|
list(APPEND sdl_cpu_names "x64")
|
|
|
|
elseif(osx_arch STREQUAL "arm64")
|
|
|
|
list(APPEND sdl_cpu_names "arm64")
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
|
2023-03-14 21:56:55 -06:00
|
|
|
set(sdl_known_archs x64 x86 arm64 arm32 emscripten powerpc64 powerpc32 loongarch64)
|
2023-01-28 22:12:40 -07:00
|
|
|
if(NOT sdl_cpu_names)
|
|
|
|
set(found FALSE)
|
|
|
|
foreach(sdl_known_arch ${sdl_known_archs})
|
|
|
|
if(NOT found)
|
|
|
|
string(TOUPPER "${sdl_known_arch}" sdl_known_arch_upper)
|
|
|
|
set(var_name "SDL_CPU_${sdl_known_arch_upper}")
|
|
|
|
check_cpu_architecture(${sdl_known_arch} ${var_name})
|
|
|
|
if(${var_name})
|
|
|
|
list(APPEND sdl_cpu_names ${sdl_known_arch})
|
|
|
|
set(found TRUE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
foreach(sdl_known_arch ${sdl_known_archs})
|
|
|
|
string(TOUPPER "${sdl_known_arch}" sdl_known_arch_upper)
|
|
|
|
set(var_name "SDL_CPU_${sdl_known_arch_upper}")
|
|
|
|
if(sdl_cpu_names MATCHES "(^|;)${sdl_known_arch}($|;)") # FIXME: use if(IN_LIST)
|
|
|
|
set(${var_name} 1 PARENT_SCOPE)
|
2023-01-09 07:06:45 -07:00
|
|
|
else()
|
2023-01-28 22:12:40 -07:00
|
|
|
set(${var_name} 0 PARENT_SCOPE)
|
2023-01-09 07:06:45 -07:00
|
|
|
endif()
|
|
|
|
endforeach()
|
2023-01-28 22:12:40 -07:00
|
|
|
set(SDL_CPU_NAMES ${sdl_cpu_names} PARENT_SCOPE)
|
2023-01-09 07:06:45 -07:00
|
|
|
endfunction()
|