1# CMakeLists.txt 2# 3# Copyright (C) 2013-2021 by 4# David Turner, Robert Wilhelm, and Werner Lemberg. 5# 6# Written originally by John Cary <cary@txcorp.com> 7# 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# 14# 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 18# 19# https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html 20# 21# for information about debug or release builds, for example 22# 23# cmake -B build -D CMAKE_BUILD_TYPE=Release 24# 25# 26# For a dynamic library, use 27# 28# cmake -B build -D BUILD_SHARED_LIBS=true -D CMAKE_BUILD_TYPE=Release 29# 30# For a framework on OS X, use 31# 32# cmake -E chdir build cmake -G Xcode -D BUILD_FRAMEWORK:BOOL=true .. 33# 34# For an iOS static library, use 35# 36# cmake -E chdir build cmake -G Xcode -D IOS_PLATFORM=OS .. 37# 38# or 39# 40# cmake -E chdir build cmake -G Xcode -D IOS_PLATFORM=SIMULATOR .. 41# 42# or 43# 44# cmake -E chdir build cmake -G Xcode -D IOS_PLATFORM=SIMULATOR64 .. 45# 46# 47# Finally, build the project with 48# 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 58# 59# Please refer to the cmake manual for further options, in particular, how 60# to modify compilation and linking parameters. 61# 62# Some notes. 63# 64# - `cmake' creates configuration files in 65# 66# <build-directory>/include/freetype/config 67# 68# which should be further modified if necessary. 69# 70# - You can use `cmake' directly on a freshly cloned FreeType git 71# repository. 72# 73# - `CMakeLists.txt' is provided as-is since it is normally not used by the 74# developer team. 75# 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: 81# 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 [...] 87# 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: 91# 92# cmake -B build -D FT_DISABLE_ZLIB=TRUE \ 93# -D FT_DISABLE_BZIP2=TRUE \ 94# -D FT_DISABLE_PNG=TRUE \ 95# -D FT_DISABLE_HARFBUZZ=TRUE \ 96# -D FT_DISABLE_BROTLI=TRUE [...] 97# 98# - NOTE: If a package is set as DISABLED, it cannot be set as REQUIRED 99# without unsetting the DISABLED value first. For example, if 100# `FT_DISABLE_HARFBUZZ=TRUE' has been set (Cache is present), you need to 101# call `FT_DISABLE_HARFBUZZ=FALSE' before calling 102# `FT_REQUIRE_HARFBUZZ=TRUE'. 103# 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). 108 109# 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) 113 114if (NOT CMAKE_VERSION VERSION_LESS 3.3) 115 # Allow symbol visibility settings also on static libraries. CMake < 3.3 116 # only sets the property on a shared library build. 117 cmake_policy(SET CMP0063 NEW) 118 119 # Support new IN_LIST if() operator. 120 cmake_policy(SET CMP0057 NEW) 121endif () 122 123include(CheckIncludeFile) 124include(CMakeDependentOption) 125 126# 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" 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 () 148 149 # iOS only uses static libraries 150 set(BUILD_SHARED_LIBS OFF) 151 152 set(CMAKE_TOOLCHAIN_FILE 153 ${CMAKE_SOURCE_DIR}/builds/cmake/iOS.cmake) 154 endif () 155else () 156 if (DEFINED IOS_PLATFORM) 157 message(FATAL_ERROR "IOS_PLATFORM is not supported on this platform") 158 endif () 159endif () 160 161 162project(freetype C) 163 164set(VERSION_MAJOR "2") 165set(VERSION_MINOR "11") 166set(VERSION_PATCH "1") 167 168# 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}") 186 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. 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) 218 219 220# Disallow in-source builds 221if ("${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") 230endif () 231 232 233# Add local cmake modules 234list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/builds/cmake) 235 236 237if (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_32_64_BIT)") 243 set(BUILD_SHARED_LIBS ON) 244endif () 245 246 247# Find dependencies 248if (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 () 255endif () 256 257if (NOT FT_DISABLE_PNG) 258 if (FT_REQUIRE_PNG) 259 find_package(PNG REQUIRED) 260 else () 261 find_package(PNG) 262 endif () 263endif () 264 265if (NOT FT_DISABLE_ZLIB) 266 if (FT_REQUIRE_ZLIB) 267 find_package(ZLIB REQUIRED) 268 else () 269 find_package(ZLIB) 270 endif () 271endif () 272 273if (NOT FT_DISABLE_BZIP2) 274 if (FT_REQUIRE_BZIP2) 275 find_package(BZip2 REQUIRED) 276 else () 277 find_package(BZip2) 278 endif () 279endif () 280 281if (NOT FT_DISABLE_BROTLI) 282 if (FT_REQUIRE_BROTLI) 283 find_package(BrotliDec REQUIRED) 284 else () 285 find_package(BrotliDec) 286 endif () 287endif () 288 289# Create the configuration file 290if (UNIX) 291 check_include_file("unistd.h" HAVE_UNISTD_H) 292 check_include_file("fcntl.h" HAVE_FCNTL_H) 293 294 file(READ "${PROJECT_SOURCE_DIR}/builds/unix/ftconfig.h.in" 295 FTCONFIG_H) 296 if (HAVE_UNISTD_H) 297 string(REGEX REPLACE 298 "#undef +(HAVE_UNISTD_H)" "#define \\1 1" 299 FTCONFIG_H "${FTCONFIG_H}") 300 endif () 301 if (HAVE_FCNTL_H) 302 string(REGEX REPLACE 303 "#undef +(HAVE_FCNTL_H)" "#define \\1 1" 304 FTCONFIG_H "${FTCONFIG_H}") 305 endif () 306else () 307 file(READ "${PROJECT_SOURCE_DIR}/include/freetype/config/ftconfig.h" 308 FTCONFIG_H) 309endif () 310 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 () 320 321 322# Create the options file 323file(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 () 345if (BROTLIDEC_FOUND) 346 string(REGEX REPLACE 347 "/\\* +(#define +FT_CONFIG_OPTION_USE_BROTLI) +\\*/" "\\1" 348 FTOPTION_H "${FTOPTION_H}") 349endif () 350 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 () 360 361 362file(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") 365 366 367set(BASE_SRCS 368 src/autofit/autofit.c 369 src/base/ftbase.c 370 src/base/ftbbox.c 371 src/base/ftbdf.c 372 src/base/ftbitmap.c 373 src/base/ftcid.c 374 src/base/ftfstype.c 375 src/base/ftgasp.c 376 src/base/ftglyph.c 377 src/base/ftgxval.c 378 src/base/ftinit.c 379 src/base/ftmm.c 380 src/base/ftotval.c 381 src/base/ftpatent.c 382 src/base/ftpfr.c 383 src/base/ftstroke.c 384 src/base/ftsynth.c 385 src/base/fttype1.c 386 src/base/ftwinfnt.c 387 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 398 src/psnames/psnames.c 399 src/raster/raster.c 400 src/sdf/sdf.c 401 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 409if (UNIX) 410 list(APPEND BASE_SRCS "builds/unix/ftsystem.c") 411elseif (WIN32) 412 list(APPEND BASE_SRCS "builds/windows/ftsystem.c") 413else () 414 list(APPEND BASE_SRCS "src/base/ftsystem.c") 415endif () 416 417if (WIN32) 418 enable_language(RC) 419 list(APPEND BASE_SRCS builds/windows/ftdebug.c 420 src/base/ftver.rc) 421elseif (WINCE) 422 list(APPEND BASE_SRCS builds/wince/ftdebug.c) 423else () 424 list(APPEND BASE_SRCS src/base/ftdebug.c) 425endif () 426 427if (BUILD_FRAMEWORK) 428 list(APPEND BASE_SRCS builds/mac/freetype-Info.plist) 429endif () 430 431 432if (NOT DISABLE_FORCE_DEBUG_POSTFIX) 433 set(CMAKE_DEBUG_POSTFIX d) 434endif () 435 436 437add_library(freetype 438 ${PUBLIC_HEADERS} 439 ${PUBLIC_CONFIG_HEADERS} 440 ${PRIVATE_HEADERS} 441 ${BASE_SRCS} 442) 443 444set_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) 454 if (BUILD_SHARED_LIBS) 455 target_compile_definitions( 456 freetype PRIVATE DLL_EXPORT) 457 endif () 458endif () 459 460if (BUILD_SHARED_LIBS) 461 set_target_properties(freetype PROPERTIES 462 VERSION ${LIBRARY_VERSION} 463 SOVERSION ${LIBRARY_SOVERSION}) 464endif () 465 466# Pick up ftconfig.h and ftoption.h generated above, first. 467target_include_directories( 468 freetype 469 PUBLIC 470 $<INSTALL_INTERFACE:include/freetype2> 471 $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include> 472 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> 473 PRIVATE 474 ${CMAKE_CURRENT_BINARY_DIR}/include 475 ${CMAKE_CURRENT_SOURCE_DIR}/include 476 477 # Make <ftconfig.h> available for builds/unix/ftsystem.c. 478 ${CMAKE_CURRENT_BINARY_DIR}/include/freetype/config 479) 480 481 482if (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 () 493 494 495set(PKG_CONFIG_REQUIRED_PRIVATE "") 496set(PKG_CONFIG_LIBS_PRIVATE "") 497 498if (ZLIB_FOUND) 499 target_link_libraries(freetype PRIVATE ${ZLIB_LIBRARIES}) 500 target_include_directories(freetype PRIVATE ${ZLIB_INCLUDE_DIRS}) 501 list(APPEND PKG_CONFIG_REQUIRED_PRIVATE "zlib") 502endif () 503if (BZIP2_FOUND) 504 target_link_libraries(freetype PRIVATE ${BZIP2_LIBRARIES}) 505 target_include_directories(freetype PRIVATE ${BZIP2_INCLUDE_DIR}) # not BZIP2_INCLUDE_DIRS 506 list(APPEND PKG_CONFIG_LIBS_PRIVATE "-lbz2") 507endif () 508if (PNG_FOUND) 509 target_link_libraries(freetype PRIVATE ${PNG_LIBRARIES}) 510 target_compile_definitions(freetype PRIVATE ${PNG_DEFINITIONS}) 511 target_include_directories(freetype PRIVATE ${PNG_INCLUDE_DIRS}) 512 list(APPEND PKG_CONFIG_REQUIRED_PRIVATE "libpng") 513endif () 514if (HarfBuzz_FOUND) 515 target_link_libraries(freetype PRIVATE ${HarfBuzz_LIBRARY}) 516 target_include_directories(freetype PRIVATE ${HarfBuzz_INCLUDE_DIRS}) 517 list(APPEND PKG_CONFIG_REQUIRED_PRIVATE "harfbuzz >= ${HARFBUZZ_MIN_VERSION}") 518endif () 519if (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 () 525 526 527# Installation 528include(GNUInstallDirs) 529 530if (NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL) 531 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) 544endif () 545 546if (NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL) 547 # Generate the pkg-config file 548 file(READ "${PROJECT_SOURCE_DIR}/builds/unix/freetype2.in" FREETYPE2_PC_IN) 549 550 string(REPLACE ";" ", " PKG_CONFIG_REQUIRED_PRIVATE "${PKG_CONFIG_REQUIRED_PRIVATE}") 551 552 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}) 566 567 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 "") 572 endif () 573 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) 581 582 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 588 install( 589 TARGETS freetype 590 EXPORT freetype-targets 591 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} 592 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} 593 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} 594 FRAMEWORK DESTINATION Library/Frameworks 595 COMPONENT libraries) 596 install( 597 EXPORT freetype-targets 598 DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/freetype 599 FILE freetype-config.cmake 600 COMPONENT headers) 601 install( 602 FILES ${PROJECT_BINARY_DIR}/freetype-config-version.cmake 603 DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/freetype 604 COMPONENT headers) 605endif () 606 607 608# Packaging 609set(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") 612set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.TXT") 613 614set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR}) 615set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR}) 616set(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) 621else () 622 set(CPACK_GENERATOR TGZ) 623endif () 624 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 635include(CPack) 636