aboutsummaryrefslogtreecommitdiff
path: root/cmake/modules/FindSdl.cmake
diff options
context:
space:
mode:
authorh.udo <hudokkow@gmail.com>2016-09-08 18:15:54 +0100
committerh.udo <hudokkow@gmail.com>2016-12-21 10:04:18 +0000
commita18701e7b2fe03780f90502d5d51e09cdc3ad718 (patch)
treea9d2c2cca8599a18a78c6b1345f42e48e76ddb27 /cmake/modules/FindSdl.cmake
parentf2b31fda391d3364b7307ab9f9216fa0ee7164c7 (diff)
[cmake] Move to root folder: Move files
Diffstat (limited to 'cmake/modules/FindSdl.cmake')
-rw-r--r--cmake/modules/FindSdl.cmake46
1 files changed, 46 insertions, 0 deletions
diff --git a/cmake/modules/FindSdl.cmake b/cmake/modules/FindSdl.cmake
new file mode 100644
index 0000000000..91bcac5bf7
--- /dev/null
+++ b/cmake/modules/FindSdl.cmake
@@ -0,0 +1,46 @@
+#.rst:
+# FindSDL
+# -------
+# Finds the SDL library
+#
+# 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(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 REQUIRED_VARS SDL_LIBRARY SDL_INCLUDE_DIR
+ VERSION_VAR SDL_VERSION)
+
+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_LIBRARY SDL_INCLUDE_DIR)