git repos / blockattack-game

blame: source/misc/cmake/FindSDL2.cmake

normal view · raw

5614ab55 sago007 2016-01-17 13:44 1
# - Try to find SDL2
5614ab55 sago007 2016-01-17 13:44 2
# Once done, this will define
5614ab55 sago007 2016-01-17 13:44 3
#
5614ab55 sago007 2016-01-17 13:44 4
#  SDL2_FOUND - system has SDL2
5614ab55 sago007 2016-01-17 13:44 5
#  SDL2_INCLUDE_DIRS - the SDL2 include directories
5614ab55 sago007 2016-01-17 13:44 6
#  SDL2_LIBRARIES - link these to use SDL2
5614ab55 sago007 2016-01-17 13:44 7
#  SDL2_SDL_LIBRARY - only libSDL2
5614ab55 sago007 2016-01-17 13:44 8
#  SDL2_SDLmain_LIBRARY - only libSDL2main
5614ab55 sago007 2016-01-17 13:44 9
#  SDL2_SOURCES - add this in the source file list of your target (hack for OSX)
5614ab55 sago007 2016-01-17 13:44 10
#
5614ab55 sago007 2016-01-17 13:44 11
# See documentation on how to write CMake scripts at
5614ab55 sago007 2016-01-17 13:44 12
# http://www.cmake.org/Wiki/CMake:How_To_Find_Libraries
5614ab55 sago007 2016-01-17 13:44 13
5614ab55 sago007 2016-01-17 13:44 14
include(LibFindMacros)
5614ab55 sago007 2016-01-17 13:44 15
libfind_pkg_detect(SDL2 sdl2 FIND_PATH SDL.h PATH_SUFFIXES SDL2 FIND_LIBRARY SDL2)
5614ab55 sago007 2016-01-17 13:44 16
5614ab55 sago007 2016-01-17 13:44 17
# Process others than OSX with native SDL normally
5614ab55 sago007 2016-01-17 13:44 18
if(NOT "${SDL2_SDL_LIBRARY}" MATCHES "framework")
5614ab55 sago007 2016-01-17 13:44 19
  if(MINGW)
5614ab55 sago007 2016-01-17 13:44 20
    set(MINGW32_LIBRARY mingw32)
5614ab55 sago007 2016-01-17 13:44 21
    set(SDL2_PROCESS_LIBS ${SDL2_PROCESS_LIBS} MINGW32_LIBRARY)
5614ab55 sago007 2016-01-17 13:44 22
  endif()
5614ab55 sago007 2016-01-17 13:44 23
  find_library(SDL2_SDLmain_LIBRARY
5614ab55 sago007 2016-01-17 13:44 24
    NAMES libSDL2main.a SDL2main
5614ab55 sago007 2016-01-17 13:44 25
    HINTS ${SDL2_PKGCONF_LIBRARY_DIRS}
5614ab55 sago007 2016-01-17 13:44 26
  )
5614ab55 sago007 2016-01-17 13:44 27
  if (SDL2_SDLmain_LIBRARY)
5614ab55 sago007 2016-01-17 13:44 28
    set(SDL2_PROCESS_LIBS ${SDL2_PROCESS_LIBS} SDL2_SDLmain_LIBRARY)
5614ab55 sago007 2016-01-17 13:44 29
  endif()
5614ab55 sago007 2016-01-17 13:44 30
  set(SDL2_PROCESS_LIBS ${SDL2_PROCESS_LIBS} SDL2_SDL_LIBRARY)
5614ab55 sago007 2016-01-17 13:44 31
endif()
5614ab55 sago007 2016-01-17 13:44 32
5614ab55 sago007 2016-01-17 13:44 33
libfind_process(SDL2)
5614ab55 sago007 2016-01-17 13:44 34
5614ab55 sago007 2016-01-17 13:44 35
# Special processing for OSX native SDL
5614ab55 sago007 2016-01-17 13:44 36
if("${SDL2_SDL_LIBRARY}" MATCHES "SDL.framework")
5614ab55 sago007 2016-01-17 13:44 37
  set(SDL2_SOURCES "osx/SDLmain.m")
5614ab55 sago007 2016-01-17 13:44 38
  set(SDL2_LIBRARIES "-framework SDL2")
5614ab55 sago007 2016-01-17 13:44 39
endif()
5614ab55 sago007 2016-01-17 13:44 40
5614ab55 sago007 2016-01-17 13:44 41
# All OSX versions need Cocoa
5614ab55 sago007 2016-01-17 13:44 42
if(APPLE)
5614ab55 sago007 2016-01-17 13:44 43
  set(SDL2_LIBRARIES ${SDL2_LIBRARIES} "-framework Cocoa")
5614ab55 sago007 2016-01-17 13:44 44
endif(APPLE)
e566d265 sago007 2016-01-16 14:19 45
e566d265 sago007 2016-01-16 14:19 46
1970-01-01 00:00 47