summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Eikel <cmake@eikel.org>2012-09-04 14:11:10 (GMT)
committerBrad King <brad.king@kitware.com>2012-09-25 17:52:30 (GMT)
commit4541c078645c367b36949b629ea33c17316cedeb (patch)
tree3e27d4940503df1b2035110ad777b4e031af2a7a
parenta28c24726bc4a7882bdd65604359cb545d49c69b (diff)
downloadCMake-4541c078645c367b36949b629ea33c17316cedeb.zip
CMake-4541c078645c367b36949b629ea33c17316cedeb.tar.gz
CMake-4541c078645c367b36949b629ea33c17316cedeb.tar.bz2
FindSDL: Add version support for FindSDL_ttf
-rw-r--r--Modules/FindSDL_ttf.cmake19
1 files changed, 18 insertions, 1 deletions
diff --git a/Modules/FindSDL_ttf.cmake b/Modules/FindSDL_ttf.cmake
index 3821b36..7ce775b 100644
--- a/Modules/FindSDL_ttf.cmake
+++ b/Modules/FindSDL_ttf.cmake
@@ -58,13 +58,30 @@ find_library(SDL_TTF_LIBRARY
PATH_SUFFIXES lib
)
+if(SDL_TTF_INCLUDE_DIR AND EXISTS "${SDL_TTF_INCLUDE_DIR}/SDL_ttf.h")
+ file(STRINGS "${SDL_TTF_INCLUDE_DIR}/SDL_ttf.h" SDL_TTF_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_TTF_MAJOR_VERSION[ \t]+[0-9]+$")
+ file(STRINGS "${SDL_TTF_INCLUDE_DIR}/SDL_ttf.h" SDL_TTF_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_TTF_MINOR_VERSION[ \t]+[0-9]+$")
+ file(STRINGS "${SDL_TTF_INCLUDE_DIR}/SDL_ttf.h" SDL_TTF_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_TTF_PATCHLEVEL[ \t]+[0-9]+$")
+ string(REGEX REPLACE "^#define[ \t]+SDL_TTF_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_TTF_VERSION_MAJOR "${SDL_TTF_VERSION_MAJOR_LINE}")
+ string(REGEX REPLACE "^#define[ \t]+SDL_TTF_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_TTF_VERSION_MINOR "${SDL_TTF_VERSION_MINOR_LINE}")
+ string(REGEX REPLACE "^#define[ \t]+SDL_TTF_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL_TTF_VERSION_PATCH "${SDL_TTF_VERSION_PATCH_LINE}")
+ set(SDL_TTF_VERSION_STRING ${SDL_TTF_VERSION_MAJOR}.${SDL_TTF_VERSION_MINOR}.${SDL_TTF_VERSION_PATCH})
+ unset(SDL_TTF_VERSION_MAJOR_LINE)
+ unset(SDL_TTF_VERSION_MINOR_LINE)
+ unset(SDL_TTF_VERSION_PATCH_LINE)
+ unset(SDL_TTF_VERSION_MAJOR)
+ unset(SDL_TTF_VERSION_MINOR)
+ unset(SDL_TTF_VERSION_PATCH)
+endif()
+
set(SDL_TTF_LIBRARIES ${SDL_TTF_LIBRARY})
set(SDL_TTF_INCLUDE_DIRS ${SDL_TTF_INCLUDE_DIR})
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL_ttf
- REQUIRED_VARS SDL_TTF_LIBRARIES SDL_TTF_INCLUDE_DIRS)
+ REQUIRED_VARS SDL_TTF_LIBRARIES SDL_TTF_INCLUDE_DIRS
+ VERSION_VAR SDL_TTF_VERSION_STRING)
# for backward compatiblity
set(SDLTTF_LIBRARY ${SDL_TTF_LIBRARIES})