🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

663 lines
20 KiB

  1. # CMakeLists.txt
  2. #
  3. # Copyright (C) 2013-2022 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. # To minimize the number of cmake_policy() workarounds,
  109. # CMake >= 3 is requested.
  110. cmake_minimum_required(VERSION 3.0)
  111. if (NOT CMAKE_VERSION VERSION_LESS 3.3)
  112. # Allow symbol visibility settings also on static libraries. CMake < 3.3
  113. # only sets the property on a shared library build.
  114. cmake_policy(SET CMP0063 NEW)
  115. # Support new IN_LIST if() operator.
  116. cmake_policy(SET CMP0057 NEW)
  117. endif ()
  118. include(CheckIncludeFile)
  119. include(CMakeDependentOption)
  120. include(FindPkgConfig)
  121. # CMAKE_TOOLCHAIN_FILE must be set before `project' is called, which
  122. # configures the base build environment and references the toolchain file
  123. if (APPLE)
  124. if (DEFINED IOS_PLATFORM)
  125. if (NOT "${IOS_PLATFORM}" STREQUAL "OS"
  126. AND NOT "${IOS_PLATFORM}" STREQUAL "SIMULATOR"
  127. AND NOT "${IOS_PLATFORM}" STREQUAL "SIMULATOR64")
  128. message(FATAL_ERROR
  129. "IOS_PLATFORM must be set to either OS, SIMULATOR, or SIMULATOR64")
  130. endif ()
  131. if (NOT "${CMAKE_GENERATOR}" STREQUAL "Xcode")
  132. message(AUTHOR_WARNING
  133. "You should use Xcode generator with IOS_PLATFORM enabled to get Universal builds.")
  134. endif ()
  135. if (BUILD_SHARED_LIBS)
  136. message(FATAL_ERROR
  137. "BUILD_SHARED_LIBS can not be on with IOS_PLATFORM enabled")
  138. endif ()
  139. if (BUILD_FRAMEWORK)
  140. message(FATAL_ERROR
  141. "BUILD_FRAMEWORK can not be on with IOS_PLATFORM enabled")
  142. endif ()
  143. # iOS only uses static libraries
  144. set(BUILD_SHARED_LIBS OFF)
  145. set(CMAKE_TOOLCHAIN_FILE
  146. ${CMAKE_SOURCE_DIR}/builds/cmake/iOS.cmake)
  147. endif ()
  148. else ()
  149. if (DEFINED IOS_PLATFORM)
  150. message(FATAL_ERROR "IOS_PLATFORM is not supported on this platform")
  151. endif ()
  152. endif ()
  153. project(freetype C)
  154. set(VERSION_MAJOR "2")
  155. set(VERSION_MINOR "12")
  156. set(VERSION_PATCH "1")
  157. # Generate LIBRARY_VERSION and LIBRARY_SOVERSION.
  158. set(LIBTOOL_REGEX "version_info='([0-9]+):([0-9]+):([0-9]+)'")
  159. file(STRINGS "${PROJECT_SOURCE_DIR}/builds/unix/configure.raw"
  160. VERSION_INFO
  161. REGEX ${LIBTOOL_REGEX})
  162. string(REGEX REPLACE
  163. ${LIBTOOL_REGEX} "\\1"
  164. LIBTOOL_CURRENT "${VERSION_INFO}")
  165. string(REGEX REPLACE
  166. ${LIBTOOL_REGEX} "\\2"
  167. LIBTOOL_REVISION "${VERSION_INFO}")
  168. string(REGEX REPLACE
  169. ${LIBTOOL_REGEX} "\\3"
  170. LIBTOOL_AGE "${VERSION_INFO}")
  171. # This is what libtool does internally on Unix platforms.
  172. math(EXPR LIBRARY_SOVERSION "${LIBTOOL_CURRENT} - ${LIBTOOL_AGE}")
  173. set(LIBRARY_VERSION "${LIBRARY_SOVERSION}.${LIBTOOL_AGE}.${LIBTOOL_REVISION}")
  174. # External dependency library detection is automatic. See the notes at the
  175. # top of this file, for how to force or disable dependencies completely.
  176. option(FT_DISABLE_ZLIB
  177. "Disable use of system zlib and use internal zlib library instead." OFF)
  178. cmake_dependent_option(FT_REQUIRE_ZLIB
  179. "Require system zlib instead of internal zlib library." OFF
  180. "NOT FT_DISABLE_ZLIB" OFF)
  181. option(FT_DISABLE_BZIP2
  182. "Disable support of bzip2 compressed fonts." OFF)
  183. cmake_dependent_option(FT_REQUIRE_BZIP2
  184. "Require support of bzip2 compressed fonts." OFF
  185. "NOT FT_DISABLE_BZIP2" OFF)
  186. option(FT_DISABLE_PNG
  187. "Disable support of PNG compressed OpenType embedded bitmaps." OFF)
  188. cmake_dependent_option(FT_REQUIRE_PNG
  189. "Require support of PNG compressed OpenType embedded bitmaps." OFF
  190. "NOT FT_DISABLE_PNG" OFF)
  191. option(FT_DISABLE_HARFBUZZ
  192. "Disable HarfBuzz (used for improving auto-hinting of OpenType fonts)." OFF)
  193. cmake_dependent_option(FT_REQUIRE_HARFBUZZ
  194. "Require HarfBuzz for improving auto-hinting of OpenType fonts." OFF
  195. "NOT FT_DISABLE_HARFBUZZ" OFF)
  196. option(FT_DISABLE_BROTLI
  197. "Disable support of compressed WOFF2 fonts." OFF)
  198. cmake_dependent_option(FT_REQUIRE_BROTLI
  199. "Require support of compressed WOFF2 fonts." OFF
  200. "NOT FT_DISABLE_BROTLI" OFF)
  201. # Disallow in-source builds
  202. if ("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
  203. message(FATAL_ERROR
  204. "In-source builds are not permitted! Make a separate folder for"
  205. " building, e.g.,\n"
  206. " cmake -E make_directory build\n"
  207. " cmake -E chdir build cmake ..\n"
  208. "Before that, remove the files created by this failed run with\n"
  209. " cmake -E remove CMakeCache.txt\n"
  210. " cmake -E remove_directory CMakeFiles")
  211. endif ()
  212. # Add local cmake modules
  213. list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/builds/cmake)
  214. if (BUILD_FRAMEWORK)
  215. if (NOT "${CMAKE_GENERATOR}" STREQUAL "Xcode")
  216. message(FATAL_ERROR
  217. "You should use Xcode generator with BUILD_FRAMEWORK enabled")
  218. endif ()
  219. set(CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD)")
  220. set(BUILD_SHARED_LIBS ON)
  221. endif ()
  222. # Find dependencies
  223. if (NOT FT_DISABLE_HARFBUZZ)
  224. set(HARFBUZZ_MIN_VERSION "2.0.0")
  225. if (FT_REQUIRE_HARFBUZZ)
  226. find_package(HarfBuzz ${HARFBUZZ_MIN_VERSION} REQUIRED)
  227. else ()
  228. find_package(HarfBuzz ${HARFBUZZ_MIN_VERSION})
  229. endif ()
  230. endif ()
  231. if (NOT FT_DISABLE_PNG)
  232. if (FT_REQUIRE_PNG)
  233. find_package(PNG REQUIRED)
  234. else ()
  235. find_package(PNG)
  236. endif ()
  237. endif ()
  238. if (NOT FT_DISABLE_ZLIB)
  239. if (FT_REQUIRE_ZLIB)
  240. find_package(ZLIB REQUIRED)
  241. else ()
  242. find_package(ZLIB)
  243. endif ()
  244. endif ()
  245. if (NOT FT_DISABLE_BZIP2)
  246. # Genuine BZip2 does not provide bzip2.pc, but some platforms have it.
  247. # For better dependency in freetype2.pc, bzip2.pc is searched
  248. # regardless of the availability of libbz2. If bzip2.pc is found,
  249. # Requires.private is used instead of Libs.private.
  250. if (FT_REQUIRE_BZIP2)
  251. find_package(BZip2 REQUIRED)
  252. else ()
  253. find_package(BZip2)
  254. endif ()
  255. pkg_check_modules(PC_BZIP2 bzip2)
  256. endif ()
  257. if (NOT FT_DISABLE_BROTLI)
  258. if (FT_REQUIRE_BROTLI)
  259. find_package(BrotliDec REQUIRED)
  260. else ()
  261. find_package(BrotliDec)
  262. endif ()
  263. endif ()
  264. # Create the configuration file
  265. if (UNIX)
  266. check_include_file("unistd.h" HAVE_UNISTD_H)
  267. check_include_file("fcntl.h" HAVE_FCNTL_H)
  268. file(READ "${PROJECT_SOURCE_DIR}/builds/unix/ftconfig.h.in"
  269. FTCONFIG_H)
  270. if (HAVE_UNISTD_H)
  271. string(REGEX REPLACE
  272. "#undef +(HAVE_UNISTD_H)" "#define \\1 1"
  273. FTCONFIG_H "${FTCONFIG_H}")
  274. endif ()
  275. if (HAVE_FCNTL_H)
  276. string(REGEX REPLACE
  277. "#undef +(HAVE_FCNTL_H)" "#define \\1 1"
  278. FTCONFIG_H "${FTCONFIG_H}")
  279. endif ()
  280. else ()
  281. file(READ "${PROJECT_SOURCE_DIR}/include/freetype/config/ftconfig.h"
  282. FTCONFIG_H)
  283. endif ()
  284. set(FTCONFIG_H_NAME "${PROJECT_BINARY_DIR}/include/freetype/config/ftconfig.h")
  285. if (EXISTS "${FTCONFIG_H_NAME}")
  286. file(READ "${FTCONFIG_H_NAME}" ORIGINAL_FTCONFIG_H)
  287. else ()
  288. set(ORIGINAL_FTCONFIG_H "")
  289. endif ()
  290. if (NOT (ORIGINAL_FTCONFIG_H STREQUAL FTCONFIG_H))
  291. file(WRITE "${FTCONFIG_H_NAME}" "${FTCONFIG_H}")
  292. endif ()
  293. # Create the options file
  294. file(READ "${PROJECT_SOURCE_DIR}/include/freetype/config/ftoption.h"
  295. FTOPTION_H)
  296. if (ZLIB_FOUND)
  297. string(REGEX REPLACE
  298. "/\\* +(#define +FT_CONFIG_OPTION_SYSTEM_ZLIB) +\\*/" "\\1"
  299. FTOPTION_H "${FTOPTION_H}")
  300. endif ()
  301. if (BZIP2_FOUND)
  302. string(REGEX REPLACE
  303. "/\\* +(#define +FT_CONFIG_OPTION_USE_BZIP2) +\\*/" "\\1"
  304. FTOPTION_H "${FTOPTION_H}")
  305. endif ()
  306. if (PNG_FOUND)
  307. string(REGEX REPLACE
  308. "/\\* +(#define +FT_CONFIG_OPTION_USE_PNG) +\\*/" "\\1"
  309. FTOPTION_H "${FTOPTION_H}")
  310. endif ()
  311. if (HARFBUZZ_FOUND)
  312. string(REGEX REPLACE
  313. "/\\* +(#define +FT_CONFIG_OPTION_USE_HARFBUZZ) +\\*/" "\\1"
  314. FTOPTION_H "${FTOPTION_H}")
  315. endif ()
  316. if (BROTLIDEC_FOUND)
  317. string(REGEX REPLACE
  318. "/\\* +(#define +FT_CONFIG_OPTION_USE_BROTLI) +\\*/" "\\1"
  319. FTOPTION_H "${FTOPTION_H}")
  320. endif ()
  321. set(FTOPTION_H_NAME "${PROJECT_BINARY_DIR}/include/freetype/config/ftoption.h")
  322. if (EXISTS "${FTOPTION_H_NAME}")
  323. file(READ "${FTOPTION_H_NAME}" ORIGINAL_FTOPTION_H)
  324. else ()
  325. set(ORIGINAL_FTOPTION_H "")
  326. endif ()
  327. if (NOT (ORIGINAL_FTOPTION_H STREQUAL FTOPTION_H))
  328. file(WRITE "${FTOPTION_H_NAME}" "${FTOPTION_H}")
  329. endif ()
  330. file(GLOB PUBLIC_HEADERS "include/ft2build.h" "include/freetype/*.h")
  331. file(GLOB PUBLIC_CONFIG_HEADERS "include/freetype/config/*.h")
  332. file(GLOB PRIVATE_HEADERS "include/freetype/internal/*.h")
  333. set(BASE_SRCS
  334. src/autofit/autofit.c
  335. src/base/ftbase.c
  336. src/base/ftbbox.c
  337. src/base/ftbdf.c
  338. src/base/ftbitmap.c
  339. src/base/ftcid.c
  340. src/base/ftfstype.c
  341. src/base/ftgasp.c
  342. src/base/ftglyph.c
  343. src/base/ftgxval.c
  344. src/base/ftinit.c
  345. src/base/ftmm.c
  346. src/base/ftotval.c
  347. src/base/ftpatent.c
  348. src/base/ftpfr.c
  349. src/base/ftstroke.c
  350. src/base/ftsynth.c
  351. src/base/fttype1.c
  352. src/base/ftwinfnt.c
  353. src/bdf/bdf.c
  354. src/bzip2/ftbzip2.c
  355. src/cache/ftcache.c
  356. src/cff/cff.c
  357. src/cid/type1cid.c
  358. src/gzip/ftgzip.c
  359. src/lzw/ftlzw.c
  360. src/pcf/pcf.c
  361. src/pfr/pfr.c
  362. src/psaux/psaux.c
  363. src/pshinter/pshinter.c
  364. src/psnames/psnames.c
  365. src/raster/raster.c
  366. src/sdf/sdf.c
  367. src/sfnt/sfnt.c
  368. src/smooth/smooth.c
  369. src/svg/svg.c
  370. src/truetype/truetype.c
  371. src/type1/type1.c
  372. src/type42/type42.c
  373. src/winfonts/winfnt.c
  374. )
  375. if (UNIX)
  376. list(APPEND BASE_SRCS "builds/unix/ftsystem.c")
  377. elseif (WIN32)
  378. list(APPEND BASE_SRCS "builds/windows/ftsystem.c")
  379. else ()
  380. list(APPEND BASE_SRCS "src/base/ftsystem.c")
  381. endif ()
  382. if (WIN32)
  383. enable_language(RC)
  384. list(APPEND BASE_SRCS builds/windows/ftdebug.c
  385. src/base/ftver.rc)
  386. elseif (WINCE)
  387. list(APPEND BASE_SRCS builds/wince/ftdebug.c)
  388. else ()
  389. list(APPEND BASE_SRCS src/base/ftdebug.c)
  390. endif ()
  391. if (BUILD_FRAMEWORK)
  392. list(APPEND BASE_SRCS builds/mac/freetype-Info.plist)
  393. endif ()
  394. if (NOT DISABLE_FORCE_DEBUG_POSTFIX)
  395. set(CMAKE_DEBUG_POSTFIX d)
  396. endif ()
  397. add_library(freetype
  398. ${PUBLIC_HEADERS}
  399. ${PUBLIC_CONFIG_HEADERS}
  400. ${PRIVATE_HEADERS}
  401. ${BASE_SRCS}
  402. )
  403. set_target_properties(
  404. freetype PROPERTIES
  405. C_VISIBILITY_PRESET hidden)
  406. target_compile_definitions(
  407. freetype PRIVATE FT2_BUILD_LIBRARY)
  408. if (WIN32)
  409. target_compile_definitions(
  410. freetype PRIVATE _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_WARNINGS)
  411. if (BUILD_SHARED_LIBS)
  412. target_compile_definitions(
  413. freetype PRIVATE DLL_EXPORT)
  414. endif ()
  415. endif ()
  416. if (BUILD_SHARED_LIBS)
  417. set_target_properties(freetype PROPERTIES
  418. VERSION ${LIBRARY_VERSION}
  419. SOVERSION ${LIBRARY_SOVERSION})
  420. endif ()
  421. # Pick up ftconfig.h and ftoption.h generated above, first.
  422. target_include_directories(
  423. freetype
  424. PUBLIC
  425. $<INSTALL_INTERFACE:include/freetype2>
  426. $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
  427. $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
  428. PRIVATE
  429. ${CMAKE_CURRENT_BINARY_DIR}/include
  430. ${CMAKE_CURRENT_SOURCE_DIR}/include
  431. # Make <ftconfig.h> available for builds/unix/ftsystem.c.
  432. ${CMAKE_CURRENT_BINARY_DIR}/include/freetype/config
  433. )
  434. if (BUILD_FRAMEWORK)
  435. set_property(SOURCE ${PUBLIC_CONFIG_HEADERS}
  436. PROPERTY MACOSX_PACKAGE_LOCATION Headers/config
  437. )
  438. set_target_properties(freetype PROPERTIES
  439. FRAMEWORK TRUE
  440. MACOSX_FRAMEWORK_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/builds/mac/freetype-Info.plist
  441. PUBLIC_HEADER "${PUBLIC_HEADERS}"
  442. XCODE_ATTRIBUTE_INSTALL_PATH "@rpath"
  443. )
  444. endif ()
  445. set(PKGCONFIG_REQUIRES "")
  446. set(PKGCONFIG_REQUIRES_PRIVATE "")
  447. set(PKGCONFIG_LIBS "-L\${libdir} -lfreetype")
  448. set(PKGCONFIG_LIBS_PRIVATE "")
  449. if (ZLIB_FOUND)
  450. target_link_libraries(freetype PRIVATE ${ZLIB_LIBRARIES})
  451. target_include_directories(freetype PRIVATE ${ZLIB_INCLUDE_DIRS})
  452. list(APPEND PKGCONFIG_REQUIRES_PRIVATE "zlib")
  453. endif ()
  454. if (BZIP2_FOUND)
  455. target_link_libraries(freetype PRIVATE ${BZIP2_LIBRARIES})
  456. target_include_directories(freetype PRIVATE ${BZIP2_INCLUDE_DIR}) # not BZIP2_INCLUDE_DIRS
  457. if (PC_BZIP2_FOUND)
  458. list(APPEND PKGCONFIG_REQUIRES_PRIVATE "bzip2")
  459. else ()
  460. list(APPEND PKGCONFIG_LIBS_PRIVATE "-lbz2")
  461. endif ()
  462. endif ()
  463. if (PNG_FOUND)
  464. target_link_libraries(freetype PRIVATE ${PNG_LIBRARIES})
  465. target_compile_definitions(freetype PRIVATE ${PNG_DEFINITIONS})
  466. target_include_directories(freetype PRIVATE ${PNG_INCLUDE_DIRS})
  467. list(APPEND PKGCONFIG_REQUIRES_PRIVATE "libpng")
  468. endif ()
  469. if (HarfBuzz_FOUND)
  470. target_link_libraries(freetype PRIVATE ${HarfBuzz_LIBRARY})
  471. target_include_directories(freetype PRIVATE ${HarfBuzz_INCLUDE_DIRS})
  472. list(APPEND PKGCONFIG_REQUIRES_PRIVATE "harfbuzz >= ${HARFBUZZ_MIN_VERSION}")
  473. endif ()
  474. if (BROTLIDEC_FOUND)
  475. target_link_libraries(freetype PRIVATE ${BROTLIDEC_LIBRARIES})
  476. target_compile_definitions(freetype PRIVATE ${BROTLIDEC_DEFINITIONS})
  477. target_include_directories(freetype PRIVATE ${BROTLIDEC_INCLUDE_DIRS})
  478. list(APPEND PKGCONFIG_REQUIRES_PRIVATE "libbrotlidec")
  479. endif ()
  480. # Installation
  481. include(GNUInstallDirs)
  482. if (NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL)
  483. install(
  484. # Note the trailing slash in the argument to `DIRECTORY'!
  485. DIRECTORY ${PROJECT_SOURCE_DIR}/include/
  486. DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/freetype2
  487. COMPONENT headers
  488. PATTERN "internal" EXCLUDE
  489. PATTERN "ftconfig.h" EXCLUDE
  490. PATTERN "ftoption.h" EXCLUDE)
  491. install(
  492. FILES ${PROJECT_BINARY_DIR}/include/freetype/config/ftconfig.h
  493. ${PROJECT_BINARY_DIR}/include/freetype/config/ftoption.h
  494. DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/freetype2/freetype/config
  495. COMPONENT headers)
  496. endif ()
  497. if (NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL)
  498. # Generate the pkg-config file
  499. file(READ "${PROJECT_SOURCE_DIR}/builds/unix/freetype2.in" FREETYPE2_PC_IN)
  500. string(REPLACE ";" ", " PKGCONFIG_REQUIRES_PRIVATE "${PKGCONFIG_REQUIRES_PRIVATE}")
  501. string(REPLACE "%prefix%" ${CMAKE_INSTALL_PREFIX}
  502. FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
  503. string(REPLACE "%exec_prefix%" "\${prefix}"
  504. FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
  505. string(REPLACE "%libdir%" "\${prefix}/${CMAKE_INSTALL_LIBDIR}"
  506. FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
  507. string(REPLACE "%includedir%" "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}"
  508. FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
  509. string(REPLACE "%ft_version%" "${LIBTOOL_CURRENT}.${LIBTOOL_REVISION}.${LIBTOOL_AGE}"
  510. FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
  511. if (BUILD_SHARED_LIBS)
  512. string(REPLACE "%PKGCONFIG_REQUIRES%" "${PKGCONFIG_REQUIRES}"
  513. FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
  514. string(REPLACE "%PKGCONFIG_REQUIRES_PRIVATE%" "${PKGCONFIG_REQUIRES_PRIVATE}"
  515. FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
  516. string(REPLACE "%PKGCONFIG_LIBS%" "${PKGCONFIG_LIBS}"
  517. FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
  518. string(REPLACE "%PKGCONFIG_LIBS_PRIVATE%" "${PKGCONFIG_LIBS_PRIVATE}"
  519. FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
  520. else ()
  521. string(REPLACE "%PKGCONFIG_REQUIRES%" "${PKGCONFIG_REQUIRES} ${PKGCONFIG_REQUIRES_PRIVATE}"
  522. FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
  523. string(REPLACE "%PKGCONFIG_REQUIRES_PRIVATE%" ""
  524. FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
  525. string(REPLACE "%PKGCONFIG_LIBS%" "${PKGCONFIG_LIBS} ${PKGCONFIG_LIBS_PRIVATE}"
  526. FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
  527. string(REPLACE "%PKGCONFIG_LIBS_PRIVATE%" ""
  528. FREETYPE2_PC_IN ${FREETYPE2_PC_IN})
  529. endif ()
  530. set(FREETYPE2_PC_IN_NAME "${PROJECT_BINARY_DIR}/freetype2.pc")
  531. if (EXISTS "${FREETYPE2_PC_IN_NAME}")
  532. file(READ "${FREETYPE2_PC_IN_NAME}" ORIGINAL_FREETYPE2_PC_IN)
  533. else ()
  534. set(ORIGINAL_FREETYPE2_PC_IN "")
  535. endif ()
  536. if (NOT (ORIGINAL_FREETYPE2_PC_IN STREQUAL FREETYPE2_PC_IN))
  537. file(WRITE "${FREETYPE2_PC_IN_NAME}" ${FREETYPE2_PC_IN})
  538. endif ()
  539. install(
  540. FILES ${PROJECT_BINARY_DIR}/freetype2.pc
  541. DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
  542. COMPONENT pkgconfig)
  543. include(CMakePackageConfigHelpers)
  544. write_basic_package_version_file(
  545. ${PROJECT_BINARY_DIR}/freetype-config-version.cmake
  546. VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
  547. COMPATIBILITY SameMajorVersion)
  548. install(
  549. TARGETS freetype
  550. EXPORT freetype-targets
  551. LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
  552. ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
  553. RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
  554. FRAMEWORK DESTINATION Library/Frameworks
  555. COMPONENT libraries)
  556. install(
  557. EXPORT freetype-targets
  558. DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/freetype
  559. FILE freetype-config.cmake
  560. COMPONENT headers)
  561. install(
  562. FILES ${PROJECT_BINARY_DIR}/freetype-config-version.cmake
  563. DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/freetype
  564. COMPONENT headers)
  565. endif ()
  566. # Packaging
  567. set(CPACK_PACKAGE_NAME ${CMAKE_PROJECT_NAME})
  568. set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The FreeType font rendering library.")
  569. set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
  570. set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.TXT")
  571. set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
  572. set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
  573. set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH})
  574. set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
  575. if (WIN32)
  576. set(CPACK_GENERATOR ZIP)
  577. else ()
  578. set(CPACK_GENERATOR TGZ)
  579. endif ()
  580. set(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "Libraries")
  581. set(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C/C++ Headers")
  582. set(CPACK_COMPONENT_LIBRARIES_DESCRIPTION
  583. "Library used to build programs which use FreeType")
  584. set(CPACK_COMPONENT_HEADERS_DESCRIPTION
  585. "C/C++ header files for use with FreeType")
  586. set(CPACK_COMPONENT_HEADERS_DEPENDS libraries)
  587. set(CPACK_COMPONENT_LIBRARIES_GROUP "Development")
  588. set(CPACK_COMPONENT_HEADERS_GROUP "Development")
  589. include(CPack)