Fixed building for simulators or older iOS SDKs
authorSam Lantinga <slouken@libsdl.org>
Thu, 07 Dec 2017 17:47:01 -0800
changeset 11733490588c02a65
parent 11732 ad13456d6e7f
child 11734 6d6dc7d2a704
Fixed building for simulators or older iOS SDKs
Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj
include/SDL_config_iphoneos.h
src/render/metal/SDL_render_metal.m
src/video/uikit/SDL_uikitmetalview.h
src/video/uikit/SDL_uikitmetalview.m
     1.1 --- a/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj	Thu Dec 07 17:12:03 2017 -0800
     1.2 +++ b/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj	Thu Dec 07 17:47:01 2017 -0800
     1.3 @@ -1691,7 +1691,6 @@
     1.4  				GCC_WARN_UNINITIALIZED_AUTOS = YES;
     1.5  				GCC_WARN_UNUSED_FUNCTION = YES;
     1.6  				GCC_WARN_UNUSED_VARIABLE = YES;
     1.7 -				IPHONEOS_DEPLOYMENT_TARGET = 6.1;
     1.8  				ONLY_ACTIVE_ARCH = YES;
     1.9  				SDKROOT = iphoneos;
    1.10  				TARGETED_DEVICE_FAMILY = "1,2";
    1.11 @@ -1728,7 +1727,6 @@
    1.12  				GCC_WARN_UNINITIALIZED_AUTOS = YES;
    1.13  				GCC_WARN_UNUSED_FUNCTION = YES;
    1.14  				GCC_WARN_UNUSED_VARIABLE = YES;
    1.15 -				IPHONEOS_DEPLOYMENT_TARGET = 6.1;
    1.16  				SDKROOT = iphoneos;
    1.17  				TARGETED_DEVICE_FAMILY = "1,2";
    1.18  			};
    1.19 @@ -1864,6 +1862,7 @@
    1.20  				GCC_WARN_STRICT_SELECTOR_MATCH = YES;
    1.21  				GCC_WARN_UNDECLARED_SELECTOR = YES;
    1.22  				HEADER_SEARCH_PATHS = "$(VULKAN_SDK)/include";
    1.23 +				IPHONEOS_DEPLOYMENT_TARGET = 8.0;
    1.24  				PRODUCT_NAME = SDL2;
    1.25  				SKIP_INSTALL = YES;
    1.26  			};
    1.27 @@ -1881,6 +1880,7 @@
    1.28  				GCC_WARN_STRICT_SELECTOR_MATCH = YES;
    1.29  				GCC_WARN_UNDECLARED_SELECTOR = YES;
    1.30  				HEADER_SEARCH_PATHS = "$(VULKAN_SDK)/include";
    1.31 +				IPHONEOS_DEPLOYMENT_TARGET = 8.0;
    1.32  				PRODUCT_NAME = SDL2;
    1.33  				SKIP_INSTALL = YES;
    1.34  			};
     2.1 --- a/include/SDL_config_iphoneos.h	Thu Dec 07 17:12:03 2017 -0800
     2.2 +++ b/include/SDL_config_iphoneos.h	Thu Dec 07 17:47:01 2017 -0800
     2.3 @@ -148,18 +148,25 @@
     2.4  #define SDL_VIDEO_DRIVER_UIKIT  1
     2.5  #define SDL_VIDEO_DRIVER_DUMMY  1
     2.6  
     2.7 -/* enable OpenGL ES */
     2.8 +/* Enable OpenGL ES */
     2.9  #define SDL_VIDEO_OPENGL_ES2 1
    2.10  #define SDL_VIDEO_OPENGL_ES 1
    2.11  #define SDL_VIDEO_RENDER_OGL_ES 1
    2.12  #define SDL_VIDEO_RENDER_OGL_ES2    1
    2.13  
    2.14 -/* Enable Metal and Vulkan support on 64-bit devices when an iOS 8+ SDK is used. */
    2.15 -#if !TARGET_OS_SIMULATOR && !TARGET_CPU_ARM && defined(__IPHONE_8_0)
    2.16 +/* Metal supported on 64-bit devices running iOS 8.0 and tvOS 9.0 and newer */
    2.17 +#if !TARGET_OS_SIMULATOR && !TARGET_CPU_ARM && ((__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 90000))
    2.18 +#define SDL_PLATFORM_SUPPORTS_METAL	1
    2.19 +#else
    2.20 +#define SDL_PLATFORM_SUPPORTS_METAL	0
    2.21 +#endif
    2.22 +
    2.23 +#if SDL_PLATFORM_SUPPORTS_METAL
    2.24  #define SDL_VIDEO_RENDER_METAL  1
    2.25 +#endif
    2.26 +
    2.27 +#if SDL_PLATFORM_SUPPORTS_METAL
    2.28  #define SDL_VIDEO_VULKAN 1
    2.29 -#else
    2.30 -#define SDL_VIDEO_VULKAN 0
    2.31  #endif
    2.32  
    2.33  /* Enable system power support */
     3.1 --- a/src/render/metal/SDL_render_metal.m	Thu Dec 07 17:12:03 2017 -0800
     3.2 +++ b/src/render/metal/SDL_render_metal.m	Thu Dec 07 17:47:01 2017 -0800
     3.3 @@ -113,12 +113,12 @@
     3.4  static int
     3.5  IsMetalAvailable(const SDL_SysWMinfo *syswm)
     3.6  {
     3.7 -    if (syswm->subsystem != SDL_SYSWM_COCOA) {  // !!! FIXME: SDL_SYSWM_UIKIT for iOS, too!
     3.8 -        return SDL_SetError("Metal render target only supports Cocoa video target at the moment.");
     3.9 +    if (syswm->subsystem != SDL_SYSWM_COCOA && syswm->subsystem != SDL_SYSWM_UIKIT) {
    3.10 +        return SDL_SetError("Metal render target only supports Cocoa and UIKit video targets at the moment.");
    3.11      }
    3.12  
    3.13      // this checks a weak symbol.
    3.14 -#if MAC_OS_X_VERSION_MIN_REQUIRED < 101100
    3.15 +#if defined(__MACOSX__)
    3.16      if (MTLCreateSystemDefaultDevice == NULL) {  // probably on 10.10 or lower.
    3.17          return SDL_SetError("Metal framework not available on this system");
    3.18      }
     4.1 --- a/src/video/uikit/SDL_uikitmetalview.h	Thu Dec 07 17:12:03 2017 -0800
     4.2 +++ b/src/video/uikit/SDL_uikitmetalview.h	Thu Dec 07 17:47:01 2017 -0800
     4.3 @@ -32,6 +32,8 @@
     4.4  #import "../SDL_sysvideo.h"
     4.5  #import "SDL_uikitwindow.h"
     4.6  
     4.7 +#if SDL_VIDEO_DRIVER_UIKIT && (SDL_VIDEO_RENDER_METAL || SDL_VIDEO_VULKAN)
     4.8 +
     4.9  #import <UIKit/UIKit.h>
    4.10  #import <Metal/Metal.h>
    4.11  #import <QuartzCore/CAMetalLayer.h>
    4.12 @@ -50,6 +52,8 @@
    4.13  
    4.14  void UIKit_Mtl_GetDrawableSize(SDL_Window * window, int * w, int * h);
    4.15  
    4.16 +#endif /* SDL_VIDEO_DRIVER_UIKIT && (SDL_VIDEO_RENDER_METAL || SDL_VIDEO_VULKAN) */
    4.17 +
    4.18  #endif /* SDL_uikitmetalview_h_ */
    4.19  
    4.20  /* vi: set ts=4 sw=4 expandtab: */
     5.1 --- a/src/video/uikit/SDL_uikitmetalview.m	Thu Dec 07 17:12:03 2017 -0800
     5.2 +++ b/src/video/uikit/SDL_uikitmetalview.m	Thu Dec 07 17:47:01 2017 -0800
     5.3 @@ -28,7 +28,7 @@
     5.4  
     5.5  #include "../../SDL_internal.h"
     5.6  
     5.7 -#if SDL_VIDEO_VULKAN && SDL_VIDEO_DRIVER_UIKIT
     5.8 +#if SDL_VIDEO_DRIVER_UIKIT && (SDL_VIDEO_RENDER_METAL || SDL_VIDEO_VULKAN)
     5.9  
    5.10  #import "../SDL_sysvideo.h"
    5.11  #import "SDL_uikitwindow.h"
    5.12 @@ -133,4 +133,4 @@
    5.13      }
    5.14  }
    5.15  
    5.16 -#endif
    5.17 +#endif /* SDL_VIDEO_DRIVER_UIKIT && (SDL_VIDEO_RENDER_METAL || SDL_VIDEO_VULKAN) */