forked from minhngoc25a/freetype2
[cmake] Add brotli support.
* CMakeLists.txt (FT_WITH_BROTLI): New option. * builds/cmake/FindBrotliDec.cmake: New file.
This commit is contained in:
parent
bbb14361db
commit
3de1b8d0b0
|
@ -68,12 +68,14 @@
|
||||||
# . `CMakeLists.txt' is provided as-is since it is normally not used by the
|
# . `CMakeLists.txt' is provided as-is since it is normally not used by the
|
||||||
# developer team.
|
# developer team.
|
||||||
#
|
#
|
||||||
# . Set the `FT_WITH_ZLIB', `FT_WITH_BZIP2', `FT_WITH_PNG', and
|
# . Set the `FT_WITH_ZLIB', `FT_WITH_BZIP2', `FT_WITH_PNG',
|
||||||
# `FT_WITH_HARFBUZZ' CMake variables to `ON' to force using a dependency.
|
# `FT_WITH_HARFBUZZ', and `FT_WITH_BROTLI' CMake variables to `ON' to
|
||||||
# Leave a variable undefined (which is the default) to use the dependency
|
# force using a dependency. Leave a variable undefined (which is the
|
||||||
# only if it is available. Set `CMAKE_DISABLE_FIND_PACKAGE_HarfBuzz=TRUE' to
|
# default) to use the dependency only if it is available. Set
|
||||||
# disable a dependency completely (CMake package name, so `BZip2' instead of
|
# `CMAKE_DISABLE_FIND_PACKAGE_XXX=TRUE' to disable a dependency completely
|
||||||
# `BZIP2'). Example:
|
# (where `XXX' is a CMake package name like `BZip2').
|
||||||
|
#
|
||||||
|
# Example:
|
||||||
#
|
#
|
||||||
# cmake -DFT_WITH_ZLIB=ON -DCMAKE_DISABLE_FIND_PACKAGE_HarfBuzz=TRUE [...]
|
# 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}")
|
math(EXPR LIBRARY_SOVERSION "${LIBTOOL_CURRENT} - ${LIBTOOL_AGE}")
|
||||||
set(LIBRARY_VERSION "${LIBRARY_SOVERSION}.${LIBTOOL_AGE}.${LIBTOOL_REVISION}")
|
set(LIBRARY_VERSION "${LIBRARY_SOVERSION}.${LIBTOOL_AGE}.${LIBTOOL_REVISION}")
|
||||||
|
|
||||||
# These options mean "require x and complain if not found". They'll get
|
# 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
|
# optionally found anyway. Use `-DCMAKE_DISABLE_FIND_PACKAGE_x=TRUE` to
|
||||||
# searching for a packge entirely (x is the CMake package name, so "BZip2"
|
# disable searching for a package entirely (`x' is the CMake package name,
|
||||||
# instead of "BZIP2").
|
# so `BZip2' instead of `BZIP2').
|
||||||
option(FT_WITH_ZLIB "Use system zlib instead of internal library." OFF)
|
option(FT_WITH_ZLIB "Use system zlib instead of internal library." OFF)
|
||||||
option(FT_WITH_BZIP2 "Support bzip2 compressed fonts." OFF)
|
option(FT_WITH_BZIP2 "Support bzip2 compressed fonts." OFF)
|
||||||
option(FT_WITH_PNG "Support PNG compressed OpenType embedded bitmaps." 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_HARFBUZZ "Improve auto-hinting of OpenType fonts." OFF)
|
||||||
|
option(FT_WITH_BROTLI "Support compressed WOFF2 fonts." OFF)
|
||||||
|
|
||||||
|
|
||||||
# Disallow in-source builds
|
# Disallow in-source builds
|
||||||
|
@ -219,6 +222,12 @@ else ()
|
||||||
find_package(BZip2)
|
find_package(BZip2)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
if (FT_WITH_BROTLI)
|
||||||
|
find_package(BrotliDec REQUIRED)
|
||||||
|
else ()
|
||||||
|
find_package(BrotliDec)
|
||||||
|
endif ()
|
||||||
|
|
||||||
# Create the configuration file
|
# Create the configuration file
|
||||||
if (UNIX)
|
if (UNIX)
|
||||||
check_include_file("unistd.h" HAVE_UNISTD_H)
|
check_include_file("unistd.h" HAVE_UNISTD_H)
|
||||||
|
@ -283,6 +292,11 @@ if (HARFBUZZ_FOUND)
|
||||||
"/\\* +(#define +FT_CONFIG_OPTION_USE_HARFBUZZ) +\\*/" "\\1"
|
"/\\* +(#define +FT_CONFIG_OPTION_USE_HARFBUZZ) +\\*/" "\\1"
|
||||||
FTOPTION_H "${FTOPTION_H}")
|
FTOPTION_H "${FTOPTION_H}")
|
||||||
endif ()
|
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")
|
set(FTOPTION_H_NAME "${PROJECT_BINARY_DIR}/include/freetype/config/ftoption.h")
|
||||||
if (EXISTS "${FTOPTION_H_NAME}")
|
if (EXISTS "${FTOPTION_H_NAME}")
|
||||||
|
@ -439,6 +453,12 @@ if (HARFBUZZ_FOUND)
|
||||||
target_include_directories(freetype PRIVATE ${HARFBUZZ_INCLUDE_DIRS})
|
target_include_directories(freetype PRIVATE ${HARFBUZZ_INCLUDE_DIRS})
|
||||||
list(APPEND PKG_CONFIG_REQUIRED_PRIVATE "harfbuzz >= ${HARFBUZZ_MIN_VERSION}")
|
list(APPEND PKG_CONFIG_REQUIRED_PRIVATE "harfbuzz >= ${HARFBUZZ_MIN_VERSION}")
|
||||||
endif ()
|
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
|
# Installation
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
|
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>
|
2019-09-05 Werner Lemberg <wl@gnu.org>
|
||||||
|
|
||||||
Fix handling of `AF_CONFIG_OPTION_INDIC'.
|
Fix handling of `AF_CONFIG_OPTION_INDIC'.
|
||||||
|
|
|
@ -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)
|
Loading…
Reference in New Issue