Bug 1888033 - [Menu Redesign] Add a secret setting and feature flag for the menu...
[gecko.git] / modules / freetype2 / CMakeLists.txt
blob8dbca01e652f395768c241c1257826dc6f26f913
1 # CMakeLists.txt
3 # Copyright (C) 2013-2023 by
4 # David Turner, Robert Wilhelm, and Werner Lemberg.
6 # Written originally by John Cary <cary@txcorp.com>
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.
15 # The following will (1) create a build directory, and (2) change into it and
16 # call cmake to configure the build with default parameters as a static
17 # library.  See
19 #   https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html
21 # for information about debug or release builds, for example
23 #   cmake -B build -D CMAKE_BUILD_TYPE=Release
26 # For a dynamic library, use
28 #   cmake -B build -D BUILD_SHARED_LIBS=true -D CMAKE_BUILD_TYPE=Release
30 # For a framework on OS X, use
32 #   cmake -E chdir build cmake -G Xcode -D BUILD_FRAMEWORK:BOOL=true ..
34 # For an iOS static library, use
36 #   cmake -E chdir build cmake -G Xcode -D IOS_PLATFORM=OS ..
38 # or
40 #   cmake -E chdir build cmake -G Xcode -D IOS_PLATFORM=SIMULATOR ..
42 # or
44 #   cmake -E chdir build cmake -G Xcode -D IOS_PLATFORM=SIMULATOR64 ..
47 # Finally, build the project with
49 #   cmake --build build
51 # Install it with
53 #   (sudo) cmake --build build --target install
55 # A binary distribution can be made with
57 #   cmake --build build --config Release --target package
59 # Please refer to the cmake manual for further options, in particular, how
60 # to modify compilation and linking parameters.
62 # Some notes.
64 # - Say `cmake -LAH` to see all configuration options.
66 # - `cmake' creates configuration files in
68 #     <build-directory>/include/freetype/config
70 #   which should be further modified if necessary.
72 # - You can use `cmake' directly on a freshly cloned FreeType git
73 #   repository.
75 # - `CMakeLists.txt' is provided as-is since it is normally not used by the
76 #   developer team.
78 # - Set the `FT_REQUIRE_ZLIB', `FT_REQUIRE_BZIP2', `FT_REQUIRE_PNG',
79 #   `FT_REQUIRE_HARFBUZZ', and `FT_REQUIRE_BROTLI' CMake variables to `ON'
80 #   or `TRUE' to force using a dependency.  Leave a variable undefined
81 #   (which is the default) to use the dependency only if it is available.
82 #   Example:
84 #     cmake -B build -D FT_REQUIRE_ZLIB=TRUE \
85 #                    -D FT_REQUIRE_BZIP2=TRUE \
86 #                    -D FT_REQUIRE_PNG=TRUE \
87 #                    -D FT_REQUIRE_HARFBUZZ=TRUE \
88 #                    -D FT_REQUIRE_BROTLI=TRUE [...]
90 # - Set `FT_DISABLE_XXX=TRUE' to disable a dependency completely (where
91 #   `XXX' is a CMake package name like `BZip2').  Example for disabling all
92 #   dependencies:
94 #     cmake -B build -D FT_DISABLE_ZLIB=TRUE \
95 #                    -D FT_DISABLE_BZIP2=TRUE \
96 #                    -D FT_DISABLE_PNG=TRUE \
97 #                    -D FT_DISABLE_HARFBUZZ=TRUE \
98 #                    -D FT_DISABLE_BROTLI=TRUE [...]
100 # - NOTE: If a package is set as DISABLED, it cannot be set as REQUIRED
101 #   without unsetting the DISABLED value first.  For example, if
102 #   `FT_DISABLE_HARFBUZZ=TRUE' has been set (Cache is present), you need to
103 #   call `FT_DISABLE_HARFBUZZ=FALSE' before calling
104 #   `FT_REQUIRE_HARFBUZZ=TRUE'.
106 # - Installation of FreeType can be controlled with the CMake variables
107 #   `SKIP_INSTALL_HEADERS', `SKIP_INSTALL_LIBRARIES', and `SKIP_INSTALL_ALL'
108 #   (this is compatible with the same CMake variables in zlib's CMake
109 #   support).
111 # To minimize the number of cmake_policy() workarounds,
112 # CMake >= 3 is requested.
113 cmake_minimum_required(VERSION 3.0)
115 if (NOT CMAKE_VERSION VERSION_LESS 3.3)
116   # Allow symbol visibility settings also on static libraries. CMake < 3.3
117   # only sets the property on a shared library build.
118   cmake_policy(SET CMP0063 NEW)
120   # Support new IN_LIST if() operator.
121   cmake_policy(SET CMP0057 NEW)
122 endif ()
124 include(CheckIncludeFile)
125 include(CMakeDependentOption)
127 # CMAKE_TOOLCHAIN_FILE must be set before `project' is called, which
128 # configures the base build environment and references the toolchain file
129 if (APPLE)
130   if (DEFINED IOS_PLATFORM)
131     if (NOT "${IOS_PLATFORM}" STREQUAL "OS"
132         AND NOT "${IOS_PLATFORM}" STREQUAL "SIMULATOR"
133         AND NOT "${IOS_PLATFORM}" STREQUAL "SIMULATOR64")
134       message(FATAL_ERROR
135         "IOS_PLATFORM must be set to either OS, SIMULATOR, or SIMULATOR64")
136     endif ()
137     if (NOT "${CMAKE_GENERATOR}" STREQUAL "Xcode")
138       message(AUTHOR_WARNING
139         "You should use Xcode generator with IOS_PLATFORM enabled to get Universal builds.")
140     endif ()
141     if (BUILD_SHARED_LIBS)
142       message(FATAL_ERROR
143         "BUILD_SHARED_LIBS can not be on with IOS_PLATFORM enabled")
144     endif ()
145     if (BUILD_FRAMEWORK)
146       message(FATAL_ERROR
147         "BUILD_FRAMEWORK can not be on with IOS_PLATFORM enabled")
148     endif ()
150     # iOS only uses static libraries
151     set(BUILD_SHARED_LIBS OFF)
153     set(CMAKE_TOOLCHAIN_FILE
154       ${CMAKE_SOURCE_DIR}/builds/cmake/iOS.cmake)
155   endif ()
156 else ()
157   if (DEFINED IOS_PLATFORM)
158     message(FATAL_ERROR "IOS_PLATFORM is not supported on this platform")
159   endif ()
160 endif ()
163 project(freetype C)
165 set(VERSION_MAJOR "2")
166 set(VERSION_MINOR "13")
167 set(VERSION_PATCH "2")
169 # Generate LIBRARY_VERSION and LIBRARY_SOVERSION.
170 set(LIBTOOL_REGEX "version_info='([0-9]+):([0-9]+):([0-9]+)'")
171 file(STRINGS "${PROJECT_SOURCE_DIR}/builds/unix/configure.raw"
172   VERSION_INFO
173   REGEX ${LIBTOOL_REGEX})
174 string(REGEX REPLACE
175   ${LIBTOOL_REGEX} "\\1"
176   LIBTOOL_CURRENT "${VERSION_INFO}")
177 string(REGEX REPLACE
178   ${LIBTOOL_REGEX} "\\2"
179   LIBTOOL_REVISION "${VERSION_INFO}")
180 string(REGEX REPLACE
181   ${LIBTOOL_REGEX} "\\3"
182   LIBTOOL_AGE "${VERSION_INFO}")
184 # This is what libtool does internally on Unix platforms.
185 math(EXPR LIBRARY_SOVERSION "${LIBTOOL_CURRENT} - ${LIBTOOL_AGE}")
186 set(LIBRARY_VERSION "${LIBRARY_SOVERSION}.${LIBTOOL_AGE}.${LIBTOOL_REVISION}")
188 # External dependency library detection is automatic.  See the notes at the
189 # top of this file, for how to force or disable dependencies completely.
190 option(FT_DISABLE_ZLIB
191   "Disable use of system zlib and use internal zlib library instead." OFF)
192 cmake_dependent_option(FT_REQUIRE_ZLIB
193   "Require system zlib instead of internal zlib library." OFF
194   "NOT FT_DISABLE_ZLIB" OFF)
196 option(FT_DISABLE_BZIP2
197   "Disable support of bzip2 compressed fonts." OFF)
198 cmake_dependent_option(FT_REQUIRE_BZIP2
199   "Require support of bzip2 compressed fonts." OFF
200   "NOT FT_DISABLE_BZIP2" OFF)
202 option(FT_DISABLE_PNG
203   "Disable support of PNG compressed OpenType embedded bitmaps." OFF)
204 cmake_dependent_option(FT_REQUIRE_PNG
205   "Require support of PNG compressed OpenType embedded bitmaps." OFF
206   "NOT FT_DISABLE_PNG" OFF)
208 option(FT_DISABLE_HARFBUZZ
209   "Disable HarfBuzz (used for improving auto-hinting of OpenType fonts)." OFF)
210 cmake_dependent_option(FT_REQUIRE_HARFBUZZ
211   "Require HarfBuzz for improving auto-hinting of OpenType fonts." OFF
212   "NOT FT_DISABLE_HARFBUZZ" OFF)
214 option(FT_DISABLE_BROTLI
215   "Disable support of compressed WOFF2 fonts." OFF)
216 cmake_dependent_option(FT_REQUIRE_BROTLI
217   "Require support of compressed WOFF2 fonts." OFF
218   "NOT FT_DISABLE_BROTLI" OFF)
220 option(FT_ENABLE_ERROR_STRINGS
221   "Enable support for meaningful error descriptions." OFF)
223 # Disallow in-source builds
224 if ("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
225   message(FATAL_ERROR
226     "In-source builds are not permitted!  Make a separate folder for"
227     " building, e.g.,\n"
228     "  cmake -E make_directory build\n"
229     "  cmake -E chdir build cmake ..\n"
230     "Before that, remove the files created by this failed run with\n"
231     "  cmake -E remove CMakeCache.txt\n"
232     "  cmake -E remove_directory CMakeFiles")
233 endif ()
236 # Add local cmake modules
237 list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/builds/cmake)
240 if (BUILD_FRAMEWORK)
241   if (NOT "${CMAKE_GENERATOR}" STREQUAL "Xcode")
242     message(FATAL_ERROR
243       "You should use Xcode generator with BUILD_FRAMEWORK enabled")
244   endif ()
245   set(CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD)")
246   set(BUILD_SHARED_LIBS ON)
247 endif ()
250 # Find dependencies
251 include(FindPkgConfig)
253 if (NOT FT_DISABLE_HARFBUZZ)
254   set(HARFBUZZ_MIN_VERSION "2.0.0")
255   if (FT_REQUIRE_HARFBUZZ)
256     find_package(HarfBuzz ${HARFBUZZ_MIN_VERSION} REQUIRED)
257   else ()
258     find_package(HarfBuzz ${HARFBUZZ_MIN_VERSION})
259   endif ()
260 endif ()
262 if (NOT FT_DISABLE_PNG)
263   if (FT_REQUIRE_PNG)
264     find_package(PNG REQUIRED)
265   else ()
266     find_package(PNG)
267   endif ()
268 endif ()
270 if (NOT FT_DISABLE_ZLIB)
271   if (FT_REQUIRE_ZLIB)
272     find_package(ZLIB REQUIRED)
273   else ()
274     find_package(ZLIB)
275   endif ()
276 endif ()
278 if (NOT FT_DISABLE_BZIP2)
279   # Genuine BZip2 does not provide bzip2.pc, but some platforms have it.
280   # For better dependency in freetype2.pc, bzip2.pc is searched
281   # regardless of the availability of libbz2. If bzip2.pc is found,
282   # Requires.private is used instead of Libs.private.
283   if (FT_REQUIRE_BZIP2)
284     find_package(BZip2 REQUIRED)
285   else ()
286     find_package(BZip2)
287   endif ()
288   pkg_check_modules(PC_BZIP2 bzip2)
289 endif ()
291 if (NOT FT_DISABLE_BROTLI)
292   if (FT_REQUIRE_BROTLI)
293     find_package(BrotliDec REQUIRED)
294   else ()
295     find_package(BrotliDec)
296   endif ()
297 endif ()
299 # Create the configuration file
300 if (UNIX)
301   check_include_file("unistd.h" HAVE_UNISTD_H)
302   check_include_file("fcntl.h" HAVE_FCNTL_H)
304   file(READ "${PROJECT_SOURCE_DIR}/builds/unix/ftconfig.h.in"
305     FTCONFIG_H)
306   if (HAVE_UNISTD_H)
307     string(REGEX REPLACE
308       "#undef +(HAVE_UNISTD_H)" "#define \\1 1"
309       FTCONFIG_H "${FTCONFIG_H}")
310   endif ()
311   if (HAVE_FCNTL_H)
312     string(REGEX REPLACE
313       "#undef +(HAVE_FCNTL_H)" "#define \\1 1"
314       FTCONFIG_H "${FTCONFIG_H}")
315   endif ()
316 else ()
317   file(READ "${PROJECT_SOURCE_DIR}/include/freetype/config/ftconfig.h"
318     FTCONFIG_H)
319 endif ()
321 set(FTCONFIG_H_NAME "${PROJECT_BINARY_DIR}/include/freetype/config/ftconfig.h")
322 if (EXISTS "${FTCONFIG_H_NAME}")
323   file(READ "${FTCONFIG_H_NAME}" ORIGINAL_FTCONFIG_H)
324 else ()
325   set(ORIGINAL_FTCONFIG_H "")
326 endif ()
327 if (NOT (ORIGINAL_FTCONFIG_H STREQUAL FTCONFIG_H))
328   file(WRITE "${FTCONFIG_H_NAME}" "${FTCONFIG_H}")
329 endif ()
332 # Create the options file
333 file(READ "${PROJECT_SOURCE_DIR}/include/freetype/config/ftoption.h"
334   FTOPTION_H)
335 if (ZLIB_FOUND)
336   string(REGEX REPLACE
337     "/\\* +(#define +FT_CONFIG_OPTION_SYSTEM_ZLIB) +\\*/" "\\1"
338     FTOPTION_H "${FTOPTION_H}")
339 endif ()
340 if (BZIP2_FOUND)
341   string(REGEX REPLACE
342     "/\\* +(#define +FT_CONFIG_OPTION_USE_BZIP2) +\\*/" "\\1"
343     FTOPTION_H "${FTOPTION_H}")
344 endif ()
345 if (PNG_FOUND)
346   string(REGEX REPLACE
347     "/\\* +(#define +FT_CONFIG_OPTION_USE_PNG) +\\*/" "\\1"
348     FTOPTION_H "${FTOPTION_H}")
349 endif ()
350 if (HARFBUZZ_FOUND)
351   string(REGEX REPLACE
352     "/\\* +(#define +FT_CONFIG_OPTION_USE_HARFBUZZ) +\\*/" "\\1"
353     FTOPTION_H "${FTOPTION_H}")
354 endif ()
355 if (BROTLIDEC_FOUND)
356   string(REGEX REPLACE
357     "/\\* +(#define +FT_CONFIG_OPTION_USE_BROTLI) +\\*/" "\\1"
358     FTOPTION_H "${FTOPTION_H}")
359 endif ()
361 if (FT_ENABLE_ERROR_STRINGS)
362   string(REGEX REPLACE
363     "/\\* +(#define +FT_CONFIG_OPTION_ERROR_STRINGS) +\\*/" "\\1"
364     FTOPTION_H "${FTOPTION_H}")
365 endif ()
367 set(FTOPTION_H_NAME "${PROJECT_BINARY_DIR}/include/freetype/config/ftoption.h")
368 if (EXISTS "${FTOPTION_H_NAME}")
369   file(READ "${FTOPTION_H_NAME}" ORIGINAL_FTOPTION_H)
370 else ()
371   set(ORIGINAL_FTOPTION_H "")
372 endif ()
373 if (NOT (ORIGINAL_FTOPTION_H STREQUAL FTOPTION_H))
374   file(WRITE "${FTOPTION_H_NAME}" "${FTOPTION_H}")
375 endif ()
378 file(GLOB PUBLIC_HEADERS "include/ft2build.h" "include/freetype/*.h")
379 file(GLOB PUBLIC_CONFIG_HEADERS "include/freetype/config/*.h")
380 file(GLOB PRIVATE_HEADERS "include/freetype/internal/*.h")
383 set(BASE_SRCS
384   src/autofit/autofit.c
385   src/base/ftbase.c
386   src/base/ftbbox.c
387   src/base/ftbdf.c
388   src/base/ftbitmap.c
389   src/base/ftcid.c
390   src/base/ftfstype.c
391   src/base/ftgasp.c
392   src/base/ftglyph.c
393   src/base/ftgxval.c
394   src/base/ftinit.c
395   src/base/ftmm.c
396   src/base/ftotval.c
397   src/base/ftpatent.c
398   src/base/ftpfr.c
399   src/base/ftstroke.c
400   src/base/ftsynth.c
401   src/base/fttype1.c
402   src/base/ftwinfnt.c
403   src/bdf/bdf.c
404   src/bzip2/ftbzip2.c
405   src/cache/ftcache.c
406   src/cff/cff.c
407   src/cid/type1cid.c
408   src/gzip/ftgzip.c
409   src/lzw/ftlzw.c
410   src/pcf/pcf.c
411   src/pfr/pfr.c
412   src/psaux/psaux.c
413   src/pshinter/pshinter.c
414   src/psnames/psnames.c
415   src/raster/raster.c
416   src/sdf/sdf.c
417   src/sfnt/sfnt.c
418   src/smooth/smooth.c
419   src/svg/svg.c
420   src/truetype/truetype.c
421   src/type1/type1.c
422   src/type42/type42.c
423   src/winfonts/winfnt.c
426 if (UNIX)
427   list(APPEND BASE_SRCS "builds/unix/ftsystem.c")
428 elseif (WIN32)
429   list(APPEND BASE_SRCS "builds/windows/ftsystem.c")
430 else ()
431   list(APPEND BASE_SRCS "src/base/ftsystem.c")
432 endif ()
434 if (WIN32)
435   enable_language(RC)
436   list(APPEND BASE_SRCS builds/windows/ftdebug.c
437                         src/base/ftver.rc)
438 elseif (WINCE)
439   list(APPEND BASE_SRCS builds/wince/ftdebug.c)
440 else ()
441   list(APPEND BASE_SRCS src/base/ftdebug.c)
442 endif ()
444 if (BUILD_FRAMEWORK)
445   list(APPEND BASE_SRCS builds/mac/freetype-Info.plist)
446 endif ()
449 if (NOT DISABLE_FORCE_DEBUG_POSTFIX)
450   set(CMAKE_DEBUG_POSTFIX d)
451 endif ()
454 add_library(freetype
455   ${PUBLIC_HEADERS}
456   ${PUBLIC_CONFIG_HEADERS}
457   ${PRIVATE_HEADERS}
458   ${BASE_SRCS}
461 set_target_properties(
462   freetype PROPERTIES
463     C_VISIBILITY_PRESET hidden)
465 target_compile_definitions(
466   freetype PRIVATE FT2_BUILD_LIBRARY)
468 if (WIN32)
469   target_compile_definitions(
470     freetype PRIVATE _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_WARNINGS)
471   if (BUILD_SHARED_LIBS)
472     target_compile_definitions(
473       freetype PRIVATE DLL_EXPORT)
474   endif ()
475 endif ()
477 if (BUILD_SHARED_LIBS)
478   set_target_properties(freetype PROPERTIES
479     VERSION ${LIBRARY_VERSION}
480     SOVERSION ${LIBRARY_SOVERSION})
481 endif ()
483 # Pick up ftconfig.h and ftoption.h generated above, first.
484 target_include_directories(
485   freetype
486     PUBLIC
487       $<INSTALL_INTERFACE:include/freetype2>
488       $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
489       $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
490     PRIVATE
491       ${CMAKE_CURRENT_BINARY_DIR}/include
492       ${CMAKE_CURRENT_SOURCE_DIR}/include
494       # Make <ftconfig.h> available for builds/unix/ftsystem.c.
495       ${CMAKE_CURRENT_BINARY_DIR}/include/freetype/config
499 if (BUILD_FRAMEWORK)
500   set_property(SOURCE ${PUBLIC_CONFIG_HEADERS}
501     PROPERTY MACOSX_PACKAGE_LOCATION Headers/config
502   )
503   set_target_properties(freetype PROPERTIES
504     FRAMEWORK TRUE
505     MACOSX_FRAMEWORK_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/builds/mac/freetype-Info.plist
506     PUBLIC_HEADER "${PUBLIC_HEADERS}"
507     XCODE_ATTRIBUTE_INSTALL_PATH "@rpath"
508   )
509 endif ()
511 # 'freetype-interface' is an interface library, to be accessed with
512 # `EXPORT_NAME Freetype::Freetype`.  This is the target name provided by
513 # CMake's `FindFreetype.cmake`, so we provide it for compatibility.
514 add_library(freetype-interface INTERFACE)
515 set_target_properties(freetype-interface PROPERTIES
516   EXPORT_NAME Freetype::Freetype
517   INTERFACE_LINK_LIBRARIES freetype)
519 set(PKGCONFIG_REQUIRES "")
520 set(PKGCONFIG_REQUIRES_PRIVATE "")
521 set(PKGCONFIG_LIBS "-L\${libdir} -lfreetype")
522 set(PKGCONFIG_LIBS_PRIVATE "")
524 if (ZLIB_FOUND)
525   target_link_libraries(freetype PRIVATE ${ZLIB_LIBRARIES})
526   target_include_directories(freetype PRIVATE ${ZLIB_INCLUDE_DIRS})
527   list(APPEND PKGCONFIG_REQUIRES_PRIVATE "zlib")
528 endif ()
529 if (BZIP2_FOUND)
530   target_link_libraries(freetype PRIVATE ${BZIP2_LIBRARIES})
531   target_include_directories(freetype PRIVATE ${BZIP2_INCLUDE_DIR}) # not BZIP2_INCLUDE_DIRS
532   if (PC_BZIP2_FOUND)
533     list(APPEND PKGCONFIG_REQUIRES_PRIVATE "bzip2")
534   else ()
535     list(APPEND PKGCONFIG_LIBS_PRIVATE "-lbz2")
536   endif ()
537 endif ()
538 if (PNG_FOUND)
539   target_link_libraries(freetype PRIVATE ${PNG_LIBRARIES})
540   target_compile_definitions(freetype PRIVATE ${PNG_DEFINITIONS})
541   target_include_directories(freetype PRIVATE ${PNG_INCLUDE_DIRS})
542   list(APPEND PKGCONFIG_REQUIRES_PRIVATE "libpng")
543 endif ()
544 if (HarfBuzz_FOUND)
545   target_link_libraries(freetype PRIVATE ${HarfBuzz_LIBRARY})
546   target_include_directories(freetype PRIVATE ${HarfBuzz_INCLUDE_DIRS})
547   list(APPEND PKGCONFIG_REQUIRES_PRIVATE "harfbuzz >= ${HARFBUZZ_MIN_VERSION}")
548 endif ()
549 if (BROTLIDEC_FOUND)
550   target_link_libraries(freetype PRIVATE ${BROTLIDEC_LIBRARIES})
551   target_compile_definitions(freetype PRIVATE ${BROTLIDEC_DEFINITIONS})
552   target_include_directories(freetype PRIVATE ${BROTLIDEC_INCLUDE_DIRS})
553   list(APPEND PKGCONFIG_REQUIRES_PRIVATE "libbrotlidec")
554 endif ()
557 # Installation
558 include(GNUInstallDirs)
560 if (NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL)
561   install(
562     # Note the trailing slash in the argument to `DIRECTORY'!
563     DIRECTORY ${PROJECT_SOURCE_DIR}/include/
564       DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/freetype2
565       COMPONENT headers
566       PATTERN "internal" EXCLUDE
567       PATTERN "ftconfig.h" EXCLUDE
568       PATTERN "ftoption.h" EXCLUDE)
569   install(
570     FILES ${PROJECT_BINARY_DIR}/include/freetype/config/ftconfig.h
571           ${PROJECT_BINARY_DIR}/include/freetype/config/ftoption.h
572       DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/freetype2/freetype/config
573       COMPONENT headers)
574 endif ()
576 if (NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL)
577   # Generate the pkg-config file
578   file(READ "${PROJECT_SOURCE_DIR}/builds/unix/freetype2.in" FREETYPE2_PC_IN)
580   string(REPLACE ";" ", " PKGCONFIG_REQUIRES_PRIVATE "${PKGCONFIG_REQUIRES_PRIVATE}")
582   string(REPLACE "%prefix%" ${CMAKE_INSTALL_PREFIX}
583           FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
584   string(REPLACE "%exec_prefix%" "\${prefix}"
585           FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
586   string(REPLACE "%libdir%" "\${prefix}/${CMAKE_INSTALL_LIBDIR}"
587           FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
588   string(REPLACE "%includedir%" "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}"
589           FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
590   string(REPLACE "%ft_version%" "${LIBTOOL_CURRENT}.${LIBTOOL_REVISION}.${LIBTOOL_AGE}"
591           FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
593   if (BUILD_SHARED_LIBS)
594     string(REPLACE "%PKGCONFIG_REQUIRES%" "${PKGCONFIG_REQUIRES}"
595             FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
596     string(REPLACE "%PKGCONFIG_REQUIRES_PRIVATE%" "${PKGCONFIG_REQUIRES_PRIVATE}"
597             FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
598     string(REPLACE "%PKGCONFIG_LIBS%" "${PKGCONFIG_LIBS}"
599             FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
600     string(REPLACE "%PKGCONFIG_LIBS_PRIVATE%" "${PKGCONFIG_LIBS_PRIVATE}"
601             FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
602   else ()
603     string(REPLACE "%PKGCONFIG_REQUIRES%" "${PKGCONFIG_REQUIRES} ${PKGCONFIG_REQUIRES_PRIVATE}"
604             FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
605     string(REPLACE "%PKGCONFIG_REQUIRES_PRIVATE%" ""
606             FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
607     string(REPLACE "%PKGCONFIG_LIBS%" "${PKGCONFIG_LIBS} ${PKGCONFIG_LIBS_PRIVATE}"
608             FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
609     string(REPLACE "%PKGCONFIG_LIBS_PRIVATE%" ""
610             FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
611   endif ()
613   set(FREETYPE2_PC_IN_NAME "${PROJECT_BINARY_DIR}/freetype2.pc")
614   if (EXISTS "${FREETYPE2_PC_IN_NAME}")
615     file(READ "${FREETYPE2_PC_IN_NAME}" ORIGINAL_FREETYPE2_PC_IN)
616   else ()
617     set(ORIGINAL_FREETYPE2_PC_IN "")
618   endif ()
619   if (NOT (ORIGINAL_FREETYPE2_PC_IN STREQUAL FREETYPE2_PC_IN))
620     file(WRITE "${FREETYPE2_PC_IN_NAME}" ${FREETYPE2_PC_IN})
621   endif ()
623   install(
624     FILES ${PROJECT_BINARY_DIR}/freetype2.pc
625     DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
626     COMPONENT pkgconfig)
628   include(CMakePackageConfigHelpers)
629   write_basic_package_version_file(
630     ${PROJECT_BINARY_DIR}/freetype-config-version.cmake
631     VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
632     COMPATIBILITY SameMajorVersion)
634   install(
635     TARGETS freetype freetype-interface
636       EXPORT freetype-targets
637       LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
638       ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
639       RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
640       FRAMEWORK DESTINATION Library/Frameworks
641       COMPONENT libraries)
642   install(
643     EXPORT freetype-targets
644       DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/freetype
645       FILE freetype-config.cmake
646       COMPONENT headers)
647   install(
648     FILES ${PROJECT_BINARY_DIR}/freetype-config-version.cmake
649     DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/freetype
650     COMPONENT headers)
651 endif ()
654 # Packaging
655 set(CPACK_PACKAGE_NAME ${CMAKE_PROJECT_NAME})
656 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The FreeType font rendering library.")
657 set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
658 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.TXT")
660 set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
661 set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
662 set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH})
663 set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
665 if (WIN32)
666   set(CPACK_GENERATOR ZIP)
667 else ()
668   set(CPACK_GENERATOR TGZ)
669 endif ()
671 set(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "Libraries")
672 set(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C/C++ Headers")
673 set(CPACK_COMPONENT_LIBRARIES_DESCRIPTION
674   "Library used to build programs which use FreeType")
675 set(CPACK_COMPONENT_HEADERS_DESCRIPTION
676   "C/C++ header files for use with FreeType")
677 set(CPACK_COMPONENT_HEADERS_DEPENDS libraries)
678 set(CPACK_COMPONENT_LIBRARIES_GROUP "Development")
679 set(CPACK_COMPONENT_HEADERS_GROUP "Development")
681 include(CPack)