From 61a566c02a9d611a7c7c38f888745405ad952735 Mon Sep 17 00:00:00 2001 From: Benjamin Eikel Date: Tue, 4 Sep 2012 16:16:20 +0200 Subject: FindSDL: Format documentation --- Modules/FindSDL.cmake | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'Modules/FindSDL.cmake') diff --git a/Modules/FindSDL.cmake b/Modules/FindSDL.cmake index 487c5d3460..22a71b3c31 100644 --- a/Modules/FindSDL.cmake +++ b/Modules/FindSDL.cmake @@ -1,16 +1,16 @@ -# 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 # # 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 -- cgit v1.2.1 From 020d2131ed53444835f53cdc3d32717121fe162f Mon Sep 17 00:00:00 2001 From: Benjamin Eikel Date: Tue, 4 Sep 2012 16:21:16 +0200 Subject: FindSDL: Add version support --- Modules/FindSDL.cmake | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'Modules/FindSDL.cmake') diff --git a/Modules/FindSDL.cmake b/Modules/FindSDL.cmake index 22a71b3c31..9fb50029fd 100644 --- a/Modules/FindSDL.cmake +++ b/Modules/FindSDL.cmake @@ -3,6 +3,7 @@ # 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 @@ -167,7 +168,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) -- cgit v1.2.1 From 38a0f715745257fda16dd748d046fa549a9192d2 Mon Sep 17 00:00:00 2001 From: Benjamin Eikel Date: Tue, 4 Sep 2012 16:59:23 +0200 Subject: FindSDL: Add my copyright tag to all FindSDL_* modules --- Modules/FindSDL.cmake | 1 + 1 file changed, 1 insertion(+) (limited to 'Modules/FindSDL.cmake') diff --git a/Modules/FindSDL.cmake b/Modules/FindSDL.cmake index 9fb50029fd..1f5e78034f 100644 --- a/Modules/FindSDL.cmake +++ b/Modules/FindSDL.cmake @@ -55,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. -- cgit v1.2.1 From 9ed24c5316fc4e9b56e3b491dee2f88b2cbb6f17 Mon Sep 17 00:00:00 2001 From: Benjamin Eikel Date: Tue, 4 Sep 2012 17:20:37 +0200 Subject: FindSDL: Remove from find_... calls PATHS that are set by default Use PATH_SUFFIXES to add SDL parts to standard paths. --- Modules/FindSDL.cmake | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) (limited to 'Modules/FindSDL.cmake') diff --git a/Modules/FindSDL.cmake b/Modules/FindSDL.cmake index 1f5e78034f..5cc219f863 100644 --- a/Modules/FindSDL.cmake +++ b/Modules/FindSDL.cmake @@ -70,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... @@ -90,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) -- cgit v1.2.1