... |
... |
@@ -12,13 +12,17 @@ |
12
|
12
|
# fully.
|
13
|
13
|
#
|
14
|
14
|
#
|
15
|
|
-# The following will 1. create a build directory and 2. change into it and
|
|
15
|
+# The following will (1) create a build directory, and (2) change into it and
|
16
|
16
|
# call cmake to configure the build with default parameters as a static
|
17
|
|
-# library. See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html
|
18
|
|
-# for information about Debug, Release, etc. builds.
|
|
17
|
+# library. See
|
|
18
|
+#
|
|
19
|
+# https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html
|
|
20
|
+#
|
|
21
|
+# for information about debug or release builds, for example
|
19
|
22
|
#
|
20
|
23
|
# cmake -B build -D CMAKE_BUILD_TYPE=Release
|
21
|
24
|
#
|
|
25
|
+#
|
22
|
26
|
# For a dynamic library, use
|
23
|
27
|
#
|
24
|
28
|
# cmake -B build -D BUILD_SHARED_LIBS=true -D CMAKE_BUILD_TYPE=Release
|
... |
... |
@@ -39,7 +43,8 @@ |
39
|
43
|
#
|
40
|
44
|
# cmake -E chdir build cmake -G Xcode -D IOS_PLATFORM=SIMULATOR64 ..
|
41
|
45
|
#
|
42
|
|
-# Finally, build the project with:
|
|
46
|
+#
|
|
47
|
+# Finally, build the project with
|
43
|
48
|
#
|
44
|
49
|
# cmake --build build
|
45
|
50
|
#
|
... |
... |
@@ -56,40 +61,47 @@ |
56
|
61
|
#
|
57
|
62
|
# Some notes.
|
58
|
63
|
#
|
59
|
|
-# . `cmake' creates configuration files in
|
|
64
|
+# - `cmake' creates configuration files in
|
60
|
65
|
#
|
61
|
66
|
# <build-directory>/include/freetype/config
|
62
|
67
|
#
|
63
|
68
|
# which should be further modified if necessary.
|
64
|
69
|
#
|
65
|
|
-# . You can use `cmake' directly on a freshly cloned FreeType git
|
|
70
|
+# - You can use `cmake' directly on a freshly cloned FreeType git
|
66
|
71
|
# repository.
|
67
|
72
|
#
|
68
|
|
-# . `CMakeLists.txt' is provided as-is since it is normally not used by the
|
|
73
|
+# - `CMakeLists.txt' is provided as-is since it is normally not used by the
|
69
|
74
|
# developer team.
|
70
|
75
|
#
|
71
|
|
-# . Set the `FT_WITH_ZLIB', `FT_WITH_BZIP2', `FT_WITH_PNG',
|
72
|
|
-# `FT_WITH_HARFBUZZ', and `FT_WITH_BROTLI' CMake variables to `ON' to
|
73
|
|
-# force using a dependency. Leave a variable undefined (which is the
|
74
|
|
-# default) to use the dependency only if it is available. Example:
|
|
76
|
+# - Set the `FT_REQUIRE_ZLIB', `FT_REQUIRE_BZIP2', `FT_REQUIRE_PNG',
|
|
77
|
+# `FT_REQUIRE_HARFBUZZ', and `FT_REQUIRE_BROTLI' CMake variables to `ON'
|
|
78
|
+# or `TRUE' to force using a dependency. Leave a variable undefined
|
|
79
|
+# (which is the default) to use the dependency only if it is available.
|
|
80
|
+# Example:
|
75
|
81
|
#
|
76
|
|
-# cmake -B build -D FT_WITH_ZLIB=ON \
|
77
|
|
-# -D FT_WITH_BZIP2=ON \
|
78
|
|
-# -D FT_WITH_PNG=ON \
|
79
|
|
-# -D FT_WITH_HARFBUZZ=ON \
|
80
|
|
-# -D FT_WITH_BROTLI=ON [...]
|
|
82
|
+# cmake -B build -D FT_REQUIRE_ZLIB=TRUE \
|
|
83
|
+# -D FT_REQUIRE_BZIP2=TRUE \
|
|
84
|
+# -D FT_REQUIRE_PNG=TRUE \
|
|
85
|
+# -D FT_REQUIRE_HARFBUZZ=TRUE \
|
|
86
|
+# -D FT_REQUIRE_BROTLI=TRUE [...]
|
81
|
87
|
#
|
82
|
|
-# Set `CMAKE_DISABLE_FIND_PACKAGE_XXX=TRUE' to disable a dependency completely
|
83
|
|
-# (where `XXX' is a CMake package name like `BZip2'). Example for disabling all
|
|
88
|
+# - Set `FT_DISABLE_XXX=TRUE' to disable a dependency completely (where
|
|
89
|
+# `XXX' is a CMake package name like `BZip2'). Example for disabling all
|
84
|
90
|
# dependencies:
|
85
|
91
|
#
|
86
|
|
-# cmake -B build -D CMAKE_DISABLE_FIND_PACKAGE_ZLIB=TRUE \
|
87
|
|
-# -D CMAKE_DISABLE_FIND_PACKAGE_BZip2=TRUE \
|
88
|
|
-# -D CMAKE_DISABLE_FIND_PACKAGE_PNG=TRUE \
|
89
|
|
-# -D CMAKE_DISABLE_FIND_PACKAGE_HarfBuzz=TRUE \
|
90
|
|
-# -D CMAKE_DISABLE_FIND_PACKAGE_BrotliDec=TRUE [...]
|
|
92
|
+# cmake -B build -D FT_DISABLE_ZLIB=TRUE \
|
|
93
|
+# -D FT_DISABLE_BZIP2=TRUE \
|
|
94
|
+# -D FT_DISABLE_PNG=TRUE \
|
|
95
|
+# -D FT_DISABLE_HARFBUZZ=TRUE \
|
|
96
|
+# -D FT_DISABLE_BROTLI=TRUE [...]
|
|
97
|
+#
|
|
98
|
+# - NOTE: If a package is set as DISABLED, it cannot be set as REQUIRED
|
|
99
|
+# without unsetting the DISABLED value first. For example, if
|
|
100
|
+# `FT_DISABLE_HARFBUZZ=TRUE' has been set (Cache is present), you need to
|
|
101
|
+# call `FT_DISABLE_HARFBUZZ=FALSE' before calling
|
|
102
|
+# `FT_REQUIRE_HARFBUZZ=TRUE'.
|
91
|
103
|
#
|
92
|
|
-# . Installation of FreeType can be controlled with the CMake variables
|
|
104
|
+# - Installation of FreeType can be controlled with the CMake variables
|
93
|
105
|
# `SKIP_INSTALL_HEADERS', `SKIP_INSTALL_LIBRARIES', and `SKIP_INSTALL_ALL'
|
94
|
106
|
# (this is compatible with the same CMake variables in zlib's CMake
|
95
|
107
|
# support).
|
... |
... |
@@ -109,6 +121,7 @@ if (NOT CMAKE_VERSION VERSION_LESS 3.3) |
109
|
121
|
endif ()
|
110
|
122
|
|
111
|
123
|
include(CheckIncludeFile)
|
|
124
|
+include(CMakeDependentOption)
|
112
|
125
|
|
113
|
126
|
# CMAKE_TOOLCHAIN_FILE must be set before `project' is called, which
|
114
|
127
|
# configures the base build environment and references the toolchain file
|
... |
... |
@@ -171,13 +184,37 @@ string(REGEX REPLACE |
171
|
184
|
math(EXPR LIBRARY_SOVERSION "${LIBTOOL_CURRENT} - ${LIBTOOL_AGE}")
|
172
|
185
|
set(LIBRARY_VERSION "${LIBRARY_SOVERSION}.${LIBTOOL_AGE}.${LIBTOOL_REVISION}")
|
173
|
186
|
|
174
|
|
-# External dependency library detection is automatic. See the notes at the top
|
175
|
|
-# of this file, for how to force or disable dependencies completely.
|
176
|
|
-option(FT_WITH_ZLIB "Use system zlib instead of internal library." OFF)
|
177
|
|
-option(FT_WITH_BZIP2 "Support bzip2 compressed fonts." OFF)
|
178
|
|
-option(FT_WITH_PNG "Support PNG compressed OpenType embedded bitmaps." OFF)
|
179
|
|
-option(FT_WITH_HARFBUZZ "Improve auto-hinting of OpenType fonts." OFF)
|
180
|
|
-option(FT_WITH_BROTLI "Support compressed WOFF2 fonts." OFF)
|
|
187
|
+# External dependency library detection is automatic. See the notes at the
|
|
188
|
+# top of this file, for how to force or disable dependencies completely.
|
|
189
|
+option(FT_DISABLE_ZLIB
|
|
190
|
+ "Disable use of system zlib and use internal zlib library instead." OFF)
|
|
191
|
+cmake_dependent_option(FT_REQUIRE_ZLIB
|
|
192
|
+ "Require system zlib instead of internal zlib library." OFF
|
|
193
|
+ "NOT FT_DISABLE_ZLIB" OFF)
|
|
194
|
+
|
|
195
|
+option(FT_DISABLE_BZIP2
|
|
196
|
+ "Disable support of bzip2 compressed fonts." OFF)
|
|
197
|
+cmake_dependent_option(FT_REQUIRE_BZIP2
|
|
198
|
+ "Require support of bzip2 compressed fonts." OFF
|
|
199
|
+ "NOT FT_DISABLE_BZIP2" OFF)
|
|
200
|
+
|
|
201
|
+option(FT_DISABLE_PNG
|
|
202
|
+ "Disable support of PNG compressed OpenType embedded bitmaps." OFF)
|
|
203
|
+cmake_dependent_option(FT_REQUIRE_PNG
|
|
204
|
+ "Require support of PNG compressed OpenType embedded bitmaps." OFF
|
|
205
|
+ "NOT FT_DISABLE_PNG" OFF)
|
|
206
|
+
|
|
207
|
+option(FT_DISABLE_HARFBUZZ
|
|
208
|
+ "Disable HarfBuzz (used for improving auto-hinting of OpenType fonts)." OFF)
|
|
209
|
+cmake_dependent_option(FT_REQUIRE_HARFBUZZ
|
|
210
|
+ "Require HarfBuzz for improving auto-hinting of OpenType fonts." OFF
|
|
211
|
+ "NOT FT_DISABLE_HARFBUZZ" OFF)
|
|
212
|
+
|
|
213
|
+option(FT_DISABLE_BROTLI
|
|
214
|
+ "Disable support of compressed WOFF2 fonts." OFF)
|
|
215
|
+cmake_dependent_option(FT_REQUIRE_BROTLI
|
|
216
|
+ "Require support of compressed WOFF2 fonts." OFF
|
|
217
|
+ "NOT FT_DISABLE_BROTLI" OFF)
|
181
|
218
|
|
182
|
219
|
|
183
|
220
|
# Disallow in-source builds
|
... |
... |
@@ -208,35 +245,45 @@ endif () |
208
|
245
|
|
209
|
246
|
|
210
|
247
|
# Find dependencies
|
211
|
|
-set(HARFBUZZ_MIN_VERSION "2.0.0")
|
212
|
|
-if (FT_WITH_HARFBUZZ)
|
213
|
|
- find_package(HarfBuzz ${HARFBUZZ_MIN_VERSION} REQUIRED)
|
214
|
|
-else ()
|
215
|
|
- find_package(HarfBuzz ${HARFBUZZ_MIN_VERSION})
|
|
248
|
+if (NOT FT_DISABLE_HARFBUZZ)
|
|
249
|
+ set(HARFBUZZ_MIN_VERSION "2.0.0")
|
|
250
|
+ if (FT_REQUIRE_HARFBUZZ)
|
|
251
|
+ find_package(HarfBuzz ${HARFBUZZ_MIN_VERSION} REQUIRED)
|
|
252
|
+ else ()
|
|
253
|
+ find_package(HarfBuzz ${HARFBUZZ_MIN_VERSION})
|
|
254
|
+ endif ()
|
216
|
255
|
endif ()
|
217
|
256
|
|
218
|
|
-if (FT_WITH_PNG)
|
219
|
|
- find_package(PNG REQUIRED)
|
220
|
|
-else ()
|
221
|
|
- find_package(PNG)
|
|
257
|
+if (NOT FT_DISABLE_PNG)
|
|
258
|
+ if (FT_REQUIRE_PNG)
|
|
259
|
+ find_package(PNG REQUIRED)
|
|
260
|
+ else ()
|
|
261
|
+ find_package(PNG)
|
|
262
|
+ endif ()
|
222
|
263
|
endif ()
|
223
|
264
|
|
224
|
|
-if (FT_WITH_ZLIB)
|
225
|
|
- find_package(ZLIB REQUIRED)
|
226
|
|
-else ()
|
227
|
|
- find_package(ZLIB)
|
|
265
|
+if (NOT FT_DISABLE_ZLIB)
|
|
266
|
+ if (FT_REQUIRE_ZLIB)
|
|
267
|
+ find_package(ZLIB REQUIRED)
|
|
268
|
+ else ()
|
|
269
|
+ find_package(ZLIB)
|
|
270
|
+ endif ()
|
228
|
271
|
endif ()
|
229
|
272
|
|
230
|
|
-if (FT_WITH_BZIP2)
|
231
|
|
- find_package(BZip2 REQUIRED)
|
232
|
|
-else ()
|
233
|
|
- find_package(BZip2)
|
|
273
|
+if (NOT FT_DISABLE_BZIP2)
|
|
274
|
+ if (FT_REQUIRE_BZIP2)
|
|
275
|
+ find_package(BZip2 REQUIRED)
|
|
276
|
+ else ()
|
|
277
|
+ find_package(BZip2)
|
|
278
|
+ endif ()
|
234
|
279
|
endif ()
|
235
|
280
|
|
236
|
|
-if (FT_WITH_BROTLI)
|
237
|
|
- find_package(BrotliDec REQUIRED)
|
238
|
|
-else ()
|
239
|
|
- find_package(BrotliDec)
|
|
281
|
+if (NOT FT_DISABLE_BROTLI)
|
|
282
|
+ if (FT_REQUIRE_BROTLI)
|
|
283
|
+ find_package(BrotliDec REQUIRED)
|
|
284
|
+ else ()
|
|
285
|
+ find_package(BrotliDec)
|
|
286
|
+ endif ()
|
240
|
287
|
endif ()
|
241
|
288
|
|
242
|
289
|
# Create the configuration file
|
... |
... |
@@ -426,7 +473,7 @@ target_include_directories( |
426
|
473
|
PRIVATE
|
427
|
474
|
${CMAKE_CURRENT_BINARY_DIR}/include
|
428
|
475
|
${CMAKE_CURRENT_SOURCE_DIR}/include
|
429
|
|
-
|
|
476
|
+
|
430
|
477
|
# Make <ftconfig.h> available for builds/unix/ftsystem.c.
|
431
|
478
|
${CMAKE_CURRENT_BINARY_DIR}/include/freetype/config
|
432
|
479
|
)
|