1 # - Locate SDL_ttf library
3 # SDL_TTF_LIBRARIES, the name of the library to link against
4 # SDL_TTF_INCLUDE_DIRS, where to find the headers
5 # SDL_TTF_FOUND, if false, do not try to link against
6 # SDL_TTF_VERSION_STRING - human-readable string containing the version of SDL_ttf
8 # For backward compatiblity the following variables are also set:
9 # SDLTTF_LIBRARY (same value as SDL_TTF_LIBRARIES)
10 # SDLTTF_INCLUDE_DIR (same value as SDL_TTF_INCLUDE_DIRS)
11 # SDLTTF_FOUND (same value as SDL_TTF_FOUND)
13 # $SDLDIR is an environment variable that would
14 # correspond to the ./configure --prefix=$SDLDIR
15 # used in building SDL.
17 # Created by Eric Wing. This was influenced by the FindSDL.cmake
18 # module, but with modifications to recognize OS X frameworks and
19 # additional Unix paths (FreeBSD, etc).
21 #=============================================================================
22 # Copyright 2005-2009 Kitware, Inc.
23 # Copyright 2012 Benjamin Eikel
25 # Distributed under the OSI-approved BSD License (the "License");
26 # see accompanying file Copyright.txt for details.
28 # This software is distributed WITHOUT ANY WARRANTY; without even the
29 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
30 # See the License for more information.
31 #=============================================================================
32 # (To distribute this file outside of CMake, substitute the full
33 # License text for the above reference.)
35 if(NOT SDL_TTF_INCLUDE_DIR AND SDLTTF_INCLUDE_DIR)
36 set(SDL_TTF_INCLUDE_DIR ${SDLTTF_INCLUDE_DIR} CACHE PATH "directory cache
37 entry initialized from old variable name")
39 find_path(SDL_TTF_INCLUDE_DIR SDL_ttf.h
43 PATH_SUFFIXES SDL SDL12 SDL11
46 if(NOT SDL_TTF_LIBRARY AND SDLTTF_LIBRARY)
47 set(SDL_TTF_LIBRARY ${SDLTTF_LIBRARY} CACHE FILEPATH "file cache entry
48 initialized from old variable name")
50 find_library(SDL_TTF_LIBRARY
57 if(SDL_TTF_INCLUDE_DIR AND EXISTS "${SDL_TTF_INCLUDE_DIR}/SDL_ttf.h")
58 file(STRINGS "${SDL_TTF_INCLUDE_DIR}/SDL_ttf.h" SDL_TTF_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_TTF_MAJOR_VERSION[ \t]+[0-9]+$")
59 file(STRINGS "${SDL_TTF_INCLUDE_DIR}/SDL_ttf.h" SDL_TTF_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_TTF_MINOR_VERSION[ \t]+[0-9]+$")
60 file(STRINGS "${SDL_TTF_INCLUDE_DIR}/SDL_ttf.h" SDL_TTF_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_TTF_PATCHLEVEL[ \t]+[0-9]+$")
61 string(REGEX REPLACE "^#define[ \t]+SDL_TTF_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_TTF_VERSION_MAJOR "${SDL_TTF_VERSION_MAJOR_LINE}")
62 string(REGEX REPLACE "^#define[ \t]+SDL_TTF_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_TTF_VERSION_MINOR "${SDL_TTF_VERSION_MINOR_LINE}")
63 string(REGEX REPLACE "^#define[ \t]+SDL_TTF_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL_TTF_VERSION_PATCH "${SDL_TTF_VERSION_PATCH_LINE}")
64 set(SDL_TTF_VERSION_STRING ${SDL_TTF_VERSION_MAJOR}.${SDL_TTF_VERSION_MINOR}.${SDL_TTF_VERSION_PATCH})
65 unset(SDL_TTF_VERSION_MAJOR_LINE)
66 unset(SDL_TTF_VERSION_MINOR_LINE)
67 unset(SDL_TTF_VERSION_PATCH_LINE)
68 unset(SDL_TTF_VERSION_MAJOR)
69 unset(SDL_TTF_VERSION_MINOR)
70 unset(SDL_TTF_VERSION_PATCH)
73 set(SDL_TTF_LIBRARIES ${SDL_TTF_LIBRARY})
74 set(SDL_TTF_INCLUDE_DIRS ${SDL_TTF_INCLUDE_DIR})
76 include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
78 FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL_ttf
79 REQUIRED_VARS SDL_TTF_LIBRARIES SDL_TTF_INCLUDE_DIRS
80 VERSION_VAR SDL_TTF_VERSION_STRING)
82 # for backward compatiblity
83 set(SDLTTF_LIBRARY ${SDL_TTF_LIBRARIES})
84 set(SDLTTF_INCLUDE_DIR ${SDL_TTF_INCLUDE_DIRS})
85 set(SDLTTF_FOUND ${SDL_TTF_FOUND})
87 mark_as_advanced(SDL_TTF_LIBRARY SDL_TTF_INCLUDE_DIR)