summary refs log tree commit diff stats
path: root/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake')
-rw-r--r--cmake/FindSDL2_TTF.cmake98
1 files changed, 98 insertions, 0 deletions
diff --git a/cmake/FindSDL2_TTF.cmake b/cmake/FindSDL2_TTF.cmake new file mode 100644 index 0000000..8b2edcb --- /dev/null +++ b/cmake/FindSDL2_TTF.cmake
@@ -0,0 +1,98 @@
1# Locate SDL_ttf library
2#
3# This module defines:
4#
5# ::
6#
7# SDL2_TTF_LIBRARIES, the name of the library to link against
8# SDL2_TTF_INCLUDE_DIRS, where to find the headers
9# SDL2_TTF_FOUND, if false, do not try to link against
10# SDL2_TTF_VERSION_STRING - human-readable string containing the version of SDL_ttf
11#
12#
13#
14# For backward compatibility the following variables are also set:
15#
16# ::
17#
18# SDLTTF_LIBRARY (same value as SDL2_TTF_LIBRARIES)
19# SDLTTF_INCLUDE_DIR (same value as SDL2_TTF_INCLUDE_DIRS)
20# SDLTTF_FOUND (same value as SDL2_TTF_FOUND)
21#
22#
23#
24# $SDLDIR is an environment variable that would correspond to the
25# ./configure --prefix=$SDLDIR used in building SDL.
26#
27# Created by Eric Wing. This was influenced by the FindSDL.cmake
28# module, but with modifications to recognize OS X frameworks and
29# additional Unix paths (FreeBSD, etc).
30
31#=============================================================================
32# Copyright 2005-2009 Kitware, Inc.
33# Copyright 2012 Benjamin Eikel
34#
35# Distributed under the OSI-approved BSD License (the "License");
36# see accompanying file Copyright.txt for details.
37#
38# This software is distributed WITHOUT ANY WARRANTY; without even the
39# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
40# See the License for more information.
41#=============================================================================
42# (To distribute this file outside of CMake, substitute the full
43# License text for the above reference.)
44
45find_path(SDL2_TTF_INCLUDE_DIR SDL_ttf.h
46 HINTS
47 ENV SDL2TTFDIR
48 ENV SDL2DIR
49 PATH_SUFFIXES SDL2
50 # path suffixes to search inside ENV{SDLDIR}
51 include/SDL2 include
52 PATHS ${SDL2_TTF_PATH}
53 )
54
55if (CMAKE_SIZEOF_VOID_P EQUAL 8)
56 set(VC_LIB_PATH_SUFFIX lib/x64)
57else ()
58 set(VC_LIB_PATH_SUFFIX lib/x86)
59endif ()
60
61find_library(SDL2_TTF_LIBRARY
62 NAMES SDL2_ttf
63 HINTS
64 ENV SDL2TTFDIR
65 ENV SDL2DIR
66 PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX}
67 PATHS ${SDL2_TTF_PATH}
68 )
69
70if (SDL2_TTF_INCLUDE_DIR AND EXISTS "${SDL2_TTF_INCLUDE_DIR}/SDL_ttf.h")
71 file(STRINGS "${SDL2_TTF_INCLUDE_DIR}/SDL_ttf.h" SDL2_TTF_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_TTF_MAJOR_VERSION[ \t]+[0-9]+$")
72 file(STRINGS "${SDL2_TTF_INCLUDE_DIR}/SDL_ttf.h" SDL2_TTF_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_TTF_MINOR_VERSION[ \t]+[0-9]+$")
73 file(STRINGS "${SDL2_TTF_INCLUDE_DIR}/SDL_ttf.h" SDL2_TTF_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_TTF_PATCHLEVEL[ \t]+[0-9]+$")
74 string(REGEX REPLACE "^#define[ \t]+SDL_TTF_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_TTF_VERSION_MAJOR "${SDL2_TTF_VERSION_MAJOR_LINE}")
75 string(REGEX REPLACE "^#define[ \t]+SDL_TTF_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_TTF_VERSION_MINOR "${SDL2_TTF_VERSION_MINOR_LINE}")
76 string(REGEX REPLACE "^#define[ \t]+SDL_TTF_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL2_TTF_VERSION_PATCH "${SDL2_TTF_VERSION_PATCH_LINE}")
77 set(SDL2_TTF_VERSION_STRING ${SDL2_TTF_VERSION_MAJOR}.${SDL2_TTF_VERSION_MINOR}.${SDL2_TTF_VERSION_PATCH})
78 unset(SDL2_TTF_VERSION_MAJOR_LINE)
79 unset(SDL2_TTF_VERSION_MINOR_LINE)
80 unset(SDL2_TTF_VERSION_PATCH_LINE)
81 unset(SDL2_TTF_VERSION_MAJOR)
82 unset(SDL2_TTF_VERSION_MINOR)
83 unset(SDL2_TTF_VERSION_PATCH)
84endif ()
85
86set(SDL2_TTF_LIBRARIES ${SDL2_TTF_LIBRARY})
87set(SDL2_TTF_INCLUDE_DIRS ${SDL2_TTF_INCLUDE_DIR})
88
89include(FindPackageHandleStandardArgs)
90
91FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_ttf
92 REQUIRED_VARS SDL2_TTF_LIBRARIES SDL2_TTF_INCLUDE_DIRS
93 VERSION_VAR SDL2_TTF_VERSION_STRING)
94
95# for backward compatibility
96set(SDLTTF_LIBRARY ${SDL2_TTF_LIBRARIES})
97set(SDLTTF_INCLUDE_DIR ${SDL2_TTF_INCLUDE_DIRS})
98set(SDLTTF_FOUND ${SDL2_TTF_FOUND})