summaryrefslogtreecommitdiffstats
path: root/Modules/FindSDL.cmake
diff options
context:
space:
mode:
authorDavid Cole <david.cole@kitware.com>2012-09-25 19:18:05 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2012-09-25 19:18:05 (GMT)
commit7d03885d21f02090f4e8876a349869e59845f035 (patch)
tree933b61d65e87c1ffdf1a27d02998c98336711b86 /Modules/FindSDL.cmake
parent1dd41e6c3db89d6fb648c5b11403f3dc6d6097ad (diff)
parent68c6b134d0d994cacda7aa3cb92e930df42d6e23 (diff)
downloadCMake-7d03885d21f02090f4e8876a349869e59845f035.zip
CMake-7d03885d21f02090f4e8876a349869e59845f035.tar.gz
CMake-7d03885d21f02090f4e8876a349869e59845f035.tar.bz2
Merge topic 'ImproveFindSDLxxxModules'
68c6b13 FindSDL: Stay compatible with old input variables 9ed24c5 FindSDL: Remove from find_... calls PATHS that are set by default 38a0f71 FindSDL: Add my copyright tag to all FindSDL_* modules 020d213 FindSDL: Add version support 61a566c FindSDL: Format documentation 22154c7 FindSDL: Update documentation 4541c07 FindSDL: Add version support for FindSDL_ttf a28c247 FindSDL: Use SDL_TTF prefix for variables 9f5dbf4 FindSDL: Update documentation d83f80d FindSDL: Add version support for FindSDL_mixer c10b691 FindSDL: Use SDL_MIXER prefix for variables 03dd6cc FindSDL: Pass SDL_SOUND_LIBRARY to FIND_PACKAGE_HANDLE_STANDARD_ARGS 326beca FindSDL: Use same capitalization for FPHSA as file name cfe5b87 FindSDL: Version support for FindSDL_sound 776d3fe FindSDL: Format the documentation a5194e2 FindSDL: Add "cmake_minimum_required" to "try_compile" project ...
Diffstat (limited to 'Modules/FindSDL.cmake')
-rw-r--r--Modules/FindSDL.cmake60
1 files changed, 31 insertions, 29 deletions
diff --git a/Modules/FindSDL.cmake b/Modules/FindSDL.cmake
index adaec95..9359323 100644
--- a/Modules/FindSDL.cmake
+++ b/Modules/FindSDL.cmake
@@ -1,16 +1,17 @@
-# Locate SDL library
+# - Locate SDL library
# This module defines
-# SDL_LIBRARY, the name of the library to link against
-# SDL_FOUND, if false, do not try to link to SDL
-# SDL_INCLUDE_DIR, where to find SDL.h
+# SDL_LIBRARY, the name of the library to link against
+# SDL_FOUND, if false, do not try to link to SDL
+# SDL_INCLUDE_DIR, where to find SDL.h
+# SDL_VERSION_STRING, human-readable string containing the version of SDL
#
# This module responds to the the flag:
-# SDL_BUILDING_LIBRARY
-# If this is defined, then no SDL_main will be linked in because
-# only applications need main().
-# Otherwise, it is assumed you are building an application and this
-# module will attempt to locate and set the the proper link flags
-# as part of the returned SDL_LIBRARY variable.
+# SDL_BUILDING_LIBRARY
+# If this is defined, then no SDL_main will be linked in because
+# only applications need main().
+# Otherwise, it is assumed you are building an application and this
+# module will attempt to locate and set the the proper link flags
+# as part of the returned SDL_LIBRARY variable.
#
# Don't forget to include SDLmain.h and SDLmain.m your project for the
# OS X framework based version. (Other versions link to -lSDLmain which
@@ -54,6 +55,7 @@
#=============================================================================
# Copyright 2003-2009 Kitware, Inc.
+# Copyright 2012 Benjamin Eikel
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
@@ -68,18 +70,7 @@
find_path(SDL_INCLUDE_DIR SDL.h
HINTS
ENV SDLDIR
- PATH_SUFFIXES include/SDL include
- PATHS
- ~/Library/Frameworks
- /Library/Frameworks
- /usr/local/include/SDL12
- /usr/local/include/SDL11 # FreeBSD ports
- /usr/include/SDL12
- /usr/include/SDL11
- /sw # Fink
- /opt/local # DarwinPorts
- /opt/csw # Blastwave
- /opt
+ PATH_SUFFIXES SDL SDL12 SDL11
)
# SDL-1.1 is the name used by FreeBSD ports...
@@ -88,12 +79,6 @@ find_library(SDL_LIBRARY_TEMP
NAMES SDL SDL-1.1
HINTS
ENV SDLDIR
- PATH_SUFFIXES lib
- PATHS
- /sw
- /opt/local
- /opt/csw
- /opt
)
if(NOT SDL_BUILDING_LIBRARY)
@@ -169,7 +154,24 @@ if(SDL_LIBRARY_TEMP)
set(SDL_LIBRARY_TEMP "${SDL_LIBRARY_TEMP}" CACHE INTERNAL "")
endif()
+if(SDL_INCLUDE_DIR AND EXISTS "${SDL_INCLUDE_DIR}/SDL_version.h")
+ file(STRINGS "${SDL_INCLUDE_DIR}/SDL_version.h" SDL_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_MAJOR_VERSION[ \t]+[0-9]+$")
+ file(STRINGS "${SDL_INCLUDE_DIR}/SDL_version.h" SDL_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_MINOR_VERSION[ \t]+[0-9]+$")
+ file(STRINGS "${SDL_INCLUDE_DIR}/SDL_version.h" SDL_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_PATCHLEVEL[ \t]+[0-9]+$")
+ string(REGEX REPLACE "^#define[ \t]+SDL_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_VERSION_MAJOR "${SDL_VERSION_MAJOR_LINE}")
+ string(REGEX REPLACE "^#define[ \t]+SDL_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_VERSION_MINOR "${SDL_VERSION_MINOR_LINE}")
+ string(REGEX REPLACE "^#define[ \t]+SDL_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL_VERSION_PATCH "${SDL_VERSION_PATCH_LINE}")
+ set(SDL_VERSION_STRING ${SDL_VERSION_MAJOR}.${SDL_VERSION_MINOR}.${SDL_VERSION_PATCH})
+ unset(SDL_VERSION_MAJOR_LINE)
+ unset(SDL_VERSION_MINOR_LINE)
+ unset(SDL_VERSION_PATCH_LINE)
+ unset(SDL_VERSION_MAJOR)
+ unset(SDL_VERSION_MINOR)
+ unset(SDL_VERSION_PATCH)
+endif()
+
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL
- REQUIRED_VARS SDL_LIBRARY SDL_INCLUDE_DIR)
+ REQUIRED_VARS SDL_LIBRARY SDL_INCLUDE_DIR
+ VERSION_VAR SDL_VERSION_STRING)