Bug 1909986 - For sidebar revamp, only show chatbot entrypoints (context menu, shortc...
[gecko.git] / modules / freetype2 / CMakeLists.txt
blob36516e4abdb115ee103da7f5b5f9c241bf79c264
1 # CMakeLists.txt
3 # Copyright (C) 2013-2024 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...3.5)
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 "3")
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   # FreePNG calls FindZLIB so unset ZLIB_FOUND to respect FT_DISABLE_ZLIB
269   unset(ZLIB_FOUND)
270 endif ()
272 if (NOT FT_DISABLE_ZLIB)
273   if (FT_REQUIRE_ZLIB)
274     find_package(ZLIB REQUIRED)
275   else ()
276     find_package(ZLIB)
277   endif ()
278 endif ()
280 if (NOT FT_DISABLE_BZIP2)
281   # Genuine BZip2 does not provide bzip2.pc, but some platforms have it.
282   # For better dependency in freetype2.pc, bzip2.pc is searched
283   # regardless of the availability of libbz2. If bzip2.pc is found,
284   # Requires.private is used instead of Libs.private.
285   if (FT_REQUIRE_BZIP2)
286     find_package(BZip2 REQUIRED)
287   else ()
288     find_package(BZip2)
289   endif ()
290   pkg_check_modules(PC_BZIP2 bzip2)
291 endif ()
293 if (NOT FT_DISABLE_BROTLI)
294   if (FT_REQUIRE_BROTLI)
295     find_package(BrotliDec REQUIRED)
296   else ()
297     find_package(BrotliDec)
298   endif ()
299 endif ()
301 # Create the configuration file
302 if (UNIX AND NOT WIN32)
303   check_include_file("unistd.h" HAVE_UNISTD_H)
304   check_include_file("fcntl.h" HAVE_FCNTL_H)
306   file(READ "${PROJECT_SOURCE_DIR}/builds/unix/ftconfig.h.in"
307     FTCONFIG_H)
308   if (HAVE_UNISTD_H)
309     string(REGEX REPLACE
310       "#undef +(HAVE_UNISTD_H)" "#define \\1 1"
311       FTCONFIG_H "${FTCONFIG_H}")
312   endif ()
313   if (HAVE_FCNTL_H)
314     string(REGEX REPLACE
315       "#undef +(HAVE_FCNTL_H)" "#define \\1 1"
316       FTCONFIG_H "${FTCONFIG_H}")
317   endif ()
318 else ()
319   file(READ "${PROJECT_SOURCE_DIR}/include/freetype/config/ftconfig.h"
320     FTCONFIG_H)
321 endif ()
323 set(FTCONFIG_H_NAME "${PROJECT_BINARY_DIR}/include/freetype/config/ftconfig.h")
324 if (EXISTS "${FTCONFIG_H_NAME}")
325   file(READ "${FTCONFIG_H_NAME}" ORIGINAL_FTCONFIG_H)
326 else ()
327   set(ORIGINAL_FTCONFIG_H "")
328 endif ()
329 if (NOT (ORIGINAL_FTCONFIG_H STREQUAL FTCONFIG_H))
330   file(WRITE "${FTCONFIG_H_NAME}" "${FTCONFIG_H}")
331 endif ()
334 # Create the options file
335 file(READ "${PROJECT_SOURCE_DIR}/include/freetype/config/ftoption.h"
336   FTOPTION_H)
337 if (ZLIB_FOUND)
338   string(REGEX REPLACE
339     "/\\* +(#define +FT_CONFIG_OPTION_SYSTEM_ZLIB) +\\*/" "\\1"
340     FTOPTION_H "${FTOPTION_H}")
341 endif ()
342 if (BZIP2_FOUND)
343   string(REGEX REPLACE
344     "/\\* +(#define +FT_CONFIG_OPTION_USE_BZIP2) +\\*/" "\\1"
345     FTOPTION_H "${FTOPTION_H}")
346 endif ()
347 if (PNG_FOUND)
348   string(REGEX REPLACE
349     "/\\* +(#define +FT_CONFIG_OPTION_USE_PNG) +\\*/" "\\1"
350     FTOPTION_H "${FTOPTION_H}")
351 endif ()
352 if (HARFBUZZ_FOUND)
353   string(REGEX REPLACE
354     "/\\* +(#define +FT_CONFIG_OPTION_USE_HARFBUZZ) +\\*/" "\\1"
355     FTOPTION_H "${FTOPTION_H}")
356 endif ()
357 if (BROTLIDEC_FOUND)
358   string(REGEX REPLACE
359     "/\\* +(#define +FT_CONFIG_OPTION_USE_BROTLI) +\\*/" "\\1"
360     FTOPTION_H "${FTOPTION_H}")
361 endif ()
363 if (FT_ENABLE_ERROR_STRINGS)
364   string(REGEX REPLACE
365     "/\\* +(#define +FT_CONFIG_OPTION_ERROR_STRINGS) +\\*/" "\\1"
366     FTOPTION_H "${FTOPTION_H}")
367 endif ()
369 set(FTOPTION_H_NAME "${PROJECT_BINARY_DIR}/include/freetype/config/ftoption.h")
370 if (EXISTS "${FTOPTION_H_NAME}")
371   file(READ "${FTOPTION_H_NAME}" ORIGINAL_FTOPTION_H)
372 else ()
373   set(ORIGINAL_FTOPTION_H "")
374 endif ()
375 if (NOT (ORIGINAL_FTOPTION_H STREQUAL FTOPTION_H))
376   file(WRITE "${FTOPTION_H_NAME}" "${FTOPTION_H}")
377 endif ()
380 file(GLOB PUBLIC_HEADERS "include/ft2build.h" "include/freetype/*.h")
381 file(GLOB PUBLIC_CONFIG_HEADERS "include/freetype/config/*.h")
382 file(GLOB PRIVATE_HEADERS "include/freetype/internal/*.h")
385 set(BASE_SRCS
386   src/autofit/autofit.c
387   src/base/ftbase.c
388   src/base/ftbbox.c
389   src/base/ftbdf.c
390   src/base/ftbitmap.c
391   src/base/ftcid.c
392   src/base/ftfstype.c
393   src/base/ftgasp.c
394   src/base/ftglyph.c
395   src/base/ftgxval.c
396   src/base/ftinit.c
397   src/base/ftmm.c
398   src/base/ftotval.c
399   src/base/ftpatent.c
400   src/base/ftpfr.c
401   src/base/ftstroke.c
402   src/base/ftsynth.c
403   src/base/fttype1.c
404   src/base/ftwinfnt.c
405   src/bdf/bdf.c
406   src/bzip2/ftbzip2.c
407   src/cache/ftcache.c
408   src/cff/cff.c
409   src/cid/type1cid.c
410   src/gzip/ftgzip.c
411   src/lzw/ftlzw.c
412   src/pcf/pcf.c
413   src/pfr/pfr.c
414   src/psaux/psaux.c
415   src/pshinter/pshinter.c
416   src/psnames/psnames.c
417   src/raster/raster.c
418   src/sdf/sdf.c
419   src/sfnt/sfnt.c
420   src/smooth/smooth.c
421   src/svg/svg.c
422   src/truetype/truetype.c
423   src/type1/type1.c
424   src/type42/type42.c
425   src/winfonts/winfnt.c
428 if (WIN32)
429   list(APPEND BASE_SRCS "builds/windows/ftsystem.c")
430 elseif (UNIX)
431   list(APPEND BASE_SRCS "builds/unix/ftsystem.c")
432 else ()
433   list(APPEND BASE_SRCS "src/base/ftsystem.c")
434 endif ()
436 if (WIN32)
437   enable_language(RC)
438   list(APPEND BASE_SRCS builds/windows/ftdebug.c
439                         src/base/ftver.rc)
440 elseif (WINCE)
441   list(APPEND BASE_SRCS builds/wince/ftdebug.c)
442 else ()
443   list(APPEND BASE_SRCS src/base/ftdebug.c)
444 endif ()
446 if (BUILD_FRAMEWORK)
447   list(APPEND BASE_SRCS builds/mac/freetype-Info.plist)
448 endif ()
451 if (NOT DISABLE_FORCE_DEBUG_POSTFIX)
452   set(CMAKE_DEBUG_POSTFIX d)
453 endif ()
456 add_library(freetype
457   ${PUBLIC_HEADERS}
458   ${PUBLIC_CONFIG_HEADERS}
459   ${PRIVATE_HEADERS}
460   ${BASE_SRCS}
463 set_target_properties(
464   freetype PROPERTIES
465     C_VISIBILITY_PRESET hidden)
467 target_compile_definitions(
468   freetype PRIVATE FT2_BUILD_LIBRARY)
470 if (WIN32)
471   target_compile_definitions(
472     freetype PRIVATE _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_WARNINGS)
473   if (BUILD_SHARED_LIBS)
474     target_compile_definitions(
475       freetype PRIVATE DLL_EXPORT)
476   endif ()
477 endif ()
479 if (BUILD_SHARED_LIBS)
480   set_target_properties(freetype PROPERTIES
481     VERSION ${LIBRARY_VERSION}
482     SOVERSION ${LIBRARY_SOVERSION})
483 endif ()
485 # Pick up ftconfig.h and ftoption.h generated above, first.
486 target_include_directories(
487   freetype
488     PUBLIC
489       $<INSTALL_INTERFACE:include/freetype2>
490       $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
491       $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
492     PRIVATE
493       ${CMAKE_CURRENT_BINARY_DIR}/include
494       ${CMAKE_CURRENT_SOURCE_DIR}/include
496       # Make <ftconfig.h> available for builds/unix/ftsystem.c.
497       ${CMAKE_CURRENT_BINARY_DIR}/include/freetype/config
501 if (BUILD_FRAMEWORK)
502   set_property(SOURCE ${PUBLIC_CONFIG_HEADERS}
503     PROPERTY MACOSX_PACKAGE_LOCATION Headers/config
504   )
505   set_target_properties(freetype PROPERTIES
506     FRAMEWORK TRUE
507     MACOSX_FRAMEWORK_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/builds/mac/freetype-Info.plist
508     PUBLIC_HEADER "${PUBLIC_HEADERS}"
509     XCODE_ATTRIBUTE_INSTALL_PATH "@rpath"
510   )
511 endif ()
513 # 'freetype-interface' is an interface library, to be accessed with
514 # `EXPORT_NAME Freetype::Freetype`.  This is the target name provided by
515 # CMake's `FindFreetype.cmake`, so we provide it for compatibility.
516 add_library(freetype-interface INTERFACE)
517 set_target_properties(freetype-interface PROPERTIES
518   EXPORT_NAME Freetype::Freetype
519   INTERFACE_LINK_LIBRARIES freetype)
521 set(PKGCONFIG_REQUIRES "")
522 set(PKGCONFIG_REQUIRES_PRIVATE "")
523 set(PKGCONFIG_LIBS "-L\${libdir} -lfreetype")
524 set(PKGCONFIG_LIBS_PRIVATE "")
526 if (ZLIB_FOUND)
527   target_link_libraries(freetype PRIVATE ${ZLIB_LIBRARIES})
528   target_include_directories(freetype PRIVATE ${ZLIB_INCLUDE_DIRS})
529   list(APPEND PKGCONFIG_REQUIRES_PRIVATE "zlib")
530 endif ()
531 if (BZIP2_FOUND)
532   target_link_libraries(freetype PRIVATE ${BZIP2_LIBRARIES})
533   target_include_directories(freetype PRIVATE ${BZIP2_INCLUDE_DIR}) # not BZIP2_INCLUDE_DIRS
534   if (PC_BZIP2_FOUND)
535     list(APPEND PKGCONFIG_REQUIRES_PRIVATE "bzip2")
536   else ()
537     list(APPEND PKGCONFIG_LIBS_PRIVATE "-lbz2")
538   endif ()
539 endif ()
540 if (PNG_FOUND)
541   target_link_libraries(freetype PRIVATE ${PNG_LIBRARIES})
542   target_compile_definitions(freetype PRIVATE ${PNG_DEFINITIONS})
543   target_include_directories(freetype PRIVATE ${PNG_INCLUDE_DIRS})
544   list(APPEND PKGCONFIG_REQUIRES_PRIVATE "libpng")
545 endif ()
546 if (HarfBuzz_FOUND)
547   target_link_libraries(freetype PRIVATE ${HarfBuzz_LIBRARY})
548   target_include_directories(freetype PRIVATE ${HarfBuzz_INCLUDE_DIRS})
549   list(APPEND PKGCONFIG_REQUIRES_PRIVATE "harfbuzz >= ${HARFBUZZ_MIN_VERSION}")
550 endif ()
551 if (BROTLIDEC_FOUND)
552   target_link_libraries(freetype PRIVATE ${BROTLIDEC_LIBRARIES})
553   target_compile_definitions(freetype PRIVATE ${BROTLIDEC_DEFINITIONS})
554   target_include_directories(freetype PRIVATE ${BROTLIDEC_INCLUDE_DIRS})
555   list(APPEND PKGCONFIG_REQUIRES_PRIVATE "libbrotlidec")
556 endif ()
559 # Installation
560 include(GNUInstallDirs)
562 if (NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL)
563   install(
564     # Note the trailing slash in the argument to `DIRECTORY'!
565     DIRECTORY ${PROJECT_SOURCE_DIR}/include/
566       DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/freetype2
567       COMPONENT headers
568       PATTERN "internal" EXCLUDE
569       PATTERN "ftconfig.h" EXCLUDE
570       PATTERN "ftoption.h" EXCLUDE)
571   install(
572     FILES ${PROJECT_BINARY_DIR}/include/freetype/config/ftconfig.h
573           ${PROJECT_BINARY_DIR}/include/freetype/config/ftoption.h
574       DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/freetype2/freetype/config
575       COMPONENT headers)
576 endif ()
578 if (NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL)
579   # Generate the pkg-config file
580   file(READ "${PROJECT_SOURCE_DIR}/builds/unix/freetype2.in" FREETYPE2_PC_IN)
582   string(REPLACE ";" ", " PKGCONFIG_REQUIRES_PRIVATE "${PKGCONFIG_REQUIRES_PRIVATE}")
584   string(REPLACE "%prefix%" ${CMAKE_INSTALL_PREFIX}
585           FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
586   string(REPLACE "%exec_prefix%" "\${prefix}"
587           FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
588   string(REPLACE "%libdir%" "\${prefix}/${CMAKE_INSTALL_LIBDIR}"
589           FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
590   string(REPLACE "%includedir%" "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}"
591           FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
592   string(REPLACE "%ft_version%" "${LIBTOOL_CURRENT}.${LIBTOOL_REVISION}.${LIBTOOL_AGE}"
593           FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
595   if (BUILD_SHARED_LIBS)
596     string(REPLACE "%PKGCONFIG_REQUIRES%" "${PKGCONFIG_REQUIRES}"
597             FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
598     string(REPLACE "%PKGCONFIG_REQUIRES_PRIVATE%" "${PKGCONFIG_REQUIRES_PRIVATE}"
599             FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
600     string(REPLACE "%PKGCONFIG_LIBS%" "${PKGCONFIG_LIBS}"
601             FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
602     string(REPLACE "%PKGCONFIG_LIBS_PRIVATE%" "${PKGCONFIG_LIBS_PRIVATE}"
603             FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
604   else ()
605     string(REPLACE "%PKGCONFIG_REQUIRES%" "${PKGCONFIG_REQUIRES} ${PKGCONFIG_REQUIRES_PRIVATE}"
606             FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
607     string(REPLACE "%PKGCONFIG_REQUIRES_PRIVATE%" ""
608             FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
609     string(REPLACE "%PKGCONFIG_LIBS%" "${PKGCONFIG_LIBS} ${PKGCONFIG_LIBS_PRIVATE}"
610             FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
611     string(REPLACE "%PKGCONFIG_LIBS_PRIVATE%" ""
612             FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
613   endif ()
615   set(FREETYPE2_PC_IN_NAME "${PROJECT_BINARY_DIR}/freetype2.pc")
616   if (EXISTS "${FREETYPE2_PC_IN_NAME}")
617     file(READ "${FREETYPE2_PC_IN_NAME}" ORIGINAL_FREETYPE2_PC_IN)
618   else ()
619     set(ORIGINAL_FREETYPE2_PC_IN "")
620   endif ()
621   if (NOT (ORIGINAL_FREETYPE2_PC_IN STREQUAL FREETYPE2_PC_IN))
622     file(WRITE "${FREETYPE2_PC_IN_NAME}" ${FREETYPE2_PC_IN})
623   endif ()
625   install(
626     FILES ${PROJECT_BINARY_DIR}/freetype2.pc
627     DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
628     COMPONENT pkgconfig)
630   include(CMakePackageConfigHelpers)
631   write_basic_package_version_file(
632     ${PROJECT_BINARY_DIR}/freetype-config-version.cmake
633     VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
634     COMPATIBILITY SameMajorVersion)
636   install(
637     TARGETS freetype freetype-interface
638       EXPORT freetype-targets
639       LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
640       ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
641       RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
642       FRAMEWORK DESTINATION Library/Frameworks
643       COMPONENT libraries)
644   install(
645     EXPORT freetype-targets
646       DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/freetype
647       FILE freetype-config.cmake
648       COMPONENT headers)
649   install(
650     FILES ${PROJECT_BINARY_DIR}/freetype-config-version.cmake
651     DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/freetype
652     COMPONENT headers)
653 endif ()
656 # Packaging
657 set(CPACK_PACKAGE_NAME ${CMAKE_PROJECT_NAME})
658 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The FreeType font rendering library.")
659 set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
660 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.TXT")
662 set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
663 set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
664 set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH})
665 set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
667 if (WIN32)
668   set(CPACK_GENERATOR ZIP)
669 else ()
670   set(CPACK_GENERATOR TGZ)
671 endif ()
673 set(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "Libraries")
674 set(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C/C++ Headers")
675 set(CPACK_COMPONENT_LIBRARIES_DESCRIPTION
676   "Library used to build programs which use FreeType")
677 set(CPACK_COMPONENT_HEADERS_DESCRIPTION
678   "C/C++ header files for use with FreeType")
679 set(CPACK_COMPONENT_HEADERS_DEPENDS libraries)
680 set(CPACK_COMPONENT_LIBRARIES_GROUP "Development")
681 set(CPACK_COMPONENT_HEADERS_GROUP "Development")
683 include(CPack)