CMake: tvOS support/fixes
authorDavid Ludwig <dludwig@pobox.com>
Tue, 27 Aug 2019 12:30:20 -0400
changeset 13084c3880ebab198
parent 13083 6d31d5218c2c
child 13085 ced7e9670370
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")
CMakeLists.txt
     1.1 --- a/CMakeLists.txt	Tue Aug 27 11:07:43 2019 -0400
     1.2 +++ b/CMakeLists.txt	Tue Aug 27 12:30:20 2019 -0400
     1.3 @@ -118,6 +118,8 @@
     1.4      set(DARWIN TRUE)
     1.5    elseif(CMAKE_SYSTEM_NAME MATCHES ".*MacOS.*")
     1.6      set(MACOSX TRUE)
     1.7 +  elseif(CMAKE_SYSTEM_NAME MATCHES ".*tvOS.*")
     1.8 +    set(TVOS TRUE)
     1.9    endif()
    1.10    # TODO: iOS?
    1.11  elseif(CMAKE_SYSTEM_NAME MATCHES "BeOS.*")
    1.12 @@ -159,7 +161,7 @@
    1.13  #  so we'll just use libusb when it's available. libusb does not support iOS,
    1.14  #  so we default to yes on iOS.
    1.15  #  TODO: Windows can support libusb, the hid.c file just depends on Unix APIs
    1.16 -if(WINDOWS OR IOS OR ANDROID)
    1.17 +if(WINDOWS OR IOS OR TVOS OR ANDROID)
    1.18    set(HIDAPI_SKIP_LIBUSB TRUE)
    1.19  else()
    1.20    set(HIDAPI_SKIP_LIBUSB FALSE)
    1.21 @@ -1449,7 +1451,7 @@
    1.22    # !!! FIXME: we need Carbon for some very old API calls in
    1.23    # !!! FIXME:  src/video/cocoa/SDL_cocoakeyboard.c, but we should figure out
    1.24    # !!! FIXME:  how to dump those.
    1.25 -  if(NOT IOS)
    1.26 +  if(DARWIN OR MACOSX)
    1.27      set(SDL_FRAMEWORK_COCOA 1)
    1.28      set(SDL_FRAMEWORK_CARBON 1)
    1.29    endif()
    1.30 @@ -1483,15 +1485,17 @@
    1.31    if(SDL_JOYSTICK)
    1.32      CheckHIDAPI()
    1.33      if(HAVE_HIDAPI)
    1.34 -      if(IOS)
    1.35 +      if(IOS OR TVOS)
    1.36          set(SOURCE_FILES ${SOURCE_FILES} ${SDL2_SOURCE_DIR}/src/hidapi/ios/hid.m)
    1.37          set(SDL_FRAMEWORK_COREBLUETOOTH 1)
    1.38        endif()
    1.39      endif()
    1.40 -    if (IOS)
    1.41 +    if(IOS OR TVOS)
    1.42        file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/iphoneos/*.m ${SDL2_SOURCE_DIR}/src/joystick/steam/*.c)
    1.43        set(SDL_JOYSTICK_MFI 1)
    1.44 -      set(SDL_FRAMEWORK_COREMOTION 1)
    1.45 +      if(IOS)
    1.46 +        set(SDL_FRAMEWORK_COREMOTION 1)
    1.47 +      endif()
    1.48        set(SDL_FRAMEWORK_GAMECONTROLLER 1)
    1.49        set(HAVE_SDL_SENSORS 1)
    1.50      else()
    1.51 @@ -1505,7 +1509,7 @@
    1.52    endif()
    1.53  
    1.54    if(SDL_HAPTIC)
    1.55 -    if (IOS)
    1.56 +    if (IOS OR TVOS)
    1.57        file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/dummy/*.c)
    1.58        set(SDL_HAPTIC_DUMMY 1)
    1.59      else()
    1.60 @@ -1522,7 +1526,7 @@
    1.61    endif()
    1.62  
    1.63    if(SDL_POWER)
    1.64 -    if (IOS)
    1.65 +    if (IOS OR TVOS)
    1.66        file(GLOB POWER_SOURCES ${SDL2_SOURCE_DIR}/src/power/uikit/*.m)
    1.67        set(SDL_POWER_UIKIT 1)
    1.68      else()
    1.69 @@ -1561,7 +1565,7 @@
    1.70  
    1.71    # iOS hack needed - http://code.google.com/p/ios-cmake/ ?
    1.72    if(SDL_VIDEO)
    1.73 -    if (IOS)
    1.74 +    if (IOS OR TVOS)
    1.75        set(SDL_VIDEO_DRIVER_UIKIT 1)
    1.76        set(SDL_FRAMEWORK_COREGRAPHICS 1)
    1.77        set(SDL_FRAMEWORK_QUARTZCORE 1)
    1.78 @@ -1581,7 +1585,7 @@
    1.79      endif()
    1.80  
    1.81      if(VIDEO_OPENGLES)
    1.82 -      if(IOS)
    1.83 +      if(IOS OR TVOS)
    1.84          set(SDL_FRAMEWORK_OPENGLES 1)
    1.85          set(SDL_VIDEO_OPENGL_ES 1)
    1.86          set(SDL_VIDEO_RENDER_OGL_ES 1)
    1.87 @@ -1687,7 +1691,7 @@
    1.88      list(APPEND EXTRA_LIBS ${GAMECONTROLLER})
    1.89    endif()
    1.90    if(SDL_FRAMEWORK_METAL)
    1.91 -    if(IOS)
    1.92 +    if(IOS OR TVOS)
    1.93        find_library(METAL Metal)
    1.94        list(APPEND EXTRA_LIBS ${METAL})
    1.95      else()
    1.96 @@ -1699,7 +1703,7 @@
    1.97      list(APPEND EXTRA_LIBS ${OPENGLES})
    1.98    endif()
    1.99    if(SDL_FRAMEWORK_QUARTZCORE)
   1.100 -    if(IOS)
   1.101 +    if(IOS OR TVOS)
   1.102        find_library(QUARTZCORE QuartzCore)
   1.103        list(APPEND EXTRA_LIBS ${QUARTZCORE})
   1.104      else()
   1.105 @@ -1960,7 +1964,7 @@
   1.106    if (NOT ANDROID)
   1.107      set_target_properties(SDL2 PROPERTIES DEBUG_POSTFIX ${SDL_CMAKE_DEBUG_POSTFIX})
   1.108    endif()
   1.109 -  if(IOS)
   1.110 +  if(IOS OR TVOS)
   1.111      set_property(TARGET SDL2 APPEND_STRING PROPERTY COMPILE_FLAGS "-fobjc-arc")
   1.112      target_compile_definitions(SDL2 PRIVATE IOS_DYLIB=1)
   1.113    endif()
   1.114 @@ -2006,7 +2010,7 @@
   1.115    if (NOT ANDROID)
   1.116      set_target_properties(SDL2-static PROPERTIES DEBUG_POSTFIX ${SDL_CMAKE_DEBUG_POSTFIX})
   1.117    endif()
   1.118 -  if(IOS)
   1.119 +  if(IOS OR TVOS)
   1.120      set_property(TARGET SDL2-static APPEND_STRING PROPERTY COMPILE_FLAGS "-fobjc-arc")
   1.121    endif()
   1.122  endif()