forked from opdenkamp/xbmc
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[cmake] Change FindSdl.cmake to support SDL1 on OSX
- Loading branch information
1 parent
ba91fe4
commit 896ab7e
Showing
1 changed file
with
38 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,46 @@ | ||
# - Try to find SDL2 | ||
# Once done this will define | ||
#.rst: | ||
# FindSDL | ||
# ------- | ||
# Finds the SDL library | ||
# | ||
# SDL_FOUND - system has libSDL | ||
# SDL_INCLUDE_DIRS - the libSDL include directory | ||
# SDL_LIBRARIES - The libSDL libraries | ||
# This will will define the following variables:: | ||
# | ||
# SDL_FOUND - system has SDL | ||
# SDL_INCLUDE_DIRS - the SDL include directory | ||
# SDL_LIBRARIES - the SDL libraries | ||
# SDL_DEFINITIONS - the SDL compile definitions | ||
|
||
if(PKG_CONFIG_FOUND) | ||
pkg_check_modules (SDL sdl2) | ||
else() | ||
find_package(SDL) | ||
list(APPEND SDL_INCLUDE_DIRS ${SDL_INCLUDE_DIR}) | ||
list(APPEND SDL_LIBRARIES ${SDL_LIBRARIES}) | ||
pkg_check_modules(PC_SDL2 sdl2 QUIET) | ||
if(PC_SDL2_FOUND) | ||
set(SDL_VERSION ${PC_SDL2_VERSION}) | ||
else() | ||
pkg_check_modules(PC_SDL1 sdl QUIET) | ||
if(PC_SDL1_FOUND) | ||
set(SDL_VERSION ${PC_SDL1_VERSION}) | ||
endif() | ||
endif() | ||
endif() | ||
|
||
find_path(SDL_INCLUDE_DIR SDL/SDL.h | ||
PATHS ${PC_SDL2_INCLUDE_DIR} ${PC_SDL1_INCLUDE_DIR}) | ||
find_library(SDL_LIBRARY NAMES SDL2 SDL | ||
PATHS ${PC_SDL2_LIBDIR} ${PC_SDL1_LIBDIR}) | ||
|
||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(Sdl DEFAULT_MSG SDL_INCLUDE_DIRS SDL_LIBRARIES) | ||
find_package_handle_standard_args(Sdl REQUIRED_VARS SDL_LIBRARY SDL_INCLUDE_DIR | ||
VERSION_VAR SDL_VERSION) | ||
|
||
list(APPEND SDL_DEFINITIONS -DHAVE_SDL=1) | ||
if(SDL_FOUND) | ||
set(SDL_LIBRARIES ${SDL_LIBRARY}) | ||
set(SDL_INCLUDE_DIRS ${SDL_INCLUDE_DIR}) | ||
set(SDL_DEFINITIONS -DHAVE_SDL=1) | ||
|
||
if(SDL_VERSION VERSION_GREATER 2) | ||
list(APPEND SDL_DEFINITIONS -DHAVE_SDL_VERSION=2) | ||
elseif(SDL_VERSION VERSION_GREATER 1) | ||
list(APPEND SDL_DEFINITIONS -DHAVE_SDL_VERSION=1) | ||
endif() | ||
endif() | ||
|
||
mark_as_advanced(SDL_INCLUDE_DIRS SDL_LIBRARIES SDL_DEFINITIONS) | ||
mark_as_advanced(SDL_LIBRARY SDL_INCLUDE_DIR) |