John Cary | a0e4a73 | 2013-10-24 08:49:08 +0200 | [diff] [blame] | 1 | # CMakeLists.txt |
| 2 | # |
Werner Lemberg | 7585997 | 2019-02-23 10:07:09 +0100 | [diff] [blame] | 3 | # Copyright (C) 2013-2019 by |
John Cary | a0e4a73 | 2013-10-24 08:49:08 +0200 | [diff] [blame] | 4 | # David Turner, Robert Wilhelm, and Werner Lemberg. |
| 5 | # |
Werner Lemberg | 0505537 | 2015-06-28 11:07:07 +0200 | [diff] [blame] | 6 | # Written originally by John Cary <cary@txcorp.com> |
John Cary | a0e4a73 | 2013-10-24 08:49:08 +0200 | [diff] [blame] | 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 | # |
Werner Lemberg | 0505537 | 2015-06-28 11:07:07 +0200 | [diff] [blame] | 14 | # |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 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. |
John Cary | a0e4a73 | 2013-10-24 08:49:08 +0200 | [diff] [blame] | 18 | # |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 19 | # cmake -E make_directory build |
| 20 | # cmake -E chdir build cmake .. |
Alexey Petruchik | 02f2170 | 2014-05-16 08:09:43 +0200 | [diff] [blame] | 21 | # |
| 22 | # For a dynamic library, use |
John Cary | a0e4a73 | 2013-10-24 08:49:08 +0200 | [diff] [blame] | 23 | # |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 24 | # cmake -E chdir build cmake -D BUILD_SHARED_LIBS:BOOL=true .. |
John Cary | a0e4a73 | 2013-10-24 08:49:08 +0200 | [diff] [blame] | 25 | # |
Alexey Petruchik | 02f2170 | 2014-05-16 08:09:43 +0200 | [diff] [blame] | 26 | # For a framework on OS X, use |
| 27 | # |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 28 | # cmake -E chdir build cmake -G Xcode -D BUILD_FRAMEWORK:BOOL=true .. |
Werner Lemberg | 54306f5 | 2014-10-18 10:42:28 +0200 | [diff] [blame] | 29 | # |
| 30 | # For an iOS static library, use |
| 31 | # |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 32 | # cmake -E chdir build cmake -G Xcode -D IOS_PLATFORM=OS .. |
Werner Lemberg | 54306f5 | 2014-10-18 10:42:28 +0200 | [diff] [blame] | 33 | # |
| 34 | # or |
| 35 | # |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 36 | # cmake -E chdir build cmake -G Xcode -D IOS_PLATFORM=SIMULATOR .. |
| 37 | # |
Nikolaus Waxweiler | bfbde79 | 2018-06-10 13:19:31 +0100 | [diff] [blame] | 38 | # or |
| 39 | # |
| 40 | # cmake -E chdir build cmake -G Xcode -D IOS_PLATFORM=SIMULATOR64 .. |
| 41 | # |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 42 | # Finally, build the project with: |
| 43 | # |
| 44 | # cmake --build build |
| 45 | # |
| 46 | # Install it with |
| 47 | # |
| 48 | # (sudo) cmake --build build --target install |
| 49 | # |
| 50 | # A binary distribution can be made with |
| 51 | # |
| 52 | # cmake --build build --config Release --target package |
Werner Lemberg | 54306f5 | 2014-10-18 10:42:28 +0200 | [diff] [blame] | 53 | # |
| 54 | # Please refer to the cmake manual for further options, in particular, how |
| 55 | # to modify compilation and linking parameters. |
John Cary | a0e4a73 | 2013-10-24 08:49:08 +0200 | [diff] [blame] | 56 | # |
| 57 | # Some notes. |
| 58 | # |
Werner Lemberg | 0505537 | 2015-06-28 11:07:07 +0200 | [diff] [blame] | 59 | # . `cmake' creates configuration files in |
| 60 | # |
| 61 | # <build-directory>/include/freetype/config |
| 62 | # |
| 63 | # which should be further modified if necessary. |
John Cary | a0e4a73 | 2013-10-24 08:49:08 +0200 | [diff] [blame] | 64 | # |
| 65 | # . You can use `cmake' directly on a freshly cloned FreeType git |
| 66 | # repository. |
| 67 | # |
Werner Lemberg | 0505537 | 2015-06-28 11:07:07 +0200 | [diff] [blame] | 68 | # . `CMakeLists.txt' is provided as-is since it is normally not used by the |
John Cary | a0e4a73 | 2013-10-24 08:49:08 +0200 | [diff] [blame] | 69 | # developer team. |
Alexander Bock | 8f982b3 | 2015-11-27 06:34:39 +0100 | [diff] [blame] | 70 | # |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 71 | # . Set the `FT_WITH_ZLIB', `FT_WITH_BZIP2', `FT_WITH_PNG', and |
| 72 | # `FT_WITH_HARFBUZZ' CMake variables to `ON' to force using a dependency. |
Tamas Kenez | da97b4c | 2015-11-27 07:11:42 +0100 | [diff] [blame] | 73 | # Leave a variable undefined (which is the default) to use the dependency |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 74 | # only if it is available. Set `CMAKE_DISABLE_FIND_PACKAGE_HarfBuzz=TRUE' to |
| 75 | # disable a dependency completely (CMake package name, so `BZip2' instead of |
| 76 | # `BZIP2'). Example: |
Tamas Kenez | da97b4c | 2015-11-27 07:11:42 +0100 | [diff] [blame] | 77 | # |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 78 | # cmake -DFT_WITH_ZLIB=ON -DCMAKE_DISABLE_FIND_PACKAGE_HarfBuzz=TRUE [...] |
David Capello | 9224f05 | 2016-04-16 10:24:24 +0200 | [diff] [blame] | 79 | # |
| 80 | # . Installation of FreeType can be controlled with the CMake variables |
| 81 | # `SKIP_INSTALL_HEADERS', `SKIP_INSTALL_LIBRARIES', and `SKIP_INSTALL_ALL' |
| 82 | # (this is compatible with the same CMake variables in zlib's CMake |
| 83 | # support). |
John Cary | a0e4a73 | 2013-10-24 08:49:08 +0200 | [diff] [blame] | 84 | |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 85 | # FreeType explicitly marks the API to be exported and relies on the compiler |
| 86 | # to hide all other symbols. CMake supports a C_VISBILITY_PRESET property |
| 87 | # starting with 2.8.12. |
| 88 | cmake_minimum_required(VERSION 2.8.12) |
John Cary | a0e4a73 | 2013-10-24 08:49:08 +0200 | [diff] [blame] | 89 | |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 90 | if (NOT CMAKE_VERSION VERSION_LESS 3.3) |
| 91 | # Allow symbol visibility settings also on static libraries. CMake < 3.3 |
| 92 | # only sets the propery on a shared library build. |
| 93 | cmake_policy(SET CMP0063 NEW) |
| 94 | endif () |
Werner Lemberg | 97b757d | 2015-06-28 10:42:47 +0200 | [diff] [blame] | 95 | |
| 96 | include(CheckIncludeFile) |
| 97 | |
Werner Lemberg | 54306f5 | 2014-10-18 10:42:28 +0200 | [diff] [blame] | 98 | # CMAKE_TOOLCHAIN_FILE must be set before `project' is called, which |
| 99 | # configures the base build environment and references the toolchain file |
| 100 | if (APPLE) |
| 101 | if (DEFINED IOS_PLATFORM) |
| 102 | if (NOT "${IOS_PLATFORM}" STREQUAL "OS" |
Nikolaus Waxweiler | bfbde79 | 2018-06-10 13:19:31 +0100 | [diff] [blame] | 103 | AND NOT "${IOS_PLATFORM}" STREQUAL "SIMULATOR" |
| 104 | AND NOT "${IOS_PLATFORM}" STREQUAL "SIMULATOR64") |
Werner Lemberg | 54306f5 | 2014-10-18 10:42:28 +0200 | [diff] [blame] | 105 | message(FATAL_ERROR |
Nikolaus Waxweiler | bfbde79 | 2018-06-10 13:19:31 +0100 | [diff] [blame] | 106 | "IOS_PLATFORM must be set to either OS, SIMULATOR, or SIMULATOR64") |
Werner Lemberg | 54306f5 | 2014-10-18 10:42:28 +0200 | [diff] [blame] | 107 | endif () |
| 108 | if (NOT "${CMAKE_GENERATOR}" STREQUAL "Xcode") |
| 109 | message(AUTHOR_WARNING |
| 110 | "You should use Xcode generator with IOS_PLATFORM enabled to get Universal builds.") |
| 111 | endif () |
| 112 | if (BUILD_SHARED_LIBS) |
| 113 | message(FATAL_ERROR |
| 114 | "BUILD_SHARED_LIBS can not be on with IOS_PLATFORM enabled") |
| 115 | endif () |
| 116 | if (BUILD_FRAMEWORK) |
| 117 | message(FATAL_ERROR |
| 118 | "BUILD_FRAMEWORK can not be on with IOS_PLATFORM enabled") |
| 119 | endif () |
| 120 | |
| 121 | # iOS only uses static libraries |
| 122 | set(BUILD_SHARED_LIBS OFF) |
| 123 | |
| 124 | set(CMAKE_TOOLCHAIN_FILE |
Werner Lemberg | 10265db | 2016-03-11 06:50:23 +0100 | [diff] [blame] | 125 | ${CMAKE_SOURCE_DIR}/builds/cmake/iOS.cmake) |
Werner Lemberg | 54306f5 | 2014-10-18 10:42:28 +0200 | [diff] [blame] | 126 | endif () |
| 127 | else () |
| 128 | if (DEFINED IOS_PLATFORM) |
| 129 | message(FATAL_ERROR "IOS_PLATFORM is not supported on this platform") |
| 130 | endif () |
| 131 | endif () |
| 132 | |
Werner Lemberg | 22479ca | 2015-06-28 10:26:33 +0200 | [diff] [blame] | 133 | |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 134 | project(freetype C) |
| 135 | |
| 136 | set(VERSION_MAJOR "2") |
Werner Lemberg | fbbcf50 | 2019-03-15 07:27:02 +0100 | [diff] [blame] | 137 | set(VERSION_MINOR "10") |
Werner Lemberg | 8cf046c | 2019-07-01 13:54:54 +0200 | [diff] [blame] | 138 | set(VERSION_PATCH "1") |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 139 | |
| 140 | # SOVERSION scheme: CURRENT.AGE.REVISION |
| 141 | # If there was an incompatible interface change: |
| 142 | # Increment CURRENT. Set AGE and REVISION to 0 |
| 143 | # If there was a compatible interface change: |
| 144 | # Increment AGE. Set REVISION to 0 |
| 145 | # If the source code was changed, but there were no interface changes: |
| 146 | # Increment REVISION. |
| 147 | set(LIBRARY_VERSION "6.16.0") |
| 148 | set(LIBRARY_SOVERSION "6") |
| 149 | |
| 150 | # These options mean "require x and complain if not found". They'll get |
| 151 | # optionally found anyway. Use `-DCMAKE_DISABLE_FIND_PACKAGE_x=TRUE` to disable |
| 152 | # searching for a packge entirely (x is the CMake package name, so "BZip2" |
| 153 | # instead of "BZIP2"). |
| 154 | option(FT_WITH_ZLIB "Use system zlib instead of internal library." OFF) |
| 155 | option(FT_WITH_BZIP2 "Support bzip2 compressed fonts." OFF) |
| 156 | option(FT_WITH_PNG "Support PNG compressed OpenType embedded bitmaps." OFF) |
| 157 | option(FT_WITH_HARFBUZZ "Improve auto-hinting of OpenType fonts." OFF) |
John Cary | a0e4a73 | 2013-10-24 08:49:08 +0200 | [diff] [blame] | 158 | |
Werner Lemberg | 22479ca | 2015-06-28 10:26:33 +0200 | [diff] [blame] | 159 | |
| 160 | # Disallow in-source builds |
Nikolaus Waxweiler | f7b4fb3 | 2018-05-07 23:10:36 +0100 | [diff] [blame] | 161 | if ("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}") |
Werner Lemberg | 22479ca | 2015-06-28 10:26:33 +0200 | [diff] [blame] | 162 | message(FATAL_ERROR |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 163 | "In-source builds are not permitted! Make a separate folder for" |
| 164 | " building, e.g.,\n" |
| 165 | " cmake -E make_directory build\n" |
| 166 | " cmake -E chdir build cmake ..\n" |
| 167 | "Before that, remove the files created by this failed run with\n" |
| 168 | " cmake -E remove CMakeCache.txt\n" |
| 169 | " cmake -E remove_directory CMakeFiles") |
Werner Lemberg | 22479ca | 2015-06-28 10:26:33 +0200 | [diff] [blame] | 170 | endif () |
| 171 | |
| 172 | |
Werner Lemberg | 52c9b1a | 2015-06-28 11:03:10 +0200 | [diff] [blame] | 173 | # Add local cmake modules |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 174 | list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/builds/cmake) |
Werner Lemberg | 52c9b1a | 2015-06-28 11:03:10 +0200 | [diff] [blame] | 175 | |
| 176 | |
Alexey Petruchik | 02f2170 | 2014-05-16 08:09:43 +0200 | [diff] [blame] | 177 | if (BUILD_FRAMEWORK) |
| 178 | if (NOT "${CMAKE_GENERATOR}" STREQUAL "Xcode") |
Werner Lemberg | 54306f5 | 2014-10-18 10:42:28 +0200 | [diff] [blame] | 179 | message(FATAL_ERROR |
| 180 | "You should use Xcode generator with BUILD_FRAMEWORK enabled") |
Alexey Petruchik | 02f2170 | 2014-05-16 08:09:43 +0200 | [diff] [blame] | 181 | endif () |
| 182 | set(CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD_32_64_BIT)") |
| 183 | set(BUILD_SHARED_LIBS ON) |
| 184 | endif () |
| 185 | |
Werner Lemberg | 52c9b1a | 2015-06-28 11:03:10 +0200 | [diff] [blame] | 186 | |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 187 | # Find dependencies |
| 188 | if (FT_WITH_HARFBUZZ) |
| 189 | find_package(HarfBuzz 1.3.0 REQUIRED) |
| 190 | else () |
| 191 | find_package(HarfBuzz 1.3.0) |
Steve Robinson | 707cd02 | 2018-01-10 07:48:39 +0100 | [diff] [blame] | 192 | endif () |
John Cary | a0e4a73 | 2013-10-24 08:49:08 +0200 | [diff] [blame] | 193 | |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 194 | if (FT_WITH_PNG) |
| 195 | find_package(PNG REQUIRED) |
| 196 | else () |
| 197 | find_package(PNG) |
| 198 | endif () |
Werner Lemberg | 97b757d | 2015-06-28 10:42:47 +0200 | [diff] [blame] | 199 | |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 200 | if (FT_WITH_ZLIB) |
| 201 | find_package(ZLIB REQUIRED) |
| 202 | else () |
| 203 | find_package(ZLIB) |
| 204 | endif () |
Tamas Kenez | da97b4c | 2015-11-27 07:11:42 +0100 | [diff] [blame] | 205 | |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 206 | if (FT_WITH_BZIP2) |
| 207 | find_package(BZip2 REQUIRED) |
| 208 | else () |
| 209 | find_package(BZip2) |
| 210 | endif () |
Werner Lemberg | 52c9b1a | 2015-06-28 11:03:10 +0200 | [diff] [blame] | 211 | |
John Cary | a0e4a73 | 2013-10-24 08:49:08 +0200 | [diff] [blame] | 212 | # Create the configuration file |
Werner Lemberg | 68222dd | 2015-06-25 16:38:11 +0200 | [diff] [blame] | 213 | if (UNIX) |
Werner Lemberg | 97b757d | 2015-06-28 10:42:47 +0200 | [diff] [blame] | 214 | check_include_file("unistd.h" HAVE_UNISTD_H) |
| 215 | check_include_file("fcntl.h" HAVE_FCNTL_H) |
| 216 | check_include_file("stdint.h" HAVE_STDINT_H) |
John Cary | a0e4a73 | 2013-10-24 08:49:08 +0200 | [diff] [blame] | 217 | |
Werner Lemberg | 68222dd | 2015-06-25 16:38:11 +0200 | [diff] [blame] | 218 | file(READ "${PROJECT_SOURCE_DIR}/builds/unix/ftconfig.in" |
| 219 | FTCONFIG_H) |
Werner Lemberg | 97b757d | 2015-06-28 10:42:47 +0200 | [diff] [blame] | 220 | if (HAVE_UNISTD_H) |
| 221 | string(REGEX REPLACE |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 222 | "#undef +(HAVE_UNISTD_H)" "#define \\1 1" |
Werner Lemberg | 97b757d | 2015-06-28 10:42:47 +0200 | [diff] [blame] | 223 | FTCONFIG_H "${FTCONFIG_H}") |
| 224 | endif () |
| 225 | if (HAVE_FCNTL_H) |
| 226 | string(REGEX REPLACE |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 227 | "#undef +(HAVE_FCNTL_H)" "#define \\1 1" |
Werner Lemberg | 97b757d | 2015-06-28 10:42:47 +0200 | [diff] [blame] | 228 | FTCONFIG_H "${FTCONFIG_H}") |
| 229 | endif () |
| 230 | if (HAVE_STDINT_H) |
| 231 | string(REGEX REPLACE |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 232 | "#undef +(HAVE_STDINT_H)" "#define \\1 1" |
Werner Lemberg | 97b757d | 2015-06-28 10:42:47 +0200 | [diff] [blame] | 233 | FTCONFIG_H "${FTCONFIG_H}") |
| 234 | endif () |
Werner Lemberg | 68222dd | 2015-06-25 16:38:11 +0200 | [diff] [blame] | 235 | string(REPLACE "/undef " "#undef " |
| 236 | FTCONFIG_H "${FTCONFIG_H}") |
Minmin Gong | ebe3750 | 2019-04-15 10:46:19 +0200 | [diff] [blame] | 237 | else () |
Nikolaus Waxweiler | 660afb5 | 2018-05-02 23:19:55 +0100 | [diff] [blame] | 238 | file(READ "${PROJECT_SOURCE_DIR}/include/freetype/config/ftconfig.h" |
| 239 | FTCONFIG_H) |
Werner Lemberg | 68222dd | 2015-06-25 16:38:11 +0200 | [diff] [blame] | 240 | endif () |
Minmin Gong | ebe3750 | 2019-04-15 10:46:19 +0200 | [diff] [blame] | 241 | |
| 242 | set(FTCONFIG_H_NAME "${PROJECT_BINARY_DIR}/include/freetype/config/ftconfig.h") |
| 243 | if (EXISTS "${FTCONFIG_H_NAME}") |
| 244 | file(READ "${FTCONFIG_H_NAME}" ORIGINAL_FTCONFIG_H) |
| 245 | else () |
| 246 | set(ORIGINAL_FTCONFIG_H "") |
| 247 | endif () |
| 248 | if (NOT (ORIGINAL_FTCONFIG_H STREQUAL FTCONFIG_H)) |
| 249 | file(WRITE "${FTCONFIG_H_NAME}" "${FTCONFIG_H}") |
| 250 | endif () |
John Cary | a0e4a73 | 2013-10-24 08:49:08 +0200 | [diff] [blame] | 251 | |
Werner Lemberg | 97b757d | 2015-06-28 10:42:47 +0200 | [diff] [blame] | 252 | |
Werner Lemberg | 52c9b1a | 2015-06-28 11:03:10 +0200 | [diff] [blame] | 253 | # Create the options file |
Werner Lemberg | 52c9b1a | 2015-06-28 11:03:10 +0200 | [diff] [blame] | 254 | file(READ "${PROJECT_SOURCE_DIR}/include/freetype/config/ftoption.h" |
| 255 | FTOPTION_H) |
| 256 | if (ZLIB_FOUND) |
| 257 | string(REGEX REPLACE |
| 258 | "/\\* +(#define +FT_CONFIG_OPTION_SYSTEM_ZLIB) +\\*/" "\\1" |
| 259 | FTOPTION_H "${FTOPTION_H}") |
| 260 | endif () |
| 261 | if (BZIP2_FOUND) |
| 262 | string(REGEX REPLACE |
| 263 | "/\\* +(#define +FT_CONFIG_OPTION_USE_BZIP2) +\\*/" "\\1" |
| 264 | FTOPTION_H "${FTOPTION_H}") |
| 265 | endif () |
| 266 | if (PNG_FOUND) |
| 267 | string(REGEX REPLACE |
| 268 | "/\\* +(#define +FT_CONFIG_OPTION_USE_PNG) +\\*/" "\\1" |
| 269 | FTOPTION_H "${FTOPTION_H}") |
| 270 | endif () |
| 271 | if (HARFBUZZ_FOUND) |
| 272 | string(REGEX REPLACE |
| 273 | "/\\* +(#define +FT_CONFIG_OPTION_USE_HARFBUZZ) +\\*/" "\\1" |
| 274 | FTOPTION_H "${FTOPTION_H}") |
| 275 | endif () |
Minmin Gong | ebe3750 | 2019-04-15 10:46:19 +0200 | [diff] [blame] | 276 | |
| 277 | set(FTOPTION_H_NAME "${PROJECT_BINARY_DIR}/include/freetype/config/ftoption.h") |
| 278 | if (EXISTS "${FTOPTION_H_NAME}") |
| 279 | file(READ "${FTOPTION_H_NAME}" ORIGINAL_FTOPTION_H) |
| 280 | else () |
| 281 | set(ORIGINAL_FTOPTION_H "") |
| 282 | endif () |
| 283 | if (NOT (ORIGINAL_FTOPTION_H STREQUAL FTOPTION_H)) |
| 284 | file(WRITE "${FTOPTION_H_NAME}" "${FTOPTION_H}") |
| 285 | endif () |
Werner Lemberg | 97b757d | 2015-06-28 10:42:47 +0200 | [diff] [blame] | 286 | |
| 287 | |
Werner Lemberg | 392cf22 | 2015-06-25 13:04:57 +0200 | [diff] [blame] | 288 | file(GLOB PUBLIC_HEADERS "include/ft2build.h" "include/freetype/*.h") |
| 289 | file(GLOB PUBLIC_CONFIG_HEADERS "include/freetype/config/*.h") |
| 290 | file(GLOB PRIVATE_HEADERS "include/freetype/internal/*.h") |
Alexey Petruchik | 02f2170 | 2014-05-16 08:09:43 +0200 | [diff] [blame] | 291 | |
Werner Lemberg | 0505537 | 2015-06-28 11:07:07 +0200 | [diff] [blame] | 292 | |
John Cary | a0e4a73 | 2013-10-24 08:49:08 +0200 | [diff] [blame] | 293 | set(BASE_SRCS |
| 294 | src/autofit/autofit.c |
Werner Lemberg | 5ef5a4f | 2015-06-25 15:45:13 +0200 | [diff] [blame] | 295 | src/base/ftbase.c |
John Cary | a0e4a73 | 2013-10-24 08:49:08 +0200 | [diff] [blame] | 296 | src/base/ftbbox.c |
Pavel Koshevoy | 15da66a | 2014-05-13 07:33:48 +0200 | [diff] [blame] | 297 | src/base/ftbdf.c |
John Cary | a0e4a73 | 2013-10-24 08:49:08 +0200 | [diff] [blame] | 298 | src/base/ftbitmap.c |
John Cary | a0e4a73 | 2013-10-24 08:49:08 +0200 | [diff] [blame] | 299 | src/base/ftcid.c |
John Cary | a0e4a73 | 2013-10-24 08:49:08 +0200 | [diff] [blame] | 300 | src/base/ftfstype.c |
| 301 | src/base/ftgasp.c |
John Cary | a0e4a73 | 2013-10-24 08:49:08 +0200 | [diff] [blame] | 302 | src/base/ftglyph.c |
| 303 | src/base/ftgxval.c |
| 304 | src/base/ftinit.c |
John Cary | a0e4a73 | 2013-10-24 08:49:08 +0200 | [diff] [blame] | 305 | src/base/ftmm.c |
John Cary | a0e4a73 | 2013-10-24 08:49:08 +0200 | [diff] [blame] | 306 | src/base/ftotval.c |
John Cary | a0e4a73 | 2013-10-24 08:49:08 +0200 | [diff] [blame] | 307 | src/base/ftpatent.c |
| 308 | src/base/ftpfr.c |
John Cary | a0e4a73 | 2013-10-24 08:49:08 +0200 | [diff] [blame] | 309 | src/base/ftstroke.c |
| 310 | src/base/ftsynth.c |
| 311 | src/base/ftsystem.c |
John Cary | a0e4a73 | 2013-10-24 08:49:08 +0200 | [diff] [blame] | 312 | src/base/fttype1.c |
John Cary | a0e4a73 | 2013-10-24 08:49:08 +0200 | [diff] [blame] | 313 | src/base/ftwinfnt.c |
John Cary | a0e4a73 | 2013-10-24 08:49:08 +0200 | [diff] [blame] | 314 | src/bdf/bdf.c |
| 315 | src/bzip2/ftbzip2.c |
| 316 | src/cache/ftcache.c |
| 317 | src/cff/cff.c |
| 318 | src/cid/type1cid.c |
| 319 | src/gzip/ftgzip.c |
| 320 | src/lzw/ftlzw.c |
| 321 | src/pcf/pcf.c |
| 322 | src/pfr/pfr.c |
| 323 | src/psaux/psaux.c |
| 324 | src/pshinter/pshinter.c |
Werner Lemberg | 5ef5a4f | 2015-06-25 15:45:13 +0200 | [diff] [blame] | 325 | src/psnames/psnames.c |
John Cary | a0e4a73 | 2013-10-24 08:49:08 +0200 | [diff] [blame] | 326 | src/raster/raster.c |
| 327 | src/sfnt/sfnt.c |
| 328 | src/smooth/smooth.c |
| 329 | src/truetype/truetype.c |
| 330 | src/type1/type1.c |
| 331 | src/type42/type42.c |
| 332 | src/winfonts/winfnt.c |
| 333 | ) |
| 334 | |
Werner Lemberg | 94c79c2 | 2015-06-26 06:46:59 +0200 | [diff] [blame] | 335 | if (WIN32) |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 336 | enable_language(RC) |
| 337 | list(APPEND BASE_SRCS builds/windows/ftdebug.c |
| 338 | src/base/ftver.rc) |
Werner Lemberg | 94c79c2 | 2015-06-26 06:46:59 +0200 | [diff] [blame] | 339 | elseif (WINCE) |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 340 | list(APPEND BASE_SRCS builds/wince/ftdebug.c) |
Werner Lemberg | 94c79c2 | 2015-06-26 06:46:59 +0200 | [diff] [blame] | 341 | else () |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 342 | list(APPEND BASE_SRCS src/base/ftdebug.c) |
Werner Lemberg | 94c79c2 | 2015-06-26 06:46:59 +0200 | [diff] [blame] | 343 | endif () |
| 344 | |
Alexey Petruchik | 02f2170 | 2014-05-16 08:09:43 +0200 | [diff] [blame] | 345 | if (BUILD_FRAMEWORK) |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 346 | list(APPEND BASE_SRCS builds/mac/freetype-Info.plist) |
Alexey Petruchik | 02f2170 | 2014-05-16 08:09:43 +0200 | [diff] [blame] | 347 | endif () |
| 348 | |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 349 | |
yuri_levchenko | af585ad | 2017-11-09 13:38:26 +0200 | [diff] [blame] | 350 | if (NOT DISABLE_FORCE_DEBUG_POSTFIX) |
| 351 | set(CMAKE_DEBUG_POSTFIX d) |
Minmin Gong | ebe3750 | 2019-04-15 10:46:19 +0200 | [diff] [blame] | 352 | endif () |
Werner Lemberg | 0505537 | 2015-06-28 11:07:07 +0200 | [diff] [blame] | 353 | |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 354 | |
Alexey Petruchik | 02f2170 | 2014-05-16 08:09:43 +0200 | [diff] [blame] | 355 | add_library(freetype |
| 356 | ${PUBLIC_HEADERS} |
| 357 | ${PUBLIC_CONFIG_HEADERS} |
| 358 | ${PRIVATE_HEADERS} |
| 359 | ${BASE_SRCS} |
| 360 | ) |
| 361 | |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 362 | set_target_properties( |
| 363 | freetype PROPERTIES |
| 364 | C_VISIBILITY_PRESET hidden) |
| 365 | |
| 366 | target_compile_definitions( |
| 367 | freetype PRIVATE FT2_BUILD_LIBRARY) |
| 368 | |
| 369 | if (WIN32) |
| 370 | target_compile_definitions( |
| 371 | freetype PRIVATE _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_WARNINGS) |
Alexei Podtelezhnikov | 4b97ab9 | 2018-07-24 23:01:34 -0400 | [diff] [blame] | 372 | if (BUILD_SHARED_LIBS) |
| 373 | target_compile_definitions( |
| 374 | freetype PRIVATE DLL_EXPORT) |
| 375 | endif () |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 376 | endif () |
Werner Lemberg | 0505537 | 2015-06-28 11:07:07 +0200 | [diff] [blame] | 377 | |
Werner Lemberg | a82c45d | 2015-08-02 18:35:49 +0200 | [diff] [blame] | 378 | if (BUILD_SHARED_LIBS) |
| 379 | set_target_properties(freetype PROPERTIES |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 380 | VERSION ${LIBRARY_VERSION} |
| 381 | SOVERSION ${LIBRARY_SOVERSION}) |
Werner Lemberg | a82c45d | 2015-08-02 18:35:49 +0200 | [diff] [blame] | 382 | endif () |
| 383 | |
Nikolaus Waxweiler | f7b4fb3 | 2018-05-07 23:10:36 +0100 | [diff] [blame] | 384 | # Pick up ftconfig.h and ftoption.h generated above, first. |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 385 | target_include_directories( |
| 386 | freetype |
Nikolaus Waxweiler | f7b4fb3 | 2018-05-07 23:10:36 +0100 | [diff] [blame] | 387 | PUBLIC |
| 388 | $<INSTALL_INTERFACE:include/freetype2> |
| 389 | $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include> |
| 390 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> |
Werner Lemberg | d91f752 | 2018-08-31 07:34:30 +0200 | [diff] [blame] | 391 | PRIVATE |
Nikolaus Waxweiler | f7b4fb3 | 2018-05-07 23:10:36 +0100 | [diff] [blame] | 392 | ${CMAKE_CURRENT_BINARY_DIR}/include |
| 393 | ${CMAKE_CURRENT_SOURCE_DIR}/include) |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 394 | |
Werner Lemberg | a82c45d | 2015-08-02 18:35:49 +0200 | [diff] [blame] | 395 | |
Alexey Petruchik | 02f2170 | 2014-05-16 08:09:43 +0200 | [diff] [blame] | 396 | if (BUILD_FRAMEWORK) |
| 397 | set_property(SOURCE ${PUBLIC_CONFIG_HEADERS} |
| 398 | PROPERTY MACOSX_PACKAGE_LOCATION Headers/config |
| 399 | ) |
| 400 | set_target_properties(freetype PROPERTIES |
| 401 | FRAMEWORK TRUE |
| 402 | MACOSX_FRAMEWORK_INFO_PLIST builds/mac/freetype-Info.plist |
| 403 | PUBLIC_HEADER "${PUBLIC_HEADERS}" |
| 404 | XCODE_ATTRIBUTE_INSTALL_PATH "@rpath" |
| 405 | ) |
| 406 | endif () |
John Cary | a0e4a73 | 2013-10-24 08:49:08 +0200 | [diff] [blame] | 407 | |
Tamas Kenez | c80620c | 2015-11-27 18:37:21 +0100 | [diff] [blame] | 408 | |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 409 | set(PKG_CONFIG_REQUIRED_PRIVATE "") |
Werner Lemberg | 52c9b1a | 2015-06-28 11:03:10 +0200 | [diff] [blame] | 410 | |
| 411 | if (ZLIB_FOUND) |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 412 | target_link_libraries(freetype PRIVATE ${ZLIB_LIBRARIES}) |
| 413 | target_include_directories(freetype PRIVATE ${ZLIB_INCLUDE_DIRS}) |
| 414 | list(APPEND PKG_CONFIG_REQUIRED_PRIVATE zlib) |
Werner Lemberg | 52c9b1a | 2015-06-28 11:03:10 +0200 | [diff] [blame] | 415 | endif () |
| 416 | if (BZIP2_FOUND) |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 417 | target_link_libraries(freetype PRIVATE ${BZIP2_LIBRARIES}) |
| 418 | target_include_directories(freetype PRIVATE ${BZIP2_INCLUDE_DIR}) # not BZIP2_INCLUDE_DIRS |
| 419 | list(APPEND PKG_CONFIG_REQUIRED_PRIVATE bzip2) |
Werner Lemberg | 52c9b1a | 2015-06-28 11:03:10 +0200 | [diff] [blame] | 420 | endif () |
| 421 | if (PNG_FOUND) |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 422 | target_link_libraries(freetype PRIVATE ${PNG_LIBRARIES}) |
| 423 | target_compile_definitions(freetype PRIVATE ${PNG_DEFINITIONS}) |
| 424 | target_include_directories(freetype PRIVATE ${PNG_INCLUDE_DIRS}) |
| 425 | list(APPEND PKG_CONFIG_REQUIRED_PRIVATE libpng) |
Werner Lemberg | 52c9b1a | 2015-06-28 11:03:10 +0200 | [diff] [blame] | 426 | endif () |
| 427 | if (HARFBUZZ_FOUND) |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 428 | target_link_libraries(freetype PRIVATE ${HARFBUZZ_LIBRARIES}) |
| 429 | target_include_directories(freetype PRIVATE ${HARFBUZZ_INCLUDE_DIRS}) |
| 430 | list(APPEND PKG_CONFIG_REQUIRED_PRIVATE harfbuzz) |
Werner Lemberg | 52c9b1a | 2015-06-28 11:03:10 +0200 | [diff] [blame] | 431 | endif () |
| 432 | |
| 433 | |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 434 | # Installation |
| 435 | include(GNUInstallDirs) |
| 436 | |
David Capello | 9224f05 | 2016-04-16 10:24:24 +0200 | [diff] [blame] | 437 | if (NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL) |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 438 | install( |
| 439 | # Note the trailing slash in the argument to `DIRECTORY'! |
| 440 | DIRECTORY ${PROJECT_SOURCE_DIR}/include/ |
| 441 | DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/freetype2 |
| 442 | COMPONENT headers |
| 443 | PATTERN "internal" EXCLUDE |
| 444 | PATTERN "ftconfig.h" EXCLUDE |
| 445 | PATTERN "ftoption.h" EXCLUDE) |
| 446 | install( |
| 447 | FILES ${PROJECT_BINARY_DIR}/include/freetype/config/ftconfig.h |
| 448 | ${PROJECT_BINARY_DIR}/include/freetype/config/ftoption.h |
| 449 | DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/freetype2/freetype/config |
| 450 | COMPONENT headers) |
David Capello | 9224f05 | 2016-04-16 10:24:24 +0200 | [diff] [blame] | 451 | endif () |
| 452 | |
| 453 | if (NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL) |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 454 | # Generate the pkg-config file |
| 455 | if (UNIX) |
| 456 | file(READ ${PROJECT_SOURCE_DIR}/builds/unix/freetype2.in FREETYPE2_PC_IN) |
| 457 | |
| 458 | string(REPLACE ";" ", " PKG_CONFIG_REQUIRED_PRIVATE "${PKG_CONFIG_REQUIRED_PRIVATE}") |
| 459 | |
| 460 | string(REPLACE "%prefix%" ${CMAKE_INSTALL_PREFIX} |
| 461 | FREETYPE2_PC_IN ${FREETYPE2_PC_IN}) |
| 462 | string(REPLACE "%exec_prefix%" "\${prefix}" |
| 463 | FREETYPE2_PC_IN ${FREETYPE2_PC_IN}) |
| 464 | string(REPLACE "%libdir%" "\${prefix}/${CMAKE_INSTALL_LIBDIR}" |
| 465 | FREETYPE2_PC_IN ${FREETYPE2_PC_IN}) |
| 466 | string(REPLACE "%includedir%" "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}" |
| 467 | FREETYPE2_PC_IN ${FREETYPE2_PC_IN}) |
| 468 | string(REPLACE "%ft_version%" "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" |
| 469 | FREETYPE2_PC_IN ${FREETYPE2_PC_IN}) |
| 470 | string(REPLACE "%REQUIRES_PRIVATE%" "${PKG_CONFIG_REQUIRED_PRIVATE}" |
| 471 | FREETYPE2_PC_IN ${FREETYPE2_PC_IN}) |
| 472 | string(REPLACE "%LIBS_PRIVATE%" "" # All libs support pkg-config |
| 473 | FREETYPE2_PC_IN ${FREETYPE2_PC_IN}) |
| 474 | |
Minmin Gong | ebe3750 | 2019-04-15 10:46:19 +0200 | [diff] [blame] | 475 | set(FREETYPE2_PC_IN_NAME "${PROJECT_BINARY_DIR}/freetype2.pc") |
| 476 | if (EXISTS "${FREETYPE2_PC_IN_NAME}") |
| 477 | file(READ "${FREETYPE2_PC_IN_NAME}" ORIGINAL_FREETYPE2_PC_IN) |
| 478 | else () |
| 479 | set(ORIGINAL_FREETYPE2_PC_IN "") |
| 480 | endif () |
| 481 | if (NOT (ORIGINAL_FREETYPE2_PC_IN STREQUAL FREETYPE2_PC_IN)) |
| 482 | file(WRITE "${FREETYPE2_PC_IN_NAME}" ${FREETYPE2_PC_IN}) |
| 483 | endif () |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 484 | |
| 485 | install( |
| 486 | FILES ${PROJECT_BINARY_DIR}/freetype2.pc |
| 487 | DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig |
| 488 | COMPONENT pkgconfig) |
| 489 | endif () |
| 490 | |
| 491 | install( |
| 492 | TARGETS freetype |
| 493 | EXPORT freetype-targets |
| 494 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 495 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} |
Werner Lemberg | 0c4feb7 | 2018-10-17 11:25:32 +0200 | [diff] [blame] | 496 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 497 | FRAMEWORK DESTINATION Library/Frameworks |
| 498 | COMPONENT libraries) |
| 499 | install( |
David Capello | 9224f05 | 2016-04-16 10:24:24 +0200 | [diff] [blame] | 500 | EXPORT freetype-targets |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 501 | DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/freetype |
| 502 | FILE freetype-config.cmake |
| 503 | COMPONENT headers) |
David Capello | 9224f05 | 2016-04-16 10:24:24 +0200 | [diff] [blame] | 504 | endif () |
John Cary | a0e4a73 | 2013-10-24 08:49:08 +0200 | [diff] [blame] | 505 | |
Werner Lemberg | 0505537 | 2015-06-28 11:07:07 +0200 | [diff] [blame] | 506 | |
John Cary | a0e4a73 | 2013-10-24 08:49:08 +0200 | [diff] [blame] | 507 | # Packaging |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 508 | set(CPACK_PACKAGE_NAME ${CMAKE_PROJECT_NAME}) |
| 509 | set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The FreeType font rendering library.") |
| 510 | set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README") |
| 511 | set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/docs/LICENSE.TXT") |
| 512 | |
John Cary | a0e4a73 | 2013-10-24 08:49:08 +0200 | [diff] [blame] | 513 | set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR}) |
| 514 | set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR}) |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 515 | set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH}) |
| 516 | set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") |
| 517 | |
| 518 | if (WIN32) |
| 519 | set(CPACK_GENERATOR ZIP) |
Minmin Gong | ebe3750 | 2019-04-15 10:46:19 +0200 | [diff] [blame] | 520 | else () |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 521 | set(CPACK_GENERATOR TGZ) |
Minmin Gong | ebe3750 | 2019-04-15 10:46:19 +0200 | [diff] [blame] | 522 | endif () |
Nikolaus Waxweiler | 029721d | 2018-04-07 21:34:24 +0100 | [diff] [blame] | 523 | |
| 524 | set(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "Libraries") |
| 525 | set(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C/C++ Headers") |
| 526 | set(CPACK_COMPONENT_LIBRARIES_DESCRIPTION |
| 527 | "Library used to build programs which use FreeType") |
| 528 | set(CPACK_COMPONENT_HEADERS_DESCRIPTION |
| 529 | "C/C++ header files for use with FreeType") |
| 530 | set(CPACK_COMPONENT_HEADERS_DEPENDS libraries) |
| 531 | set(CPACK_COMPONENT_LIBRARIES_GROUP "Development") |
| 532 | set(CPACK_COMPONENT_HEADERS_GROUP "Development") |
| 533 | |
John Cary | a0e4a73 | 2013-10-24 08:49:08 +0200 | [diff] [blame] | 534 | include(CPack) |