README-cmake.md (3322B)
1CMake 2================================================================================ 3(www.cmake.org) 4 5SDL's build system was traditionally based on autotools. Over time, this 6approach has suffered from several issues across the different supported 7platforms. 8To solve these problems, a new build system based on CMake is under development. 9It works in parallel to the legacy system, so users can experiment with it 10without complication. 11While still experimental, the build system should be usable on the following 12platforms: 13 14* FreeBSD 15* Linux 16* VS.NET 2010 17* MinGW and Msys 18* macOS, iOS, and tvOS, with support for XCode 19 20 21================================================================================ 22Usage 23================================================================================ 24 25Assuming the source for SDL is located at ~/sdl 26 27 cd ~ 28 mkdir build 29 cd build 30 cmake ../sdl 31 32This will build the static and dynamic versions of SDL in the ~/build directory. 33 34 35================================================================================ 36Usage, iOS/tvOS 37================================================================================ 38 39CMake 3.14+ natively includes support for iOS and tvOS. SDL binaries may be built 40using Xcode or Make, possibly among other build-systems. 41 42When using a recent version of CMake (3.14+), it should be possible to: 43 44- build SDL for iOS, both static and dynamic 45- build SDL test apps (as iOS/tvOS .app bundles) 46- generate a working SDL_config.h for iOS (using SDL_config.h.cmake as a basis) 47 48To use, set the following CMake variables when running CMake's configuration stage: 49 50- `CMAKE_SYSTEM_NAME=<OS>` (either `iOS` or `tvOS`) 51- `CMAKE_OSX_SYSROOT=<SDK>` (examples: `iphoneos`, `iphonesimulator`, `iphoneos12.4`, `/full/path/to/iPhoneOS.sdk`, 52 `appletvos`, `appletvsimulator`, `appletvos12.4`, `/full/path/to/AppleTVOS.sdk`, etc.) 53- `CMAKE_OSX_ARCHITECTURES=<semicolon-separated list of CPU architectures>` (example: "arm64;armv7s;x86_64") 54 55 56### Examples (for iOS/tvOS): 57 58- for iOS-Simulator, using the latest, installed SDK: 59 60 `cmake ~/sdl -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator -DCMAKE_OSX_ARCHITECTURES=x86_64` 61 62- for iOS-Device, using the latest, installed SDK, 64-bit only 63 64 `cmake ~/sdl -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos -DCMAKE_OSX_ARCHITECTURES=arm64` 65 66- for iOS-Device, using the latest, installed SDK, mixed 32/64 bit 67 68 `cmake ~/sdl -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos -DCMAKE_OSX_ARCHITECTURES="arm64;armv7s"` 69 70- for iOS-Device, using a specific SDK revision (iOS 12.4, in this example): 71 72 `cmake ~/sdl -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos12.4 -DCMAKE_OSX_ARCHITECTURES=arm64` 73 74- for iOS-Simulator, using the latest, installed SDK, and building SDL test apps (as .app bundles): 75 76 `cmake ~/sdl -DSDL_TEST=1 -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator -DCMAKE_OSX_ARCHITECTURES=x86_64` 77 78- for tvOS-Simulator, using the latest, installed SDK: 79 80 `cmake ~/sdl -DCMAKE_SYSTEM_NAME=tvOS -DCMAKE_OSX_SYSROOT=appletvsimulator -DCMAKE_OSX_ARCHITECTURES=x86_64` 81 82- for tvOS-Device, using the latest, installed SDK: 83 84 `cmake ~/sdl -DCMAKE_SYSTEM_NAME=tvOS -DCMAKE_OSX_SYSROOT=appletvos -DCMAKE_OSX_ARCHITECTURES=arm64`