Bug 1815313 - Add test for invalid schemes in onLoadRequest. r=jonalmeida
[gecko.git] / modules / freetype2 / CMakeLists.txt
blobcd04b974592e178262f13c30afea4cb453884039
1 # CMakeLists.txt
3 # Copyright (C) 2013-2022 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 # - `cmake' creates configuration files in
66 #     <build-directory>/include/freetype/config
68 #   which should be further modified if necessary.
70 # - You can use `cmake' directly on a freshly cloned FreeType git
71 #   repository.
73 # - `CMakeLists.txt' is provided as-is since it is normally not used by the
74 #   developer team.
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:
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 [...]
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
90 #   dependencies:
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 [...]
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'.
104 # - Installation of FreeType can be controlled with the CMake variables
105 #   `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).
109 # To minimize the number of cmake_policy() workarounds,
110 # CMake >= 3 is requested.
111 cmake_minimum_required(VERSION 3.0)
113 if (NOT CMAKE_VERSION VERSION_LESS 3.3)
114   # Allow symbol visibility settings also on static libraries. CMake < 3.3
115   # only sets the property on a shared library build.
116   cmake_policy(SET CMP0063 NEW)
118   # Support new IN_LIST if() operator.
119   cmake_policy(SET CMP0057 NEW)
120 endif ()
122 include(CheckIncludeFile)
123 include(CMakeDependentOption)
124 include(FindPkgConfig)
126 # CMAKE_TOOLCHAIN_FILE must be set before `project' is called, which
127 # configures the base build environment and references the toolchain file
128 if (APPLE)
129   if (DEFINED IOS_PLATFORM)
130     if (NOT "${IOS_PLATFORM}" STREQUAL "OS"
131         AND NOT "${IOS_PLATFORM}" STREQUAL "SIMULATOR"
132         AND NOT "${IOS_PLATFORM}" STREQUAL "SIMULATOR64")
133       message(FATAL_ERROR
134         "IOS_PLATFORM must be set to either OS, SIMULATOR, or SIMULATOR64")
135     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 ()
149     # iOS only uses static libraries
150     set(BUILD_SHARED_LIBS OFF)
152     set(CMAKE_TOOLCHAIN_FILE
153       ${CMAKE_SOURCE_DIR}/builds/cmake/iOS.cmake)
154   endif ()
155 else ()
156   if (DEFINED IOS_PLATFORM)
157     message(FATAL_ERROR "IOS_PLATFORM is not supported on this platform")
158   endif ()
159 endif ()
162 project(freetype C)
164 set(VERSION_MAJOR "2")
165 set(VERSION_MINOR "12")
166 set(VERSION_PATCH "1")
168 # Generate LIBRARY_VERSION and LIBRARY_SOVERSION.
169 set(LIBTOOL_REGEX "version_info='([0-9]+):([0-9]+):([0-9]+)'")
170 file(STRINGS "${PROJECT_SOURCE_DIR}/builds/unix/configure.raw"
171   VERSION_INFO
172   REGEX ${LIBTOOL_REGEX})
173 string(REGEX REPLACE
174   ${LIBTOOL_REGEX} "\\1"
175   LIBTOOL_CURRENT "${VERSION_INFO}")
176 string(REGEX REPLACE
177   ${LIBTOOL_REGEX} "\\2"
178   LIBTOOL_REVISION "${VERSION_INFO}")
179 string(REGEX REPLACE
180   ${LIBTOOL_REGEX} "\\3"
181   LIBTOOL_AGE "${VERSION_INFO}")
183 # This is what libtool does internally on Unix platforms.
184 math(EXPR LIBRARY_SOVERSION "${LIBTOOL_CURRENT} - ${LIBTOOL_AGE}")
185 set(LIBRARY_VERSION "${LIBRARY_SOVERSION}.${LIBTOOL_AGE}.${LIBTOOL_REVISION}")
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)
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)
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)
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)
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)
220 # Disallow in-source builds
221 if ("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
222   message(FATAL_ERROR
223     "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")
230 endif ()
233 # Add local cmake modules
234 list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/builds/cmake)
237 if (BUILD_FRAMEWORK)
238   if (NOT "${CMAKE_GENERATOR}" STREQUAL "Xcode")
239     message(FATAL_ERROR
240       "You should use Xcode generator with BUILD_FRAMEWORK enabled")
241   endif ()
242   set(CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD)")
243   set(BUILD_SHARED_LIBS ON)
244 endif ()
247 # Find dependencies
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 ()
255 endif ()
257 if (NOT FT_DISABLE_PNG)
258   if (FT_REQUIRE_PNG)
259     find_package(PNG REQUIRED)
260   else ()
261     find_package(PNG)
262   endif ()
263 endif ()
265 if (NOT FT_DISABLE_ZLIB)
266   if (FT_REQUIRE_ZLIB)
267     find_package(ZLIB REQUIRED)
268   else ()
269     find_package(ZLIB)
270   endif ()
271 endif ()
273 if (NOT FT_DISABLE_BZIP2)
274   # Genuine BZip2 does not provide bzip2.pc, but some platforms have it.
275   # For better dependency in freetype2.pc, bzip2.pc is searched
276   # regardless of the availability of libbz2. If bzip2.pc is found,
277   # Requires.private is used instead of Libs.private.
278   if (FT_REQUIRE_BZIP2)
279     find_package(BZip2 REQUIRED)
280   else ()
281     find_package(BZip2)
282   endif ()
283   pkg_check_modules(PC_BZIP2 bzip2)
284 endif ()
286 if (NOT FT_DISABLE_BROTLI)
287   if (FT_REQUIRE_BROTLI)
288     find_package(BrotliDec REQUIRED)
289   else ()
290     find_package(BrotliDec)
291   endif ()
292 endif ()
294 # Create the configuration file
295 if (UNIX)
296   check_include_file("unistd.h" HAVE_UNISTD_H)
297   check_include_file("fcntl.h" HAVE_FCNTL_H)
299   file(READ "${PROJECT_SOURCE_DIR}/builds/unix/ftconfig.h.in"
300     FTCONFIG_H)
301   if (HAVE_UNISTD_H)
302     string(REGEX REPLACE
303       "#undef +(HAVE_UNISTD_H)" "#define \\1 1"
304       FTCONFIG_H "${FTCONFIG_H}")
305   endif ()
306   if (HAVE_FCNTL_H)
307     string(REGEX REPLACE
308       "#undef +(HAVE_FCNTL_H)" "#define \\1 1"
309       FTCONFIG_H "${FTCONFIG_H}")
310   endif ()
311 else ()
312   file(READ "${PROJECT_SOURCE_DIR}/include/freetype/config/ftconfig.h"
313     FTCONFIG_H)
314 endif ()
316 set(FTCONFIG_H_NAME "${PROJECT_BINARY_DIR}/include/freetype/config/ftconfig.h")
317 if (EXISTS "${FTCONFIG_H_NAME}")
318   file(READ "${FTCONFIG_H_NAME}" ORIGINAL_FTCONFIG_H)
319 else ()
320   set(ORIGINAL_FTCONFIG_H "")
321 endif ()
322 if (NOT (ORIGINAL_FTCONFIG_H STREQUAL FTCONFIG_H))
323   file(WRITE "${FTCONFIG_H_NAME}" "${FTCONFIG_H}")
324 endif ()
327 # Create the options file
328 file(READ "${PROJECT_SOURCE_DIR}/include/freetype/config/ftoption.h"
329   FTOPTION_H)
330 if (ZLIB_FOUND)
331   string(REGEX REPLACE
332     "/\\* +(#define +FT_CONFIG_OPTION_SYSTEM_ZLIB) +\\*/" "\\1"
333     FTOPTION_H "${FTOPTION_H}")
334 endif ()
335 if (BZIP2_FOUND)
336   string(REGEX REPLACE
337     "/\\* +(#define +FT_CONFIG_OPTION_USE_BZIP2) +\\*/" "\\1"
338     FTOPTION_H "${FTOPTION_H}")
339 endif ()
340 if (PNG_FOUND)
341   string(REGEX REPLACE
342     "/\\* +(#define +FT_CONFIG_OPTION_USE_PNG) +\\*/" "\\1"
343     FTOPTION_H "${FTOPTION_H}")
344 endif ()
345 if (HARFBUZZ_FOUND)
346   string(REGEX REPLACE
347     "/\\* +(#define +FT_CONFIG_OPTION_USE_HARFBUZZ) +\\*/" "\\1"
348     FTOPTION_H "${FTOPTION_H}")
349 endif ()
350 if (BROTLIDEC_FOUND)
351   string(REGEX REPLACE
352     "/\\* +(#define +FT_CONFIG_OPTION_USE_BROTLI) +\\*/" "\\1"
353     FTOPTION_H "${FTOPTION_H}")
354 endif ()
356 set(FTOPTION_H_NAME "${PROJECT_BINARY_DIR}/include/freetype/config/ftoption.h")
357 if (EXISTS "${FTOPTION_H_NAME}")
358   file(READ "${FTOPTION_H_NAME}" ORIGINAL_FTOPTION_H)
359 else ()
360   set(ORIGINAL_FTOPTION_H "")
361 endif ()
362 if (NOT (ORIGINAL_FTOPTION_H STREQUAL FTOPTION_H))
363   file(WRITE "${FTOPTION_H_NAME}" "${FTOPTION_H}")
364 endif ()
367 file(GLOB PUBLIC_HEADERS "include/ft2build.h" "include/freetype/*.h")
368 file(GLOB PUBLIC_CONFIG_HEADERS "include/freetype/config/*.h")
369 file(GLOB PRIVATE_HEADERS "include/freetype/internal/*.h")
372 set(BASE_SRCS
373   src/autofit/autofit.c
374   src/base/ftbase.c
375   src/base/ftbbox.c
376   src/base/ftbdf.c
377   src/base/ftbitmap.c
378   src/base/ftcid.c
379   src/base/ftfstype.c
380   src/base/ftgasp.c
381   src/base/ftglyph.c
382   src/base/ftgxval.c
383   src/base/ftinit.c
384   src/base/ftmm.c
385   src/base/ftotval.c
386   src/base/ftpatent.c
387   src/base/ftpfr.c
388   src/base/ftstroke.c
389   src/base/ftsynth.c
390   src/base/fttype1.c
391   src/base/ftwinfnt.c
392   src/bdf/bdf.c
393   src/bzip2/ftbzip2.c
394   src/cache/ftcache.c
395   src/cff/cff.c
396   src/cid/type1cid.c
397   src/gzip/ftgzip.c
398   src/lzw/ftlzw.c
399   src/pcf/pcf.c
400   src/pfr/pfr.c
401   src/psaux/psaux.c
402   src/pshinter/pshinter.c
403   src/psnames/psnames.c
404   src/raster/raster.c
405   src/sdf/sdf.c
406   src/sfnt/sfnt.c
407   src/smooth/smooth.c
408   src/svg/svg.c
409   src/truetype/truetype.c
410   src/type1/type1.c
411   src/type42/type42.c
412   src/winfonts/winfnt.c
415 if (UNIX)
416   list(APPEND BASE_SRCS "builds/unix/ftsystem.c")
417 elseif (WIN32)
418   list(APPEND BASE_SRCS "builds/windows/ftsystem.c")
419 else ()
420   list(APPEND BASE_SRCS "src/base/ftsystem.c")
421 endif ()
423 if (WIN32)
424   enable_language(RC)
425   list(APPEND BASE_SRCS builds/windows/ftdebug.c
426                         src/base/ftver.rc)
427 elseif (WINCE)
428   list(APPEND BASE_SRCS builds/wince/ftdebug.c)
429 else ()
430   list(APPEND BASE_SRCS src/base/ftdebug.c)
431 endif ()
433 if (BUILD_FRAMEWORK)
434   list(APPEND BASE_SRCS builds/mac/freetype-Info.plist)
435 endif ()
438 if (NOT DISABLE_FORCE_DEBUG_POSTFIX)
439   set(CMAKE_DEBUG_POSTFIX d)
440 endif ()
443 add_library(freetype
444   ${PUBLIC_HEADERS}
445   ${PUBLIC_CONFIG_HEADERS}
446   ${PRIVATE_HEADERS}
447   ${BASE_SRCS}
450 set_target_properties(
451   freetype PROPERTIES
452     C_VISIBILITY_PRESET hidden)
454 target_compile_definitions(
455   freetype PRIVATE FT2_BUILD_LIBRARY)
457 if (WIN32)
458   target_compile_definitions(
459     freetype PRIVATE _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_WARNINGS)
460   if (BUILD_SHARED_LIBS)
461     target_compile_definitions(
462       freetype PRIVATE DLL_EXPORT)
463   endif ()
464 endif ()
466 if (BUILD_SHARED_LIBS)
467   set_target_properties(freetype PROPERTIES
468     VERSION ${LIBRARY_VERSION}
469     SOVERSION ${LIBRARY_SOVERSION})
470 endif ()
472 # Pick up ftconfig.h and ftoption.h generated above, first.
473 target_include_directories(
474   freetype
475     PUBLIC
476       $<INSTALL_INTERFACE:include/freetype2>
477       $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
478       $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
479     PRIVATE
480       ${CMAKE_CURRENT_BINARY_DIR}/include
481       ${CMAKE_CURRENT_SOURCE_DIR}/include
483       # Make <ftconfig.h> available for builds/unix/ftsystem.c.
484       ${CMAKE_CURRENT_BINARY_DIR}/include/freetype/config
488 if (BUILD_FRAMEWORK)
489   set_property(SOURCE ${PUBLIC_CONFIG_HEADERS}
490     PROPERTY MACOSX_PACKAGE_LOCATION Headers/config
491   )
492   set_target_properties(freetype PROPERTIES
493     FRAMEWORK TRUE
494     MACOSX_FRAMEWORK_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/builds/mac/freetype-Info.plist
495     PUBLIC_HEADER "${PUBLIC_HEADERS}"
496     XCODE_ATTRIBUTE_INSTALL_PATH "@rpath"
497   )
498 endif ()
501 set(PKGCONFIG_REQUIRES "")
502 set(PKGCONFIG_REQUIRES_PRIVATE "")
503 set(PKGCONFIG_LIBS "-L\${libdir} -lfreetype")
504 set(PKGCONFIG_LIBS_PRIVATE "")
506 if (ZLIB_FOUND)
507   target_link_libraries(freetype PRIVATE ${ZLIB_LIBRARIES})
508   target_include_directories(freetype PRIVATE ${ZLIB_INCLUDE_DIRS})
509   list(APPEND PKGCONFIG_REQUIRES_PRIVATE "zlib")
510 endif ()
511 if (BZIP2_FOUND)
512   target_link_libraries(freetype PRIVATE ${BZIP2_LIBRARIES})
513   target_include_directories(freetype PRIVATE ${BZIP2_INCLUDE_DIR}) # not BZIP2_INCLUDE_DIRS
514   if (PC_BZIP2_FOUND)
515     list(APPEND PKGCONFIG_REQUIRES_PRIVATE "bzip2")
516   else ()
517     list(APPEND PKGCONFIG_LIBS_PRIVATE "-lbz2")
518   endif ()
519 endif ()
520 if (PNG_FOUND)
521   target_link_libraries(freetype PRIVATE ${PNG_LIBRARIES})
522   target_compile_definitions(freetype PRIVATE ${PNG_DEFINITIONS})
523   target_include_directories(freetype PRIVATE ${PNG_INCLUDE_DIRS})
524   list(APPEND PKGCONFIG_REQUIRES_PRIVATE "libpng")
525 endif ()
526 if (HarfBuzz_FOUND)
527   target_link_libraries(freetype PRIVATE ${HarfBuzz_LIBRARY})
528   target_include_directories(freetype PRIVATE ${HarfBuzz_INCLUDE_DIRS})
529   list(APPEND PKGCONFIG_REQUIRES_PRIVATE "harfbuzz >= ${HARFBUZZ_MIN_VERSION}")
530 endif ()
531 if (BROTLIDEC_FOUND)
532   target_link_libraries(freetype PRIVATE ${BROTLIDEC_LIBRARIES})
533   target_compile_definitions(freetype PRIVATE ${BROTLIDEC_DEFINITIONS})
534   target_include_directories(freetype PRIVATE ${BROTLIDEC_INCLUDE_DIRS})
535   list(APPEND PKGCONFIG_REQUIRES_PRIVATE "libbrotlidec")
536 endif ()
539 # Installation
540 include(GNUInstallDirs)
542 if (NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL)
543   install(
544     # Note the trailing slash in the argument to `DIRECTORY'!
545     DIRECTORY ${PROJECT_SOURCE_DIR}/include/
546       DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/freetype2
547       COMPONENT headers
548       PATTERN "internal" EXCLUDE
549       PATTERN "ftconfig.h" EXCLUDE
550       PATTERN "ftoption.h" EXCLUDE)
551   install(
552     FILES ${PROJECT_BINARY_DIR}/include/freetype/config/ftconfig.h
553           ${PROJECT_BINARY_DIR}/include/freetype/config/ftoption.h
554       DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/freetype2/freetype/config
555       COMPONENT headers)
556 endif ()
558 if (NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL)
559   # Generate the pkg-config file
560   file(READ "${PROJECT_SOURCE_DIR}/builds/unix/freetype2.in" FREETYPE2_PC_IN)
562   string(REPLACE ";" ", " PKGCONFIG_REQUIRES_PRIVATE "${PKGCONFIG_REQUIRES_PRIVATE}")
564   string(REPLACE "%prefix%" ${CMAKE_INSTALL_PREFIX}
565           FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
566   string(REPLACE "%exec_prefix%" "\${prefix}"
567           FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
568   string(REPLACE "%libdir%" "\${prefix}/${CMAKE_INSTALL_LIBDIR}"
569           FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
570   string(REPLACE "%includedir%" "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}"
571           FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
572   string(REPLACE "%ft_version%" "${LIBTOOL_CURRENT}.${LIBTOOL_REVISION}.${LIBTOOL_AGE}"
573           FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
575   if (BUILD_SHARED_LIBS)
576     string(REPLACE "%PKGCONFIG_REQUIRES%" "${PKGCONFIG_REQUIRES}"
577             FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
578     string(REPLACE "%PKGCONFIG_REQUIRES_PRIVATE%" "${PKGCONFIG_REQUIRES_PRIVATE}"
579             FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
580     string(REPLACE "%PKGCONFIG_LIBS%" "${PKGCONFIG_LIBS}"
581             FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
582     string(REPLACE "%PKGCONFIG_LIBS_PRIVATE%" "${PKGCONFIG_LIBS_PRIVATE}"
583             FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
584   else ()
585     string(REPLACE "%PKGCONFIG_REQUIRES%" "${PKGCONFIG_REQUIRES} ${PKGCONFIG_REQUIRES_PRIVATE}"
586             FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
587     string(REPLACE "%PKGCONFIG_REQUIRES_PRIVATE%" ""
588             FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
589     string(REPLACE "%PKGCONFIG_LIBS%" "${PKGCONFIG_LIBS} ${PKGCONFIG_LIBS_PRIVATE}"
590             FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
591     string(REPLACE "%PKGCONFIG_LIBS_PRIVATE%" ""
592             FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
593   endif ()
595   set(FREETYPE2_PC_IN_NAME "${PROJECT_BINARY_DIR}/freetype2.pc")
596   if (EXISTS "${FREETYPE2_PC_IN_NAME}")
597     file(READ "${FREETYPE2_PC_IN_NAME}" ORIGINAL_FREETYPE2_PC_IN)
598   else ()
599     set(ORIGINAL_FREETYPE2_PC_IN "")
600   endif ()
601   if (NOT (ORIGINAL_FREETYPE2_PC_IN STREQUAL FREETYPE2_PC_IN))
602     file(WRITE "${FREETYPE2_PC_IN_NAME}" ${FREETYPE2_PC_IN})
603   endif ()
605   install(
606     FILES ${PROJECT_BINARY_DIR}/freetype2.pc
607     DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
608     COMPONENT pkgconfig)
610   include(CMakePackageConfigHelpers)
611   write_basic_package_version_file(
612     ${PROJECT_BINARY_DIR}/freetype-config-version.cmake
613     VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
614     COMPATIBILITY SameMajorVersion)
616   install(
617     TARGETS freetype
618       EXPORT freetype-targets
619       LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
620       ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
621       RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
622       FRAMEWORK DESTINATION Library/Frameworks
623       COMPONENT libraries)
624   install(
625     EXPORT freetype-targets
626       DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/freetype
627       FILE freetype-config.cmake
628       COMPONENT headers)
629   install(
630     FILES ${PROJECT_BINARY_DIR}/freetype-config-version.cmake
631     DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/freetype
632     COMPONENT headers)
633 endif ()
636 # Packaging
637 set(CPACK_PACKAGE_NAME ${CMAKE_PROJECT_NAME})
638 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The FreeType font rendering library.")
639 set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
640 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.TXT")
642 set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
643 set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
644 set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH})
645 set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
647 if (WIN32)
648   set(CPACK_GENERATOR ZIP)
649 else ()
650   set(CPACK_GENERATOR TGZ)
651 endif ()
653 set(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "Libraries")
654 set(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C/C++ Headers")
655 set(CPACK_COMPONENT_LIBRARIES_DESCRIPTION
656   "Library used to build programs which use FreeType")
657 set(CPACK_COMPONENT_HEADERS_DESCRIPTION
658   "C/C++ header files for use with FreeType")
659 set(CPACK_COMPONENT_HEADERS_DEPENDS libraries)
660 set(CPACK_COMPONENT_LIBRARIES_GROUP "Development")
661 set(CPACK_COMPONENT_HEADERS_GROUP "Development")
663 include(CPack)