Add SDL2 to iOS

This commit is contained in:
Benau 2020-04-21 10:11:41 +08:00
parent 6db8906adb
commit 5eb7b023b3
4 changed files with 11 additions and 2 deletions

View File

@ -654,7 +654,7 @@ if(NOT SERVER_ONLY)
if(NOT USE_GLES2)
target_link_libraries(supertuxkart ${OPENGL_gl_LIBRARY} ${GLEW_LIBRARIES})
elseif (IOS)
target_link_libraries(supertuxkart "-framework OpenGLES -framework UIKit -framework CoreMotion -framework Foundation -framework GLKit")
target_link_libraries(supertuxkart "-framework QuartzCore -framework CoreGraphics -framework AVFoundation -framework AudioToolbox -framework Metal -framework GameController -framework OpenGLES -framework UIKit -framework CoreAudio -framework CoreMotion -framework Foundation -framework GLKit")
else()
target_link_libraries(supertuxkart GLESv2)
endif()

View File

@ -7,7 +7,7 @@
# You can also use -DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM=xxxxxxxxxx to specify team
# Increase every upload to App store
SET(IOS_BUILD_VERSION 10)
SET(IOS_BUILD_VERSION 13)
# Get SDK path
execute_process(COMMAND xcodebuild -version -sdk iphoneos Path
@ -56,6 +56,8 @@ set(CURL_INCLUDE_DIR ${DEPS_PATH}/ios_arm64/dependencies/include CACHE STRING ""
set(OPENSSL_CRYPTO_LIBRARY ${DEPS_PATH}/ios_arm64/dependencies/lib/libcrypto.a;${DEPS_PATH}/ios_simulator64/dependencies/lib/libcrypto.a CACHE STRING "")
set(OPENSSL_INCLUDE_DIR ${DEPS_PATH}/ios_arm64/dependencies/include CACHE STRING "")
set(LIBRESOLV_LIBRARY ${CMAKE_OSX_SYSROOT_IOS}/usr/lib/libresolv.tbd;${CMAKE_OSX_SYSROOT_SIMULATOR}/usr/lib/libresolv.tbd CACHE STRING "")
set(SDL2_LIBRARY ${DEPS_PATH}/ios_arm64/dependencies/lib/libSDL2.a;${DEPS_PATH}/ios_simulator64/dependencies/lib/libSDL2.a CACHE STRING "")
set(SDL2_INCLUDEDIR ${DEPS_PATH}/ios_arm64/dependencies/include CACHE STRING "")
# Standard config
set(CMAKE_SYSTEM_VERSION ${SDK_VERSION} CACHE INTERNAL "")
@ -92,6 +94,10 @@ set(CMAKE_C_OSX_CURRENT_VERSION_FLAG "-current_version ")
set(CMAKE_CXX_OSX_COMPATIBILITY_VERSION_FLAG "${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}")
set(CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}")
# For archive
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fembed-bitcode")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fembed-bitcode")
# Fixed variables in iOS STK
set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE YES CACHE INTERNAL "")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC NO CACHE INTERNAL "")

View File

@ -20,6 +20,7 @@ SET(CMAKE_FIND_ROOT_PATH ${PROJECT_SOURCE_DIR}/dependencies-ios ${CCTOOLS_PREFIX
set(FREETYPE_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/dependencies-ios/include/freetype2)
set(CURL_LIBRARY "${PROJECT_SOURCE_DIR}/dependencies-ios/lib/libcurl.a;${PROJECT_SOURCE_DIR}/dependencies-ios/lib/libssl.a")
set(PNG_LIBRARY ${PROJECT_SOURCE_DIR}/dependencies-ios/lib/libpng16.a)
set(SDL2_LIBRARY ${PROJECT_SOURCE_DIR}/dependencies-ios/lib/libSDL2.a)
# adjust the default behaviour of the FIND_XXX() commands:
# search headers and libraries in the target environment, search

View File

@ -88,7 +88,9 @@ InputManager::InputManager() : m_mode(BOOTSTRAP),
m_master_player_only = false;
m_timer = 0;
#ifndef SERVER_ONLY
SDL_SetMainReady();
SDL_SetHint(SDL_HINT_NO_SIGNAL_HANDLERS, "1");
SDL_SetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, "0");
if (SDL_Init(SDL_INIT_GAMECONTROLLER) != 0)
{
Log::error("InputManager", "Unable to initialize SDL: %s",