CMake: tvOS support/fixes

To use, set the following CMake variables when running CMake's configuration stage:
- CMAKE_SYSTEM_NAME=tvOS
- CMAKE_OSX_SYSROOT=<SDK>  (examples: appletvos, appletvsimulator, appletvos12.4, /full/path/to/AppleTVOS.sdk, etc.)
- CMAKE_OSX_ARCHITECTURES=<semicolon-separated list of CPU architectures> (example: "arm64;x86_64")
This commit is contained in:
David Ludwig 2019-08-27 12:30:20 -04:00
parent b13c951cca
commit ec65a34b8e

View File

@ -118,6 +118,8 @@ elseif(APPLE)
set(DARWIN TRUE) set(DARWIN TRUE)
elseif(CMAKE_SYSTEM_NAME MATCHES ".*MacOS.*") elseif(CMAKE_SYSTEM_NAME MATCHES ".*MacOS.*")
set(MACOSX TRUE) set(MACOSX TRUE)
elseif(CMAKE_SYSTEM_NAME MATCHES ".*tvOS.*")
set(TVOS TRUE)
endif() endif()
# TODO: iOS? # TODO: iOS?
elseif(CMAKE_SYSTEM_NAME MATCHES "BeOS.*") elseif(CMAKE_SYSTEM_NAME MATCHES "BeOS.*")
@ -159,7 +161,7 @@ endif()
# so we'll just use libusb when it's available. libusb does not support iOS, # so we'll just use libusb when it's available. libusb does not support iOS,
# so we default to yes on iOS. # so we default to yes on iOS.
# TODO: Windows can support libusb, the hid.c file just depends on Unix APIs # TODO: Windows can support libusb, the hid.c file just depends on Unix APIs
if(WINDOWS OR IOS OR ANDROID) if(WINDOWS OR IOS OR TVOS OR ANDROID)
set(HIDAPI_SKIP_LIBUSB TRUE) set(HIDAPI_SKIP_LIBUSB TRUE)
else() else()
set(HIDAPI_SKIP_LIBUSB FALSE) set(HIDAPI_SKIP_LIBUSB FALSE)
@ -1449,7 +1451,7 @@ elseif(APPLE)
# !!! FIXME: we need Carbon for some very old API calls in # !!! FIXME: we need Carbon for some very old API calls in
# !!! FIXME: src/video/cocoa/SDL_cocoakeyboard.c, but we should figure out # !!! FIXME: src/video/cocoa/SDL_cocoakeyboard.c, but we should figure out
# !!! FIXME: how to dump those. # !!! FIXME: how to dump those.
if(NOT IOS) if(DARWIN OR MACOSX)
set(SDL_FRAMEWORK_COCOA 1) set(SDL_FRAMEWORK_COCOA 1)
set(SDL_FRAMEWORK_CARBON 1) set(SDL_FRAMEWORK_CARBON 1)
endif() endif()
@ -1483,15 +1485,17 @@ elseif(APPLE)
if(SDL_JOYSTICK) if(SDL_JOYSTICK)
CheckHIDAPI() CheckHIDAPI()
if(HAVE_HIDAPI) if(HAVE_HIDAPI)
if(IOS) if(IOS OR TVOS)
set(SOURCE_FILES ${SOURCE_FILES} ${SDL2_SOURCE_DIR}/src/hidapi/ios/hid.m) set(SOURCE_FILES ${SOURCE_FILES} ${SDL2_SOURCE_DIR}/src/hidapi/ios/hid.m)
set(SDL_FRAMEWORK_COREBLUETOOTH 1) set(SDL_FRAMEWORK_COREBLUETOOTH 1)
endif() endif()
endif() endif()
if (IOS) if(IOS OR TVOS)
file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/iphoneos/*.m ${SDL2_SOURCE_DIR}/src/joystick/steam/*.c) file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/iphoneos/*.m ${SDL2_SOURCE_DIR}/src/joystick/steam/*.c)
set(SDL_JOYSTICK_MFI 1) set(SDL_JOYSTICK_MFI 1)
set(SDL_FRAMEWORK_COREMOTION 1) if(IOS)
set(SDL_FRAMEWORK_COREMOTION 1)
endif()
set(SDL_FRAMEWORK_GAMECONTROLLER 1) set(SDL_FRAMEWORK_GAMECONTROLLER 1)
set(HAVE_SDL_SENSORS 1) set(HAVE_SDL_SENSORS 1)
else() else()
@ -1505,7 +1509,7 @@ elseif(APPLE)
endif() endif()
if(SDL_HAPTIC) if(SDL_HAPTIC)
if (IOS) if (IOS OR TVOS)
file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/dummy/*.c) file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/dummy/*.c)
set(SDL_HAPTIC_DUMMY 1) set(SDL_HAPTIC_DUMMY 1)
else() else()
@ -1522,7 +1526,7 @@ elseif(APPLE)
endif() endif()
if(SDL_POWER) if(SDL_POWER)
if (IOS) if (IOS OR TVOS)
file(GLOB POWER_SOURCES ${SDL2_SOURCE_DIR}/src/power/uikit/*.m) file(GLOB POWER_SOURCES ${SDL2_SOURCE_DIR}/src/power/uikit/*.m)
set(SDL_POWER_UIKIT 1) set(SDL_POWER_UIKIT 1)
else() else()
@ -1561,7 +1565,7 @@ elseif(APPLE)
# iOS hack needed - http://code.google.com/p/ios-cmake/ ? # iOS hack needed - http://code.google.com/p/ios-cmake/ ?
if(SDL_VIDEO) if(SDL_VIDEO)
if (IOS) if (IOS OR TVOS)
set(SDL_VIDEO_DRIVER_UIKIT 1) set(SDL_VIDEO_DRIVER_UIKIT 1)
set(SDL_FRAMEWORK_COREGRAPHICS 1) set(SDL_FRAMEWORK_COREGRAPHICS 1)
set(SDL_FRAMEWORK_QUARTZCORE 1) set(SDL_FRAMEWORK_QUARTZCORE 1)
@ -1581,7 +1585,7 @@ elseif(APPLE)
endif() endif()
if(VIDEO_OPENGLES) if(VIDEO_OPENGLES)
if(IOS) if(IOS OR TVOS)
set(SDL_FRAMEWORK_OPENGLES 1) set(SDL_FRAMEWORK_OPENGLES 1)
set(SDL_VIDEO_OPENGL_ES 1) set(SDL_VIDEO_OPENGL_ES 1)
set(SDL_VIDEO_RENDER_OGL_ES 1) set(SDL_VIDEO_RENDER_OGL_ES 1)
@ -1687,7 +1691,7 @@ elseif(APPLE)
list(APPEND EXTRA_LIBS ${GAMECONTROLLER}) list(APPEND EXTRA_LIBS ${GAMECONTROLLER})
endif() endif()
if(SDL_FRAMEWORK_METAL) if(SDL_FRAMEWORK_METAL)
if(IOS) if(IOS OR TVOS)
find_library(METAL Metal) find_library(METAL Metal)
list(APPEND EXTRA_LIBS ${METAL}) list(APPEND EXTRA_LIBS ${METAL})
else() else()
@ -1699,7 +1703,7 @@ elseif(APPLE)
list(APPEND EXTRA_LIBS ${OPENGLES}) list(APPEND EXTRA_LIBS ${OPENGLES})
endif() endif()
if(SDL_FRAMEWORK_QUARTZCORE) if(SDL_FRAMEWORK_QUARTZCORE)
if(IOS) if(IOS OR TVOS)
find_library(QUARTZCORE QuartzCore) find_library(QUARTZCORE QuartzCore)
list(APPEND EXTRA_LIBS ${QUARTZCORE}) list(APPEND EXTRA_LIBS ${QUARTZCORE})
else() else()
@ -1960,7 +1964,7 @@ if(SDL_SHARED)
if (NOT ANDROID) if (NOT ANDROID)
set_target_properties(SDL2 PROPERTIES DEBUG_POSTFIX ${SDL_CMAKE_DEBUG_POSTFIX}) set_target_properties(SDL2 PROPERTIES DEBUG_POSTFIX ${SDL_CMAKE_DEBUG_POSTFIX})
endif() endif()
if(IOS) if(IOS OR TVOS)
set_property(TARGET SDL2 APPEND_STRING PROPERTY COMPILE_FLAGS "-fobjc-arc") set_property(TARGET SDL2 APPEND_STRING PROPERTY COMPILE_FLAGS "-fobjc-arc")
target_compile_definitions(SDL2 PRIVATE IOS_DYLIB=1) target_compile_definitions(SDL2 PRIVATE IOS_DYLIB=1)
endif() endif()
@ -2006,7 +2010,7 @@ if(SDL_STATIC)
if (NOT ANDROID) if (NOT ANDROID)
set_target_properties(SDL2-static PROPERTIES DEBUG_POSTFIX ${SDL_CMAKE_DEBUG_POSTFIX}) set_target_properties(SDL2-static PROPERTIES DEBUG_POSTFIX ${SDL_CMAKE_DEBUG_POSTFIX})
endif() endif()
if(IOS) if(IOS OR TVOS)
set_property(TARGET SDL2-static APPEND_STRING PROPERTY COMPILE_FLAGS "-fobjc-arc") set_property(TARGET SDL2-static APPEND_STRING PROPERTY COMPILE_FLAGS "-fobjc-arc")
endif() endif()
endif() endif()