[cmake] Add brotli support. * CMakeLists.txt (FT_WITH_BROTLI): New option. * builds/cmake/FindBrotliDec.cmake: New file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 70b88c1..da07ca3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -68,12 +68,14 @@
# . `CMakeLists.txt' is provided as-is since it is normally not used by the
# developer team.
#
-# . Set the `FT_WITH_ZLIB', `FT_WITH_BZIP2', `FT_WITH_PNG', and
-# `FT_WITH_HARFBUZZ' CMake variables to `ON' to force using a dependency.
-# Leave a variable undefined (which is the default) to use the dependency
-# only if it is available. Set `CMAKE_DISABLE_FIND_PACKAGE_HarfBuzz=TRUE' to
-# disable a dependency completely (CMake package name, so `BZip2' instead of
-# `BZIP2'). Example:
+# . Set the `FT_WITH_ZLIB', `FT_WITH_BZIP2', `FT_WITH_PNG',
+# `FT_WITH_HARFBUZZ', and `FT_WITH_BROTLI' CMake variables to `ON' to
+# force using a dependency. Leave a variable undefined (which is the
+# default) to use the dependency only if it is available. Set
+# `CMAKE_DISABLE_FIND_PACKAGE_XXX=TRUE' to disable a dependency completely
+# (where `XXX' is a CMake package name like `BZip2').
+#
+# Example:
#
# cmake -DFT_WITH_ZLIB=ON -DCMAKE_DISABLE_FIND_PACKAGE_HarfBuzz=TRUE [...]
#
@@ -156,14 +158,15 @@ string(REGEX REPLACE
math(EXPR LIBRARY_SOVERSION "${LIBTOOL_CURRENT} - ${LIBTOOL_AGE}")
set(LIBRARY_VERSION "${LIBRARY_SOVERSION}.${LIBTOOL_AGE}.${LIBTOOL_REVISION}")
-# These options mean "require x and complain if not found". They'll get
-# optionally found anyway. Use `-DCMAKE_DISABLE_FIND_PACKAGE_x=TRUE` to disable
-# searching for a packge entirely (x is the CMake package name, so "BZip2"
-# instead of "BZIP2").
+# These options mean `require x and complain if not found'. They'll get
+# optionally found anyway. Use `-DCMAKE_DISABLE_FIND_PACKAGE_x=TRUE` to
+# disable searching for a package entirely (`x' is the CMake package name,
+# so `BZip2' instead of `BZIP2').
option(FT_WITH_ZLIB "Use system zlib instead of internal library." OFF)
option(FT_WITH_BZIP2 "Support bzip2 compressed fonts." OFF)
option(FT_WITH_PNG "Support PNG compressed OpenType embedded bitmaps." OFF)
option(FT_WITH_HARFBUZZ "Improve auto-hinting of OpenType fonts." OFF)
+option(FT_WITH_BROTLI "Support compressed WOFF2 fonts." OFF)
# Disallow in-source builds
@@ -219,6 +222,12 @@ else ()
find_package(BZip2)
endif ()
+if (FT_WITH_BROTLI)
+ find_package(BrotliDec REQUIRED)
+else ()
+ find_package(BrotliDec)
+endif ()
+
# Create the configuration file
if (UNIX)
check_include_file("unistd.h" HAVE_UNISTD_H)
@@ -283,6 +292,11 @@ if (HARFBUZZ_FOUND)
"/\\* +(#define +FT_CONFIG_OPTION_USE_HARFBUZZ) +\\*/" "\\1"
FTOPTION_H "${FTOPTION_H}")
endif ()
+if (BROTLIDEC_FOUND)
+ string(REGEX REPLACE
+ "/\\* +(#define +FT_CONFIG_OPTION_USE_BROTLI) +\\*/" "\\1"
+ FTOPTION_H "${FTOPTION_H}")
+endif ()
set(FTOPTION_H_NAME "${PROJECT_BINARY_DIR}/include/freetype/config/ftoption.h")
if (EXISTS "${FTOPTION_H_NAME}")
@@ -439,6 +453,12 @@ if (HARFBUZZ_FOUND)
target_include_directories(freetype PRIVATE ${HARFBUZZ_INCLUDE_DIRS})
list(APPEND PKG_CONFIG_REQUIRED_PRIVATE "harfbuzz >= ${HARFBUZZ_MIN_VERSION}")
endif ()
+if (BROTLIDEC_FOUND)
+ target_link_libraries(freetype PRIVATE ${BROTLIDEC_LIBRARIES})
+ target_compile_definitions(freetype PRIVATE ${BROTLIDEC_DEFINITIONS})
+ target_include_directories(freetype PRIVATE ${BROTLIDEC_INCLUDE_DIRS})
+ list(APPEND PKG_CONFIG_REQUIRED_PRIVATE "libbrotlidec")
+endif ()
# Installation
diff --git a/ChangeLog b/ChangeLog
index 5298252..cb0335a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2019-09-05 Werner Lemberg <wl@gnu.org>
+ [cmake] Add brotli support.
+
+ * CMakeLists.txt (FT_WITH_BROTLI): New option.
+
+ * builds/cmake/FindBrotliDec.cmake: New file.
+
+2019-09-05 Werner Lemberg <wl@gnu.org>
+
Fix handling of `AF_CONFIG_OPTION_INDIC'.
* devel/ftoption.h, include/freetype/config/ftoption.h:
diff --git a/builds/cmake/FindBrotliDec.cmake b/builds/cmake/FindBrotliDec.cmake
new file mode 100644
index 0000000..b3df17a
--- /dev/null
+++ b/builds/cmake/FindBrotliDec.cmake
@@ -0,0 +1,51 @@
+# FindBrotliDec.cmake
+#
+# Copyright (C) 2019 by
+# David Turner, Robert Wilhelm, and Werner Lemberg.
+#
+# Written by Werner Lemberg <wl@gnu.org>
+#
+# This file is part of the FreeType project, and may only be used, modified,
+# and distributed under the terms of the FreeType project license,
+# LICENSE.TXT. By continuing to use, modify, or distribute this file you
+# indicate that you have read the license and understand and accept it
+# fully.
+#
+#
+# Try to find libbrotlidec include and library directories.
+#
+# If found, the following variables are set.
+#
+# BROTLIDEC_INCLUDE_DIRS
+# BROTLIDEC_LIBRARIES
+
+include(FindPkgConfig)
+pkg_check_modules(PC_BROTLIDEC QUIET libbrotlidec)
+
+if (PC_BROTLIDEC_VERSION)
+ set(BROTLIDEC_VERSION "${PC_BROTLIDEC_VERSION}")
+endif ()
+
+
+find_path(BROTLIDEC_INCLUDE_DIRS
+ NAMES brotli/decode.h
+ HINTS ${PC_BROTLIDEC_INCLUDEDIR}
+ ${PC_BROTLIDEC_INCLUDE_DIRS}
+ PATH_SUFFIXES brotli)
+
+find_library(BROTLIDEC_LIBRARIES
+ NAMES brotlidec
+ HINTS ${PC_BROTLIDEC_LIBDIR}
+ ${PC_BROTLIDEC_LIBRARY_DIRS})
+
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(
+ brotlidec
+ REQUIRED_VARS BROTLIDEC_INCLUDE_DIRS BROTLIDEC_LIBRARIES
+ FOUND_VAR BROTLIDEC_FOUND
+ VERSION_VAR BROTLIDEC_VERSION)
+
+mark_as_advanced(
+ BROTLIDEC_INCLUDE_DIRS
+ BROTLIDEC_LIBRARIES)