We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4617

Summary: CMakeList for iOS is incomplete - missing Metal.
Product: SDL Reporter: Sev <seivan.heidari>
Component: buildAssignee: Sam Lantinga <slouken>
Status: NEW --- QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: 2.0.9   
Hardware: iPhone/iPod touch   
OS: Other   

Description Sev 2019-05-03 10:01:37 UTC
Building for iOS using CMake will build without Metal support.

Editing `CMakeList` by adding: 

```
if(SDL_VIDEO_RENDER_METAL)
    find_library(METAL Metal)
    list(APPEND EXTRA_LIBS ${METAL})
    file(GLOB RENDERER_SOURCES ${SDL2_SOURCE_DIR}/src/render/metal/*.m)
    set(SOURCE_FILES ${SOURCE_FILES} ${RENDERER_SOURCES})
  endif()
```

And setting `SDL_VIDEO_RENDER_METAL=1` for `target_os == "darwin"`  will fix the issue - however I am not exactly sure what else is missing.

From what I understand, one needs to set a bunch of defines before compiling and it's not clear cut what defines needs to be set before compiling for each platform.
Comment 1 Sev 2019-05-03 10:15:26 UTC
Edit to `CMakeList` needs to go on line 1509 right before:  
`1509# iOS hack needed - http://code.google.com/p/ios-cmake/? `

e.g 

```
 if(SDL_VIDEO_RENDER_METAL)
    find_library(METAL Metal)
    list(APPEND EXTRA_LIBS ${METAL})
    file(GLOB RENDER_SOURCES ${SDL2_SOURCE_DIR}/src/render/metal/*.m)
    set(SOURCE_FILES ${SOURCE_FILES} ${RENDER_SOURCES})
  endif()

  1509   # iOS hack needed - http://code.google.com/p/ios-cmake/ ?
  1510   if(SDL_VIDEO)
  1511     if (IOS)
  1512       set(SDL_VIDEO_DRIVER_UIKIT 1)
  1513       file(GLOB UIKITVIDEO_SOURCES ${SDL2_SOURCE_DIR}/src/video/uikit/*.m)
  1514       set(SOURCE_FILES ${SOURCE_FILES} ${UIKITVIDEO_SOURCES})
  1515     else()
  1516       CheckCOCOA()
  1517       if(VIDEO_OPENGL)
  1518         set(SDL_VIDEO_OPENGL 1)
  1519         set(SDL_VIDEO_OPENGL_CGL 1)
  1520         set(SDL_VIDEO_RENDER_OGL 1)
  1521         set(HAVE_VIDEO_OPENGL TRUE)
  1522       endif()
  1523 
  1524       if(VIDEO_OPENGLES)
  1525         set(SDL_VIDEO_OPENGL_EGL 1)
  1526         set(SDL_VIDEO_OPENGL_ES2 1)
  1527         set(SDL_VIDEO_RENDER_OGL_ES2 1)
  1528         set(HAVE_VIDEO_OPENGLES TRUE)
  1529       endif()
  1530     endif()
  1531   endif()

```
Comment 2 Sev 2019-05-03 10:16:36 UTC
I've noticed that there's also use of `./autoconf` and  `configure` is the idea that CMake is to replace those, or are they supposed to be complimentary?