CMake: iOS support added
When using a recent version of CMake (3.14+), this should make it possible to: - build SDL for iOS, both static and dynamic - build SDL test apps (as iOS .app bundles) - generate a working SDL_config.h for iOS (using SDL_config.h.cmake as a basis) To use, set the following CMake variables when running CMake's configuration stage: - CMAKE_SYSTEM_NAME=iOS - CMAKE_OSX_SYSROOT=<SDK> (examples: iphoneos, iphonesimulator, iphoneos12.4, /full/path/to/iPhoneOS.sdk, etc.) - CMAKE_OSX_ARCHITECTURES=<semicolon-separated list of CPU architectures> (example: "arm64;armv7s") Examples: - for Simulator, using the latest, installed SDK: cmake path/to/SDL -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator -DCMAKE_OSX_ARCHITECTURES=x86_64 - for Device, using the latest, installed SDK, 64-bit only cmake path/to/SDL -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos -DCMAKE_OSX_ARCHITECTURES=arm64 - for Device, using the latest, installed SDK, mixed 32/64 bit cmake path/to/SDL -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos -DCMAKE_OSX_ARCHITECTURES="arm64;armv7s" - for Device, using a specific SDK revision (iOS 12.4, in this example): cmake path/to/SDL -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos12.4 -DCMAKE_OSX_ARCHITECTURES=arm64 - for Simulator, using the latest, installed SDK, and building SDL test apps (as .app bundles): cmake path/to/SDL -DSDL_TEST=1 -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator -DCMAKE_OSX_ARCHITECTURES=x86_64 --HG-- extra : rebase_source : 0c6beeec1886332c685dad6c665085ed4e7f2a3e
This commit is contained in:
parent
ebcfaef81f
commit
36e1615cf0
3 changed files with 136 additions and 33 deletions
|
@ -101,22 +101,52 @@ endforeach(RESOURCE_FILE)
|
|||
file(COPY ${RESOURCE_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
# TODO: Might be easier to make all targets depend on the resources...?
|
||||
add_dependencies(testscale SDL2_test_resoureces)
|
||||
add_dependencies(testrendercopyex SDL2_test_resoureces)
|
||||
add_dependencies(controllermap SDL2_test_resoureces)
|
||||
add_dependencies(testyuv SDL2_test_resoureces)
|
||||
add_dependencies(testgamecontroller SDL2_test_resoureces)
|
||||
add_dependencies(testshape SDL2_test_resoureces)
|
||||
add_dependencies(testshader SDL2_test_resoureces)
|
||||
add_dependencies(testnative SDL2_test_resoureces)
|
||||
add_dependencies(testspriteminimal SDL2_test_resoureces)
|
||||
add_dependencies(testautomation SDL2_test_resoureces)
|
||||
add_dependencies(testcustomcursor SDL2_test_resoureces)
|
||||
add_dependencies(testrendertarget SDL2_test_resoureces)
|
||||
add_dependencies(testsprite2 SDL2_test_resoureces)
|
||||
|
||||
add_dependencies(loopwave SDL2_test_resoureces)
|
||||
add_dependencies(loopwavequeue SDL2_test_resoureces)
|
||||
add_dependencies(testresample SDL2_test_resoureces)
|
||||
add_dependencies(testaudiohotplug SDL2_test_resoureces)
|
||||
add_dependencies(testmultiaudio SDL2_test_resoureces)
|
||||
set(NEEDS_RESOURCES
|
||||
testscale
|
||||
testrendercopyex
|
||||
controllermap
|
||||
testyuv
|
||||
testgamecontroller
|
||||
testshape
|
||||
testshader
|
||||
testnative
|
||||
testspriteminimal
|
||||
testautomation
|
||||
testcustomcursor
|
||||
testrendertarget
|
||||
testsprite2
|
||||
loopwave
|
||||
loopwavequeue
|
||||
testresample
|
||||
testaudiohotplug
|
||||
testmultiaudio
|
||||
)
|
||||
foreach(APP IN LISTS NEEDS_RESOURCES)
|
||||
add_dependencies(${APP} SDL2_test_resoureces)
|
||||
if(APPLE)
|
||||
# Make sure resource files get installed into macOS/iOS .app bundles.
|
||||
target_sources(${APP} PRIVATE "${RESOURCE_FILES}")
|
||||
set_target_properties(${APP} PROPERTIES RESOURCE "${RESOURCE_FILES}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Set Apple App ID / Bundle ID. This is needed to launch apps on some Apple
|
||||
# platforms (iOS, for example).
|
||||
if(APPLE)
|
||||
if(${CMAKE_VERSION} VERSION_LESS "3.7.0")
|
||||
# CMake's 'BUILDSYSTEM_TARGETS' property is only available in
|
||||
# CMake 3.7 and above.
|
||||
message(WARNING "Unable to set Bundle ID for Apple .app builds due to old CMake (pre 3.7).")
|
||||
else()
|
||||
get_property(TARGETS DIRECTORY ${CMAKE_CURRENT_LIST_DIR} PROPERTY BUILDSYSTEM_TARGETS)
|
||||
foreach(CURRENT_TARGET IN LISTS TARGETS)
|
||||
get_property(TARGET_TYPE TARGET ${CURRENT_TARGET} PROPERTY TYPE)
|
||||
if(TARGET_TYPE STREQUAL "EXECUTABLE")
|
||||
set_target_properties("${CURRENT_TARGET}" PROPERTIES
|
||||
MACOSX_BUNDLE_GUI_IDENTIFIER "org.libsdl.${CURRENT_TARGET}"
|
||||
)
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
endif()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue