forked from rougier/freetype-gl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
183 lines (150 loc) · 4.74 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# Freetype GL - A C OpenGL Freetype engine
#
# Distributed under the OSI-approved BSD 2-Clause License. See accompanying
# file `LICENSE` for more details.
cmake_minimum_required(VERSION 2.8.12)
project(freetype-gl LANGUAGES C CXX)
set(CMAKE_MODULE_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules"
"${CMAKE_MODULE_PATH}"
)
message(STATUS "Building for ${CMAKE_SYSTEM_NAME} target system")
message(STATUS "Building with ${CMAKE_C_COMPILER_ID} compiler")
set(freetype-gl_WITH_GLEW_DEFAULT ON)
if((${CMAKE_SYSTEM_NAME} MATCHES "Darwin") OR
(${CMAKE_SYSTEM_NAME} MATCHES "Android"))
set(freetype-gl_WITH_GLEW_DEFAULT OFF)
endif()
option(freetype-gl_WITH_GLEW
"Use the GLEW library to fetch OpenGL function pointers"
${freetype-gl_WITH_GLEW_DEFAULT})
option(freetype-gl_USE_VAO "Use a VAO to render a vertex_buffer instance (required for forward compatible OpenGL 3.0 contexts)" OFF)
option(freetype-gl_BUILD_DEMOS "Build the freetype-gl example programs" ON)
option(freetype-gl_BUILD_APIDOC "Build the freetype-gl API documentation" ON)
option(freetype-gl_BUILD_HARFBUZZ "Build the freetype-gl harfbuzz support (experimental)" OFF)
option(freetype-gl_BUILD_MAKEFONT "Build the makefont tool" ON)
option(freetype-gl_BUILD_TESTS "Build the tests" ON)
if(${freetype-gl_BUILD_TESTS})
find_package(ImageMagick QUIET COMPONENTS compare)
if(NOT ${ImageMagick_EXECUTABLE_DIR})
message(FATAL_ERROR "ImageMagick was not found. Either provide path to ImageMagick, or disable freetype-gl_BUILD_TESTS option.")
endif()
endif()
include(RequireIncludeFile)
include(RequireFunctionExists)
include(CheckLibraryExists)
include(CheckSymbolExists)
require_include_file(stdbool.h HAVE_STDBOOL_H)
require_include_file(stdint.h HAVE_STDINT_H)
require_include_file(math.h HAVE_MATH_H)
check_library_exists(m cos "" HAVE_MATH_LIBRARY)
if(HAVE_MATH_LIBRARY)
list(APPEND CMAKE_REQUIRED_LIBRARIES m)
set(MATH_LIBRARY m)
endif()
require_function_exists(cos HAVE_COS)
require_function_exists(fabs HAVE_FABS)
require_function_exists(floor HAVE_FLOOR)
require_function_exists(fmod HAVE_FMOD)
require_function_exists(pow HAVE_POW)
require_function_exists(roundf HAVE_ROUNDF)
require_function_exists(round HAVE_ROUND)
require_function_exists(sin HAVE_SIN)
require_function_exists(sqrt HAVE_SQRT)
require_function_exists(tan HAVE_TAN)
check_symbol_exists(M_PI math.h HAVE_M_PI)
if(NOT HAVE_M_PI)
list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_USE_MATH_DEFINES)
check_symbol_exists(M_PI math.h HAVE_M_PI2)
if(NOT HAVE_M_PI2)
message(FATAL_ERROR "`M_PI` not defined in `math.h`.")
else()
add_definitions(-D_USE_MATH_DEFINES)
endif()
endif()
if(NOT MINGW AND (WIN32 OR WIN64))
set(GLEW_ROOT_DIR
${CMAKE_CURRENT_SOURCE_DIR}/windows/glew)
set(ENV{FREETYPE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/windows/freetype)
endif()
find_package(OpenGL REQUIRED)
find_package(Freetype REQUIRED)
if(freetype-gl_WITH_GLEW)
find_package(GLEW REQUIRED)
endif()
include_directories(
${OPENGL_INCLUDE_DIRS}
${FREETYPE_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}
${GLEW_INCLUDE_PATH}
)
if(MSVC)
# _CRT_NONSTDC_NO_DEPRECATE -> remove warning C4996
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE)
endif(MSVC)
if(freetype-gl_USE_VAO)
add_definitions(-DFREETYPE_GL_USE_VAO)
endif(freetype-gl_USE_VAO)
set(FREETYPE_GL_HDR
distance-field.h
edtaa3func.h
font-manager.h
freetype-gl.h
markup.h
opengl.h
platform.h
text-buffer.h
texture-atlas.h
texture-font.h
utf8-utils.h
vec234.h
vector.h
vertex-attribute.h
vertex-buffer.h
)
set(FREETYPE_GL_SRC
distance-field.c
edtaa3func.c
font-manager.c
platform.c
text-buffer.c
texture-atlas.c
texture-font.c
utf8-utils.c
vector.c
vertex-attribute.c
vertex-buffer.c
)
add_library(freetype-gl STATIC
${FREETYPE_GL_SRC}
${FREETYPE_GL_HDR}
)
if(freetype-gl_BUILD_MAKEFONT)
add_executable(makefont makefont.c)
target_link_libraries(makefont
freetype-gl
${OPENGL_LIBRARY}
${FREETYPE_LIBRARIES}
${MATH_LIBRARY}
${GLEW_LIBRARY}
)
if(MSVC AND NOT (MSVC_VERSION LESS 1900))
# prevent error LNK2019: unresolved external symbol _sprintf referenced in function __bdf_parse_properties
# see http://stackoverflow.com/a/32418900/469659
target_link_libraries(makefont "legacy_stdio_definitions.lib")
endif()
endif()
if(freetype-gl_BUILD_APIDOC)
add_subdirectory(doc)
endif()
if(freetype-gl_BUILD_HARFBUZZ)
add_subdirectory(harfbuzz)
endif()
if(freetype-gl_BUILD_DEMOS)
add_subdirectory(demos)
endif()
if(freetype-gl_BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
endif(freetype-gl_BUILD_TESTS)