blob: 4335d66dc33e74a7aff703f4b90848ac1f7cd319 [file] [log] [blame]
John Carya0e4a732013-10-24 08:49:08 +02001# CMakeLists.txt
2#
Werner Lembergb6e8a712021-01-17 07:18:48 +01003# Copyright (C) 2013-2021 by
John Carya0e4a732013-10-24 08:49:08 +02004# David Turner, Robert Wilhelm, and Werner Lemberg.
5#
Werner Lemberg05055372015-06-28 11:07:07 +02006# Written originally by John Cary <cary@txcorp.com>
John Carya0e4a732013-10-24 08:49:08 +02007#
8# This file is part of the FreeType project, and may only be used, modified,
9# and distributed under the terms of the FreeType project license,
10# LICENSE.TXT. By continuing to use, modify, or distribute this file you
11# indicate that you have read the license and understand and accept it
12# fully.
13#
Werner Lemberg05055372015-06-28 11:07:07 +020014#
AnuthaDev1f742f02021-07-20 20:00:10 +053015# The following will (1) create a build directory, and (2) change into it and
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +010016# call cmake to configure the build with default parameters as a static
AnuthaDev1f742f02021-07-20 20:00:10 +053017# 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
John Carya0e4a732013-10-24 08:49:08 +020022#
Nikolaus Waxweiler3aaae712019-11-07 23:39:41 +000023# cmake -B build -D CMAKE_BUILD_TYPE=Release
Alexey Petruchik02f21702014-05-16 08:09:43 +020024#
AnuthaDev1f742f02021-07-20 20:00:10 +053025#
Alexey Petruchik02f21702014-05-16 08:09:43 +020026# For a dynamic library, use
John Carya0e4a732013-10-24 08:49:08 +020027#
Nikolaus Waxweiler3aaae712019-11-07 23:39:41 +000028# cmake -B build -D BUILD_SHARED_LIBS=true -D CMAKE_BUILD_TYPE=Release
John Carya0e4a732013-10-24 08:49:08 +020029#
Alexey Petruchik02f21702014-05-16 08:09:43 +020030# For a framework on OS X, use
31#
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +010032# cmake -E chdir build cmake -G Xcode -D BUILD_FRAMEWORK:BOOL=true ..
Werner Lemberg54306f52014-10-18 10:42:28 +020033#
34# For an iOS static library, use
35#
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +010036# cmake -E chdir build cmake -G Xcode -D IOS_PLATFORM=OS ..
Werner Lemberg54306f52014-10-18 10:42:28 +020037#
38# or
39#
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +010040# cmake -E chdir build cmake -G Xcode -D IOS_PLATFORM=SIMULATOR ..
41#
Nikolaus Waxweilerbfbde792018-06-10 13:19:31 +010042# or
43#
44# cmake -E chdir build cmake -G Xcode -D IOS_PLATFORM=SIMULATOR64 ..
45#
AnuthaDev1f742f02021-07-20 20:00:10 +053046#
47# Finally, build the project with
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +010048#
49# cmake --build build
50#
51# Install it with
52#
53# (sudo) cmake --build build --target install
54#
55# A binary distribution can be made with
56#
57# cmake --build build --config Release --target package
Werner Lemberg54306f52014-10-18 10:42:28 +020058#
59# Please refer to the cmake manual for further options, in particular, how
60# to modify compilation and linking parameters.
John Carya0e4a732013-10-24 08:49:08 +020061#
62# Some notes.
63#
AnuthaDev1f742f02021-07-20 20:00:10 +053064# - `cmake' creates configuration files in
Werner Lemberg05055372015-06-28 11:07:07 +020065#
66# <build-directory>/include/freetype/config
67#
68# which should be further modified if necessary.
John Carya0e4a732013-10-24 08:49:08 +020069#
AnuthaDev1f742f02021-07-20 20:00:10 +053070# - You can use `cmake' directly on a freshly cloned FreeType git
John Carya0e4a732013-10-24 08:49:08 +020071# repository.
72#
AnuthaDev1f742f02021-07-20 20:00:10 +053073# - `CMakeLists.txt' is provided as-is since it is normally not used by the
John Carya0e4a732013-10-24 08:49:08 +020074# developer team.
Alexander Bock8f982b32015-11-27 06:34:39 +010075#
AnuthaDev1f742f02021-07-20 20:00:10 +053076# - 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:
Werner Lemberg3de1b8d2019-09-05 14:10:01 +020081#
AnuthaDev1f742f02021-07-20 20:00:10 +053082# 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 [...]
Tamas Kenezda97b4c2015-11-27 07:11:42 +010087#
AnuthaDev1f742f02021-07-20 20:00:10 +053088# - Set `FT_DISABLE_XXX=TRUE' to disable a dependency completely (where
89# `XXX' is a CMake package name like `BZip2'). Example for disabling all
Nikolaus Waxweiler3aaae712019-11-07 23:39:41 +000090# dependencies:
91#
AnuthaDev1f742f02021-07-20 20:00:10 +053092# 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 [...]
David Capello9224f052016-04-16 10:24:24 +020097#
AnuthaDev1f742f02021-07-20 20:00:10 +053098# - 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'.
103#
104# - Installation of FreeType can be controlled with the CMake variables
David Capello9224f052016-04-16 10:24:24 +0200105# `SKIP_INSTALL_HEADERS', `SKIP_INSTALL_LIBRARIES', and `SKIP_INSTALL_ALL'
106# (this is compatible with the same CMake variables in zlib's CMake
107# support).
John Carya0e4a732013-10-24 08:49:08 +0200108
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +0100109# FreeType explicitly marks the API to be exported and relies on the compiler
110# to hide all other symbols. CMake supports a C_VISBILITY_PRESET property
111# starting with 2.8.12.
112cmake_minimum_required(VERSION 2.8.12)
John Carya0e4a732013-10-24 08:49:08 +0200113
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +0100114if (NOT CMAKE_VERSION VERSION_LESS 3.3)
115 # Allow symbol visibility settings also on static libraries. CMake < 3.3
Werner Lemberg12351ee2019-09-05 12:02:59 +0200116 # only sets the property on a shared library build.
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +0100117 cmake_policy(SET CMP0063 NEW)
Nikolaus Waxweilerebf9e5a2021-05-15 22:36:00 +0100118
119 # Support new IN_LIST if() operator.
120 cmake_policy(SET CMP0057 NEW)
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +0100121endif ()
Werner Lemberg97b757d2015-06-28 10:42:47 +0200122
123include(CheckIncludeFile)
AnuthaDev1f742f02021-07-20 20:00:10 +0530124include(CMakeDependentOption)
Werner Lemberg97b757d2015-06-28 10:42:47 +0200125
Werner Lemberg54306f52014-10-18 10:42:28 +0200126# CMAKE_TOOLCHAIN_FILE must be set before `project' is called, which
127# configures the base build environment and references the toolchain file
128if (APPLE)
129 if (DEFINED IOS_PLATFORM)
130 if (NOT "${IOS_PLATFORM}" STREQUAL "OS"
Nikolaus Waxweilerbfbde792018-06-10 13:19:31 +0100131 AND NOT "${IOS_PLATFORM}" STREQUAL "SIMULATOR"
132 AND NOT "${IOS_PLATFORM}" STREQUAL "SIMULATOR64")
Werner Lemberg54306f52014-10-18 10:42:28 +0200133 message(FATAL_ERROR
Nikolaus Waxweilerbfbde792018-06-10 13:19:31 +0100134 "IOS_PLATFORM must be set to either OS, SIMULATOR, or SIMULATOR64")
Werner Lemberg54306f52014-10-18 10:42:28 +0200135 endif ()
136 if (NOT "${CMAKE_GENERATOR}" STREQUAL "Xcode")
137 message(AUTHOR_WARNING
138 "You should use Xcode generator with IOS_PLATFORM enabled to get Universal builds.")
139 endif ()
140 if (BUILD_SHARED_LIBS)
141 message(FATAL_ERROR
142 "BUILD_SHARED_LIBS can not be on with IOS_PLATFORM enabled")
143 endif ()
144 if (BUILD_FRAMEWORK)
145 message(FATAL_ERROR
146 "BUILD_FRAMEWORK can not be on with IOS_PLATFORM enabled")
147 endif ()
148
149 # iOS only uses static libraries
150 set(BUILD_SHARED_LIBS OFF)
151
152 set(CMAKE_TOOLCHAIN_FILE
Werner Lemberg10265db2016-03-11 06:50:23 +0100153 ${CMAKE_SOURCE_DIR}/builds/cmake/iOS.cmake)
Werner Lemberg54306f52014-10-18 10:42:28 +0200154 endif ()
155else ()
156 if (DEFINED IOS_PLATFORM)
157 message(FATAL_ERROR "IOS_PLATFORM is not supported on this platform")
158 endif ()
159endif ()
160
Werner Lemberg22479ca2015-06-28 10:26:33 +0200161
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +0100162project(freetype C)
163
164set(VERSION_MAJOR "2")
Werner Lemberg801cd842021-07-18 07:53:57 +0200165set(VERSION_MINOR "11")
Werner Lemberg3f83dae2021-12-01 20:17:59 +0100166set(VERSION_PATCH "1")
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +0100167
Werner Lemberg12351ee2019-09-05 12:02:59 +0200168# Generate LIBRARY_VERSION and LIBRARY_SOVERSION.
169set(LIBTOOL_REGEX "version_info='([0-9]+):([0-9]+):([0-9]+)'")
170file(STRINGS "${PROJECT_SOURCE_DIR}/builds/unix/configure.raw"
171 VERSION_INFO
172 REGEX ${LIBTOOL_REGEX})
173string(REGEX REPLACE
174 ${LIBTOOL_REGEX} "\\1"
175 LIBTOOL_CURRENT "${VERSION_INFO}")
176string(REGEX REPLACE
177 ${LIBTOOL_REGEX} "\\2"
178 LIBTOOL_REVISION "${VERSION_INFO}")
179string(REGEX REPLACE
180 ${LIBTOOL_REGEX} "\\3"
181 LIBTOOL_AGE "${VERSION_INFO}")
182
183# This is what libtool does internally on Unix platforms.
184math(EXPR LIBRARY_SOVERSION "${LIBTOOL_CURRENT} - ${LIBTOOL_AGE}")
185set(LIBRARY_VERSION "${LIBRARY_SOVERSION}.${LIBTOOL_AGE}.${LIBTOOL_REVISION}")
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +0100186
AnuthaDev1f742f02021-07-20 20:00:10 +0530187# External dependency library detection is automatic. See the notes at the
188# top of this file, for how to force or disable dependencies completely.
189option(FT_DISABLE_ZLIB
190 "Disable use of system zlib and use internal zlib library instead." OFF)
191cmake_dependent_option(FT_REQUIRE_ZLIB
192 "Require system zlib instead of internal zlib library." OFF
193 "NOT FT_DISABLE_ZLIB" OFF)
194
195option(FT_DISABLE_BZIP2
196 "Disable support of bzip2 compressed fonts." OFF)
197cmake_dependent_option(FT_REQUIRE_BZIP2
198 "Require support of bzip2 compressed fonts." OFF
199 "NOT FT_DISABLE_BZIP2" OFF)
200
201option(FT_DISABLE_PNG
202 "Disable support of PNG compressed OpenType embedded bitmaps." OFF)
203cmake_dependent_option(FT_REQUIRE_PNG
204 "Require support of PNG compressed OpenType embedded bitmaps." OFF
205 "NOT FT_DISABLE_PNG" OFF)
206
207option(FT_DISABLE_HARFBUZZ
208 "Disable HarfBuzz (used for improving auto-hinting of OpenType fonts)." OFF)
209cmake_dependent_option(FT_REQUIRE_HARFBUZZ
210 "Require HarfBuzz for improving auto-hinting of OpenType fonts." OFF
211 "NOT FT_DISABLE_HARFBUZZ" OFF)
212
213option(FT_DISABLE_BROTLI
214 "Disable support of compressed WOFF2 fonts." OFF)
215cmake_dependent_option(FT_REQUIRE_BROTLI
216 "Require support of compressed WOFF2 fonts." OFF
217 "NOT FT_DISABLE_BROTLI" OFF)
John Carya0e4a732013-10-24 08:49:08 +0200218
Werner Lemberg22479ca2015-06-28 10:26:33 +0200219
220# Disallow in-source builds
Nikolaus Waxweilerf7b4fb32018-05-07 23:10:36 +0100221if ("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
Werner Lemberg22479ca2015-06-28 10:26:33 +0200222 message(FATAL_ERROR
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +0100223 "In-source builds are not permitted! Make a separate folder for"
224 " building, e.g.,\n"
225 " cmake -E make_directory build\n"
226 " cmake -E chdir build cmake ..\n"
227 "Before that, remove the files created by this failed run with\n"
228 " cmake -E remove CMakeCache.txt\n"
229 " cmake -E remove_directory CMakeFiles")
Werner Lemberg22479ca2015-06-28 10:26:33 +0200230endif ()
231
232
Werner Lemberg52c9b1a2015-06-28 11:03:10 +0200233# Add local cmake modules
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +0100234list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/builds/cmake)
Werner Lemberg52c9b1a2015-06-28 11:03:10 +0200235
236
Alexey Petruchik02f21702014-05-16 08:09:43 +0200237if (BUILD_FRAMEWORK)
238 if (NOT "${CMAKE_GENERATOR}" STREQUAL "Xcode")
Werner Lemberg54306f52014-10-18 10:42:28 +0200239 message(FATAL_ERROR
240 "You should use Xcode generator with BUILD_FRAMEWORK enabled")
Alexey Petruchik02f21702014-05-16 08:09:43 +0200241 endif ()
242 set(CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD_32_64_BIT)")
243 set(BUILD_SHARED_LIBS ON)
244endif ()
245
Werner Lemberg52c9b1a2015-06-28 11:03:10 +0200246
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +0100247# Find dependencies
AnuthaDev1f742f02021-07-20 20:00:10 +0530248if (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 ()
Steve Robinson707cd022018-01-10 07:48:39 +0100255endif ()
John Carya0e4a732013-10-24 08:49:08 +0200256
AnuthaDev1f742f02021-07-20 20:00:10 +0530257if (NOT FT_DISABLE_PNG)
258 if (FT_REQUIRE_PNG)
259 find_package(PNG REQUIRED)
260 else ()
261 find_package(PNG)
262 endif ()
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +0100263endif ()
Werner Lemberg97b757d2015-06-28 10:42:47 +0200264
AnuthaDev1f742f02021-07-20 20:00:10 +0530265if (NOT FT_DISABLE_ZLIB)
266 if (FT_REQUIRE_ZLIB)
267 find_package(ZLIB REQUIRED)
268 else ()
269 find_package(ZLIB)
270 endif ()
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +0100271endif ()
Tamas Kenezda97b4c2015-11-27 07:11:42 +0100272
AnuthaDev1f742f02021-07-20 20:00:10 +0530273if (NOT FT_DISABLE_BZIP2)
274 if (FT_REQUIRE_BZIP2)
275 find_package(BZip2 REQUIRED)
276 else ()
277 find_package(BZip2)
278 endif ()
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +0100279endif ()
Werner Lemberg52c9b1a2015-06-28 11:03:10 +0200280
AnuthaDev1f742f02021-07-20 20:00:10 +0530281if (NOT FT_DISABLE_BROTLI)
282 if (FT_REQUIRE_BROTLI)
283 find_package(BrotliDec REQUIRED)
284 else ()
285 find_package(BrotliDec)
286 endif ()
Werner Lemberg3de1b8d2019-09-05 14:10:01 +0200287endif ()
288
John Carya0e4a732013-10-24 08:49:08 +0200289# Create the configuration file
Werner Lemberg68222dd2015-06-25 16:38:11 +0200290if (UNIX)
Werner Lemberg97b757d2015-06-28 10:42:47 +0200291 check_include_file("unistd.h" HAVE_UNISTD_H)
292 check_include_file("fcntl.h" HAVE_FCNTL_H)
John Carya0e4a732013-10-24 08:49:08 +0200293
David Turnera4d92062020-07-02 10:10:25 +0200294 file(READ "${PROJECT_SOURCE_DIR}/builds/unix/ftconfig.h.in"
Werner Lemberg68222dd2015-06-25 16:38:11 +0200295 FTCONFIG_H)
Werner Lemberg97b757d2015-06-28 10:42:47 +0200296 if (HAVE_UNISTD_H)
297 string(REGEX REPLACE
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +0100298 "#undef +(HAVE_UNISTD_H)" "#define \\1 1"
Werner Lemberg97b757d2015-06-28 10:42:47 +0200299 FTCONFIG_H "${FTCONFIG_H}")
300 endif ()
301 if (HAVE_FCNTL_H)
302 string(REGEX REPLACE
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +0100303 "#undef +(HAVE_FCNTL_H)" "#define \\1 1"
Werner Lemberg97b757d2015-06-28 10:42:47 +0200304 FTCONFIG_H "${FTCONFIG_H}")
305 endif ()
Minmin Gongebe37502019-04-15 10:46:19 +0200306else ()
Nikolaus Waxweiler660afb52018-05-02 23:19:55 +0100307 file(READ "${PROJECT_SOURCE_DIR}/include/freetype/config/ftconfig.h"
308 FTCONFIG_H)
Werner Lemberg68222dd2015-06-25 16:38:11 +0200309endif ()
Minmin Gongebe37502019-04-15 10:46:19 +0200310
311set(FTCONFIG_H_NAME "${PROJECT_BINARY_DIR}/include/freetype/config/ftconfig.h")
312if (EXISTS "${FTCONFIG_H_NAME}")
313 file(READ "${FTCONFIG_H_NAME}" ORIGINAL_FTCONFIG_H)
314else ()
315 set(ORIGINAL_FTCONFIG_H "")
316endif ()
317if (NOT (ORIGINAL_FTCONFIG_H STREQUAL FTCONFIG_H))
318 file(WRITE "${FTCONFIG_H_NAME}" "${FTCONFIG_H}")
319endif ()
John Carya0e4a732013-10-24 08:49:08 +0200320
Werner Lemberg97b757d2015-06-28 10:42:47 +0200321
Werner Lemberg52c9b1a2015-06-28 11:03:10 +0200322# Create the options file
Werner Lemberg52c9b1a2015-06-28 11:03:10 +0200323file(READ "${PROJECT_SOURCE_DIR}/include/freetype/config/ftoption.h"
324 FTOPTION_H)
325if (ZLIB_FOUND)
326 string(REGEX REPLACE
327 "/\\* +(#define +FT_CONFIG_OPTION_SYSTEM_ZLIB) +\\*/" "\\1"
328 FTOPTION_H "${FTOPTION_H}")
329endif ()
330if (BZIP2_FOUND)
331 string(REGEX REPLACE
332 "/\\* +(#define +FT_CONFIG_OPTION_USE_BZIP2) +\\*/" "\\1"
333 FTOPTION_H "${FTOPTION_H}")
334endif ()
335if (PNG_FOUND)
336 string(REGEX REPLACE
337 "/\\* +(#define +FT_CONFIG_OPTION_USE_PNG) +\\*/" "\\1"
338 FTOPTION_H "${FTOPTION_H}")
339endif ()
340if (HARFBUZZ_FOUND)
341 string(REGEX REPLACE
342 "/\\* +(#define +FT_CONFIG_OPTION_USE_HARFBUZZ) +\\*/" "\\1"
343 FTOPTION_H "${FTOPTION_H}")
344endif ()
Werner Lemberg3de1b8d2019-09-05 14:10:01 +0200345if (BROTLIDEC_FOUND)
346 string(REGEX REPLACE
347 "/\\* +(#define +FT_CONFIG_OPTION_USE_BROTLI) +\\*/" "\\1"
348 FTOPTION_H "${FTOPTION_H}")
349endif ()
Minmin Gongebe37502019-04-15 10:46:19 +0200350
351set(FTOPTION_H_NAME "${PROJECT_BINARY_DIR}/include/freetype/config/ftoption.h")
352if (EXISTS "${FTOPTION_H_NAME}")
353 file(READ "${FTOPTION_H_NAME}" ORIGINAL_FTOPTION_H)
354else ()
355 set(ORIGINAL_FTOPTION_H "")
356endif ()
357if (NOT (ORIGINAL_FTOPTION_H STREQUAL FTOPTION_H))
358 file(WRITE "${FTOPTION_H_NAME}" "${FTOPTION_H}")
359endif ()
Werner Lemberg97b757d2015-06-28 10:42:47 +0200360
361
Werner Lemberg392cf222015-06-25 13:04:57 +0200362file(GLOB PUBLIC_HEADERS "include/ft2build.h" "include/freetype/*.h")
363file(GLOB PUBLIC_CONFIG_HEADERS "include/freetype/config/*.h")
364file(GLOB PRIVATE_HEADERS "include/freetype/internal/*.h")
Alexey Petruchik02f21702014-05-16 08:09:43 +0200365
Werner Lemberg05055372015-06-28 11:07:07 +0200366
John Carya0e4a732013-10-24 08:49:08 +0200367set(BASE_SRCS
368 src/autofit/autofit.c
Werner Lemberg5ef5a4f2015-06-25 15:45:13 +0200369 src/base/ftbase.c
John Carya0e4a732013-10-24 08:49:08 +0200370 src/base/ftbbox.c
Pavel Koshevoy15da66a2014-05-13 07:33:48 +0200371 src/base/ftbdf.c
John Carya0e4a732013-10-24 08:49:08 +0200372 src/base/ftbitmap.c
John Carya0e4a732013-10-24 08:49:08 +0200373 src/base/ftcid.c
John Carya0e4a732013-10-24 08:49:08 +0200374 src/base/ftfstype.c
375 src/base/ftgasp.c
John Carya0e4a732013-10-24 08:49:08 +0200376 src/base/ftglyph.c
377 src/base/ftgxval.c
378 src/base/ftinit.c
John Carya0e4a732013-10-24 08:49:08 +0200379 src/base/ftmm.c
John Carya0e4a732013-10-24 08:49:08 +0200380 src/base/ftotval.c
John Carya0e4a732013-10-24 08:49:08 +0200381 src/base/ftpatent.c
382 src/base/ftpfr.c
John Carya0e4a732013-10-24 08:49:08 +0200383 src/base/ftstroke.c
384 src/base/ftsynth.c
John Carya0e4a732013-10-24 08:49:08 +0200385 src/base/fttype1.c
John Carya0e4a732013-10-24 08:49:08 +0200386 src/base/ftwinfnt.c
John Carya0e4a732013-10-24 08:49:08 +0200387 src/bdf/bdf.c
388 src/bzip2/ftbzip2.c
389 src/cache/ftcache.c
390 src/cff/cff.c
391 src/cid/type1cid.c
392 src/gzip/ftgzip.c
393 src/lzw/ftlzw.c
394 src/pcf/pcf.c
395 src/pfr/pfr.c
396 src/psaux/psaux.c
397 src/pshinter/pshinter.c
Werner Lemberg5ef5a4f2015-06-25 15:45:13 +0200398 src/psnames/psnames.c
John Carya0e4a732013-10-24 08:49:08 +0200399 src/raster/raster.c
Anuj Vermac6f394b2020-08-20 08:28:14 +0530400 src/sdf/sdf.c
John Carya0e4a732013-10-24 08:49:08 +0200401 src/sfnt/sfnt.c
402 src/smooth/smooth.c
403 src/truetype/truetype.c
404 src/type1/type1.c
405 src/type42/type42.c
406 src/winfonts/winfnt.c
407)
408
Nikolaus Waxweiler3aaae712019-11-07 23:39:41 +0000409if (UNIX)
410 list(APPEND BASE_SRCS "builds/unix/ftsystem.c")
Vincent Torribb33f032021-01-27 06:43:41 -0500411elseif (WIN32)
412 list(APPEND BASE_SRCS "builds/windows/ftsystem.c")
Nikolaus Waxweiler3aaae712019-11-07 23:39:41 +0000413else ()
414 list(APPEND BASE_SRCS "src/base/ftsystem.c")
415endif ()
416
Werner Lemberg94c79c22015-06-26 06:46:59 +0200417if (WIN32)
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +0100418 enable_language(RC)
419 list(APPEND BASE_SRCS builds/windows/ftdebug.c
420 src/base/ftver.rc)
Werner Lemberg94c79c22015-06-26 06:46:59 +0200421elseif (WINCE)
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +0100422 list(APPEND BASE_SRCS builds/wince/ftdebug.c)
Werner Lemberg94c79c22015-06-26 06:46:59 +0200423else ()
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +0100424 list(APPEND BASE_SRCS src/base/ftdebug.c)
Werner Lemberg94c79c22015-06-26 06:46:59 +0200425endif ()
426
Alexey Petruchik02f21702014-05-16 08:09:43 +0200427if (BUILD_FRAMEWORK)
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +0100428 list(APPEND BASE_SRCS builds/mac/freetype-Info.plist)
Alexey Petruchik02f21702014-05-16 08:09:43 +0200429endif ()
430
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +0100431
yuri_levchenkoaf585ad2017-11-09 13:38:26 +0200432if (NOT DISABLE_FORCE_DEBUG_POSTFIX)
433 set(CMAKE_DEBUG_POSTFIX d)
Minmin Gongebe37502019-04-15 10:46:19 +0200434endif ()
Werner Lemberg05055372015-06-28 11:07:07 +0200435
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +0100436
Alexey Petruchik02f21702014-05-16 08:09:43 +0200437add_library(freetype
438 ${PUBLIC_HEADERS}
439 ${PUBLIC_CONFIG_HEADERS}
440 ${PRIVATE_HEADERS}
441 ${BASE_SRCS}
442)
443
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +0100444set_target_properties(
445 freetype PROPERTIES
446 C_VISIBILITY_PRESET hidden)
447
448target_compile_definitions(
449 freetype PRIVATE FT2_BUILD_LIBRARY)
450
451if (WIN32)
452 target_compile_definitions(
453 freetype PRIVATE _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_WARNINGS)
Alexei Podtelezhnikov4b97ab92018-07-24 23:01:34 -0400454 if (BUILD_SHARED_LIBS)
455 target_compile_definitions(
456 freetype PRIVATE DLL_EXPORT)
457 endif ()
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +0100458endif ()
Werner Lemberg05055372015-06-28 11:07:07 +0200459
Werner Lemberga82c45d2015-08-02 18:35:49 +0200460if (BUILD_SHARED_LIBS)
461 set_target_properties(freetype PROPERTIES
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +0100462 VERSION ${LIBRARY_VERSION}
463 SOVERSION ${LIBRARY_SOVERSION})
Werner Lemberga82c45d2015-08-02 18:35:49 +0200464endif ()
465
Nikolaus Waxweilerf7b4fb32018-05-07 23:10:36 +0100466# Pick up ftconfig.h and ftoption.h generated above, first.
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +0100467target_include_directories(
468 freetype
Nikolaus Waxweilerf7b4fb32018-05-07 23:10:36 +0100469 PUBLIC
470 $<INSTALL_INTERFACE:include/freetype2>
471 $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
472 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
Werner Lembergd91f7522018-08-31 07:34:30 +0200473 PRIVATE
Nikolaus Waxweilerf7b4fb32018-05-07 23:10:36 +0100474 ${CMAKE_CURRENT_BINARY_DIR}/include
Nikolaus Waxweiler3aaae712019-11-07 23:39:41 +0000475 ${CMAKE_CURRENT_SOURCE_DIR}/include
AnuthaDev1f742f02021-07-20 20:00:10 +0530476
Nikolaus Waxweiler3aaae712019-11-07 23:39:41 +0000477 # Make <ftconfig.h> available for builds/unix/ftsystem.c.
478 ${CMAKE_CURRENT_BINARY_DIR}/include/freetype/config
479)
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +0100480
Werner Lemberga82c45d2015-08-02 18:35:49 +0200481
Alexey Petruchik02f21702014-05-16 08:09:43 +0200482if (BUILD_FRAMEWORK)
483 set_property(SOURCE ${PUBLIC_CONFIG_HEADERS}
484 PROPERTY MACOSX_PACKAGE_LOCATION Headers/config
485 )
486 set_target_properties(freetype PROPERTIES
487 FRAMEWORK TRUE
488 MACOSX_FRAMEWORK_INFO_PLIST builds/mac/freetype-Info.plist
489 PUBLIC_HEADER "${PUBLIC_HEADERS}"
490 XCODE_ATTRIBUTE_INSTALL_PATH "@rpath"
491 )
492endif ()
John Carya0e4a732013-10-24 08:49:08 +0200493
Tamas Kenezc80620c2015-11-27 18:37:21 +0100494
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +0100495set(PKG_CONFIG_REQUIRED_PRIVATE "")
Daniel Eb2aeca52021-02-14 20:25:21 +0000496set(PKG_CONFIG_LIBS_PRIVATE "")
Werner Lemberg52c9b1a2015-06-28 11:03:10 +0200497
498if (ZLIB_FOUND)
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +0100499 target_link_libraries(freetype PRIVATE ${ZLIB_LIBRARIES})
500 target_include_directories(freetype PRIVATE ${ZLIB_INCLUDE_DIRS})
Werner Lemberg12351ee2019-09-05 12:02:59 +0200501 list(APPEND PKG_CONFIG_REQUIRED_PRIVATE "zlib")
Werner Lemberg52c9b1a2015-06-28 11:03:10 +0200502endif ()
503if (BZIP2_FOUND)
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +0100504 target_link_libraries(freetype PRIVATE ${BZIP2_LIBRARIES})
505 target_include_directories(freetype PRIVATE ${BZIP2_INCLUDE_DIR}) # not BZIP2_INCLUDE_DIRS
Daniel Eb2aeca52021-02-14 20:25:21 +0000506 list(APPEND PKG_CONFIG_LIBS_PRIVATE "-lbz2")
Werner Lemberg52c9b1a2015-06-28 11:03:10 +0200507endif ()
508if (PNG_FOUND)
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +0100509 target_link_libraries(freetype PRIVATE ${PNG_LIBRARIES})
510 target_compile_definitions(freetype PRIVATE ${PNG_DEFINITIONS})
511 target_include_directories(freetype PRIVATE ${PNG_INCLUDE_DIRS})
Werner Lemberg12351ee2019-09-05 12:02:59 +0200512 list(APPEND PKG_CONFIG_REQUIRED_PRIVATE "libpng")
Werner Lemberg52c9b1a2015-06-28 11:03:10 +0200513endif ()
Nikolaus Waxweilerebf9e5a2021-05-15 22:36:00 +0100514if (HarfBuzz_FOUND)
515 target_link_libraries(freetype PRIVATE ${HarfBuzz_LIBRARY})
516 target_include_directories(freetype PRIVATE ${HarfBuzz_INCLUDE_DIRS})
Werner Lemberg12351ee2019-09-05 12:02:59 +0200517 list(APPEND PKG_CONFIG_REQUIRED_PRIVATE "harfbuzz >= ${HARFBUZZ_MIN_VERSION}")
Werner Lemberg52c9b1a2015-06-28 11:03:10 +0200518endif ()
Werner Lemberg3de1b8d2019-09-05 14:10:01 +0200519if (BROTLIDEC_FOUND)
520 target_link_libraries(freetype PRIVATE ${BROTLIDEC_LIBRARIES})
521 target_compile_definitions(freetype PRIVATE ${BROTLIDEC_DEFINITIONS})
522 target_include_directories(freetype PRIVATE ${BROTLIDEC_INCLUDE_DIRS})
523 list(APPEND PKG_CONFIG_REQUIRED_PRIVATE "libbrotlidec")
524endif ()
Werner Lemberg52c9b1a2015-06-28 11:03:10 +0200525
526
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +0100527# Installation
528include(GNUInstallDirs)
529
David Capello9224f052016-04-16 10:24:24 +0200530if (NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL)
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +0100531 install(
532 # Note the trailing slash in the argument to `DIRECTORY'!
533 DIRECTORY ${PROJECT_SOURCE_DIR}/include/
534 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/freetype2
535 COMPONENT headers
536 PATTERN "internal" EXCLUDE
537 PATTERN "ftconfig.h" EXCLUDE
538 PATTERN "ftoption.h" EXCLUDE)
539 install(
540 FILES ${PROJECT_BINARY_DIR}/include/freetype/config/ftconfig.h
541 ${PROJECT_BINARY_DIR}/include/freetype/config/ftoption.h
542 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/freetype2/freetype/config
543 COMPONENT headers)
David Capello9224f052016-04-16 10:24:24 +0200544endif ()
545
546if (NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL)
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +0100547 # Generate the pkg-config file
Christopher Degawa66005cb2021-03-15 14:51:30 -0500548 file(READ "${PROJECT_SOURCE_DIR}/builds/unix/freetype2.in" FREETYPE2_PC_IN)
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +0100549
Christopher Degawa66005cb2021-03-15 14:51:30 -0500550 string(REPLACE ";" ", " PKG_CONFIG_REQUIRED_PRIVATE "${PKG_CONFIG_REQUIRED_PRIVATE}")
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +0100551
Christopher Degawa66005cb2021-03-15 14:51:30 -0500552 string(REPLACE "%prefix%" ${CMAKE_INSTALL_PREFIX}
553 FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
554 string(REPLACE "%exec_prefix%" "\${prefix}"
555 FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
556 string(REPLACE "%libdir%" "\${prefix}/${CMAKE_INSTALL_LIBDIR}"
557 FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
558 string(REPLACE "%includedir%" "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}"
559 FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
560 string(REPLACE "%ft_version%" "${LIBTOOL_CURRENT}.${LIBTOOL_REVISION}.${LIBTOOL_AGE}"
561 FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
562 string(REPLACE "%REQUIRES_PRIVATE%" "${PKG_CONFIG_REQUIRED_PRIVATE}"
563 FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
564 string(REPLACE "%LIBS_PRIVATE%" "${PKG_CONFIG_LIBS_PRIVATE}"
565 FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +0100566
Christopher Degawa66005cb2021-03-15 14:51:30 -0500567 set(FREETYPE2_PC_IN_NAME "${PROJECT_BINARY_DIR}/freetype2.pc")
568 if (EXISTS "${FREETYPE2_PC_IN_NAME}")
569 file(READ "${FREETYPE2_PC_IN_NAME}" ORIGINAL_FREETYPE2_PC_IN)
570 else ()
571 set(ORIGINAL_FREETYPE2_PC_IN "")
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +0100572 endif ()
Christopher Degawa66005cb2021-03-15 14:51:30 -0500573 if (NOT (ORIGINAL_FREETYPE2_PC_IN STREQUAL FREETYPE2_PC_IN))
574 file(WRITE "${FREETYPE2_PC_IN_NAME}" ${FREETYPE2_PC_IN})
575 endif ()
576
577 install(
578 FILES ${PROJECT_BINARY_DIR}/freetype2.pc
579 DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
580 COMPONENT pkgconfig)
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +0100581
Boris Dalstein69353a12020-08-25 13:53:54 +0200582 include(CMakePackageConfigHelpers)
583 write_basic_package_version_file(
584 ${PROJECT_BINARY_DIR}/freetype-config-version.cmake
585 VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
586 COMPATIBILITY SameMajorVersion)
587
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +0100588 install(
589 TARGETS freetype
590 EXPORT freetype-targets
591 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
592 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
Werner Lemberg0c4feb72018-10-17 11:25:32 +0200593 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +0100594 FRAMEWORK DESTINATION Library/Frameworks
595 COMPONENT libraries)
596 install(
David Capello9224f052016-04-16 10:24:24 +0200597 EXPORT freetype-targets
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +0100598 DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/freetype
599 FILE freetype-config.cmake
600 COMPONENT headers)
Boris Dalstein69353a12020-08-25 13:53:54 +0200601 install(
602 FILES ${PROJECT_BINARY_DIR}/freetype-config-version.cmake
603 DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/freetype
604 COMPONENT headers)
David Capello9224f052016-04-16 10:24:24 +0200605endif ()
John Carya0e4a732013-10-24 08:49:08 +0200606
Werner Lemberg05055372015-06-28 11:07:07 +0200607
John Carya0e4a732013-10-24 08:49:08 +0200608# Packaging
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +0100609set(CPACK_PACKAGE_NAME ${CMAKE_PROJECT_NAME})
610set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The FreeType font rendering library.")
611set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
Werner Lembergdf7fcaf2021-02-22 15:33:23 +0100612set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.TXT")
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +0100613
John Carya0e4a732013-10-24 08:49:08 +0200614set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
615set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +0100616set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH})
617set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
618
619if (WIN32)
620 set(CPACK_GENERATOR ZIP)
Minmin Gongebe37502019-04-15 10:46:19 +0200621else ()
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +0100622 set(CPACK_GENERATOR TGZ)
Minmin Gongebe37502019-04-15 10:46:19 +0200623endif ()
Nikolaus Waxweiler029721d2018-04-07 21:34:24 +0100624
625set(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "Libraries")
626set(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C/C++ Headers")
627set(CPACK_COMPONENT_LIBRARIES_DESCRIPTION
628 "Library used to build programs which use FreeType")
629set(CPACK_COMPONENT_HEADERS_DESCRIPTION
630 "C/C++ header files for use with FreeType")
631set(CPACK_COMPONENT_HEADERS_DEPENDS libraries)
632set(CPACK_COMPONENT_LIBRARIES_GROUP "Development")
633set(CPACK_COMPONENT_HEADERS_GROUP "Development")
634
John Carya0e4a732013-10-24 08:49:08 +0200635include(CPack)