From ad27e192f4fe8600f2fe296747bf67337989c5a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 4 Feb 2016 19:29:00 +0100 Subject: [PATCH] modules: link also all required frameworks when finding SDL2 on iOS. --- modules/FindMagnum.cmake | 4 ++-- modules/FindSDL2.cmake | 30 ++++++++++++++++++++++++++++-- src/Magnum/Platform/CMakeLists.txt | 2 +- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/modules/FindMagnum.cmake b/modules/FindMagnum.cmake index c3db765d6..0a9e8698c 100644 --- a/modules/FindMagnum.cmake +++ b/modules/FindMagnum.cmake @@ -402,8 +402,8 @@ foreach(component ${Magnum_FIND_COMPONENTS}) elseif(${component} STREQUAL Sdl2Application) find_package(SDL2) if(SDL2_FOUND) - set(_MAGNUM_${_COMPONENT}_LIBRARIES ${SDL2_LIBRARY}) - set(_MAGNUM_${_COMPONENT}_INCLUDE_DIRS ${SDL2_INCLUDE_DIR}) + set(_MAGNUM_${_COMPONENT}_LIBRARIES ${SDL2_LIBRARIES}) + set(_MAGNUM_${_COMPONENT}_INCLUDE_DIRS ${SDL2_INCLUDE_DIRS}) else() unset(MAGNUM_${_COMPONENT}_LIBRARY) endif() diff --git a/modules/FindSDL2.cmake b/modules/FindSDL2.cmake index aa95cbf12..e3e0aa5f0 100644 --- a/modules/FindSDL2.cmake +++ b/modules/FindSDL2.cmake @@ -3,8 +3,12 @@ # This module defines: # # SDL2_FOUND - True if SDL2 library is found -# SDL2_LIBRARY - SDL2 dynamic library -# SDL2_INCLUDE_DIR - Include dir +# SDL2_LIBRARIES - SDL2 library and dependent libraries +# SDL2_INCLUDE_DIRS - Root include dir and include dirs of dependencies +# +# Additionally these variables are defined for internal usage: +# SDL2_INCLUDE_DIR - Root include dir (w/o dependencies) +# SDL2_LIBRARY - SDL2 library (w/o dependencies) # # @@ -61,7 +65,29 @@ find_path(SDL2_INCLUDE_DIR NAMES SDL_scancode.h PATH_SUFFIXES ${_SDL2_PATH_SUFFIXES}) +# iOS dependencies +if(CORRADE_TARGET_IOS) + set(_SDL2_FRAMEWORKS + AudioToolbox + CoreGraphics + CoreMotion + Foundation + GameController + QuartzCore + UIKit) + set(_SDL2_FRAMEWORK_LIBRARIES ) + foreach(framework ${_SDL2_FRAMEWORKS}) + find_library(_SDL2_${framework}_LIBRARY ${framework}) + list(APPEND _SDL2_FRAMEWORK_LIBRARIES ${_SDL2_${framework}_LIBRARY}) + list(APPEND _SDL2_FRAMEWORK_LIBRARY_NAMES _SDL2_${framework}_LIBRARY) + endforeach() +endif() + include(FindPackageHandleStandardArgs) find_package_handle_standard_args("SDL2" DEFAULT_MSG ${SDL2_LIBRARY_NEEDED} + ${_SDL2_FRAMEWORK_LIBRARY_NAMES} SDL2_INCLUDE_DIR) + +set(SDL2_INCLUDE_DIRS ${SDL2_INCLUDE_DIR}) +set(SDL2_LIBRARIES ${SDL2_LIBRARY} ${_SDL2_FRAMEWORK_LIBRARIES}) diff --git a/src/Magnum/Platform/CMakeLists.txt b/src/Magnum/Platform/CMakeLists.txt index 7c2731979..bd7c7067c 100644 --- a/src/Magnum/Platform/CMakeLists.txt +++ b/src/Magnum/Platform/CMakeLists.txt @@ -127,7 +127,7 @@ if(WITH_SDL2APPLICATION) message(FATAL_ERROR "SDL2 library, required by Sdl2Application, was not found. Set WITH_SDL2APPLICATION to OFF to skip building it.") endif() - include_directories(${SDL2_INCLUDE_DIR}) + include_directories(${SDL2_INCLUDE_DIRS}) set(MagnumSdl2Application_SRCS Sdl2Application.cpp