File: FindSDL2.cmake

package info (click to toggle)
performous 1.1%2Bgit20181118-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 11,736 kB
  • sloc: cpp: 30,008; ansic: 2,751; sh: 801; xml: 464; python: 374; makefile: 36
file content (45 lines) | stat: -rw-r--r-- 1,380 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# - Try to find SDL2
# Once done, this will define
#
#  SDL2_FOUND - system has SDL2
#  SDL2_INCLUDE_DIRS - the SDL2 include directories
#  SDL2_LIBRARIES - link these to use SDL2
#  SDL2_SDL_LIBRARY - only libSDL2
#  SDL2_SDLmain_LIBRARY - only libSDL2main
#  SDL2_SOURCES - add this in the source file list of your target (hack for OSX)
#
# See documentation on how to write CMake scripts at
# http://www.cmake.org/Wiki/CMake:How_To_Find_Libraries

include(LibFindMacros)
libfind_pkg_detect(SDL2 sdl2 FIND_PATH SDL.h PATH_SUFFIXES SDL2 FIND_LIBRARY SDL2)

# Process others than OSX with native SDL normally
if(NOT "${SDL2_SDL_LIBRARY}" MATCHES "framework")
  if(MINGW)
    set(MINGW32_LIBRARY mingw32)
    set(SDL2_PROCESS_LIBS ${SDL2_PROCESS_LIBS} MINGW32_LIBRARY)
  endif()
  find_library(SDL2_SDLmain_LIBRARY
    NAMES libSDL2main.a SDL2main
    HINTS ${SDL2_PKGCONF_LIBRARY_DIRS}
  )
  if (SDL2_SDLmain_LIBRARY)
    set(SDL2_PROCESS_LIBS ${SDL2_PROCESS_LIBS} SDL2_SDLmain_LIBRARY)
  endif()
  set(SDL2_PROCESS_LIBS ${SDL2_PROCESS_LIBS} SDL2_SDL_LIBRARY)
endif()

libfind_process(SDL2)

# Special processing for OSX native SDL
if("${SDL2_SDL_LIBRARY}" MATCHES "SDL.framework")
  set(SDL2_SOURCES "osx/SDLmain.m")
  set(SDL2_LIBRARIES "-framework SDL2")
endif()

# All OSX versions need Cocoa
if(APPLE)
  set(SDL2_LIBRARIES ${SDL2_LIBRARIES} "-framework Cocoa")
endif(APPLE)