[freetype] Make zlib and brotli features (#14917)

This commit is contained in:
LRFLEW 2020-12-10 15:25:00 -06:00 committed by GitHub
parent d5e6bd5186
commit c30903782c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 56 additions and 20 deletions

View File

@ -1,10 +1,13 @@
Source: freetype
Version: 2.10.2
Port-Version: 5
Build-Depends: zlib, brotli
Port-Version: 6
Homepage: https://www.freetype.org/
Description: A library to render fonts.
Default-Features: bzip2, png
Default-Features: zlib, bzip2, png, brotli
Feature: zlib
Build-Depends: zlib
Description: Use zlib instead of internal library for DEFLATE
Feature: bzip2
Build-Depends: bzip2
@ -13,3 +16,7 @@ Description: Support bzip2 compressed fonts.
Feature: png
Build-Depends: libpng
Description: Support PNG compressed OpenType embedded bitmaps.
Feature: brotli
Build-Depends: brotli
Description: Support decompression of WOFF2 streams

View File

@ -11,18 +11,24 @@ index 04ce73a..ee3cc05 100644
target_include_directories(freetype PRIVATE ${ZLIB_INCLUDE_DIRS})
list(APPEND PKG_CONFIG_REQUIRED_PRIVATE "zlib")
endif ()
@@ -562,8 +562,15 @@ if (NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL)
@@ -562,8 +562,21 @@ if (NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL)
install(
EXPORT freetype-targets
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/freetype
- FILE freetype-config.cmake
COMPONENT headers)
+
+ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/freetype-config.cmake"
+ if(ZLIB_FOUND)
+ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/freetype-config.cmake"
+[[include(CMakeFindDependencyMacro)
+find_dependency(ZLIB)
+include("${CMAKE_CURRENT_LIST_DIR}/freetype-targets.cmake")
+]])
+ else()
+ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/freetype-config.cmake"
+[[include("${CMAKE_CURRENT_LIST_DIR}/freetype-targets.cmake")
+]])
+ endif()
+
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/freetype-config.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/freetype)
endif ()

View File

@ -16,19 +16,21 @@ vcpkg_from_sourceforge(
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
zlib FT_WITH_ZLIB
bzip2 FT_WITH_BZIP2
png FT_WITH_PNG
brotli FT_WITH_BROTLI
INVERTED_FEATURES
zlib CMAKE_DISABLE_FIND_PACKAGE_ZLIB
bzip2 CMAKE_DISABLE_FIND_PACKAGE_BZip2
png CMAKE_DISABLE_FIND_PACKAGE_PNG
brotli CMAKE_DISABLE_FIND_PACKAGE_BrotliDec
)
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
OPTIONS
-DFT_WITH_ZLIB=ON # Force system zlib.
-DFT_WITH_BROTLI=ON
-DCMAKE_DISABLE_FIND_PACKAGE_HarfBuzz=ON
${FEATURE_OPTIONS}
)
@ -73,6 +75,10 @@ file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share)
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
if("zlib" IN_LIST FEATURES)
set(USE_ZLIB ON)
endif()
if("bzip2" IN_LIST FEATURES)
set(USE_BZIP2 ON)
endif()
@ -81,6 +87,10 @@ if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
set(USE_PNG ON)
endif()
if("brotli" IN_LIST FEATURES)
set(USE_BROTLI ON)
endif()
configure_file(${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake
${CURRENT_PACKAGES_DIR}/share/${PORT}/vcpkg-cmake-wrapper.cmake @ONLY)
endif()

View File

@ -1,6 +1,8 @@
_find_package(${ARGS})
find_package(ZLIB)
if(@USE_ZLIB@)
find_package(ZLIB)
endif()
if(@USE_BZIP2@)
find_package(BZip2)
@ -10,16 +12,20 @@ if(@USE_PNG@)
find_package(PNG)
endif()
find_library(BROTLIDEC_LIBRARY_RELEASE NAMES brotlidec brotlidec-static PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}" PATH_SUFFIXES lib NO_DEFAULT_PATH)
find_library(BROTLIDEC_LIBRARY_DEBUG NAMES brotlidec brotlidec-static brotlidecd brotlidec-staticd PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug" PATH_SUFFIXES lib NO_DEFAULT_PATH)
find_library(BROTLICOMMON_LIBRARY_RELEASE NAMES brotlicommon brotlicommon-static PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}" PATH_SUFFIXES lib NO_DEFAULT_PATH)
find_library(BROTLICOMMON_LIBRARY_DEBUG NAMES brotlicommon brotlicommon-static brotlicommond brotlicommon-staticd PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug" PATH_SUFFIXES lib NO_DEFAULT_PATH)
include(SelectLibraryConfigurations)
select_library_configurations(BROTLIDEC)
select_library_configurations(BROTLICOMMON)
if(@USE_BROTLI@)
find_library(BROTLIDEC_LIBRARY_RELEASE NAMES brotlidec brotlidec-static PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}" PATH_SUFFIXES lib NO_DEFAULT_PATH)
find_library(BROTLIDEC_LIBRARY_DEBUG NAMES brotlidec brotlidec-static brotlidecd brotlidec-staticd PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug" PATH_SUFFIXES lib NO_DEFAULT_PATH)
find_library(BROTLICOMMON_LIBRARY_RELEASE NAMES brotlicommon brotlicommon-static PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}" PATH_SUFFIXES lib NO_DEFAULT_PATH)
find_library(BROTLICOMMON_LIBRARY_DEBUG NAMES brotlicommon brotlicommon-static brotlicommond brotlicommon-staticd PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug" PATH_SUFFIXES lib NO_DEFAULT_PATH)
include(SelectLibraryConfigurations)
select_library_configurations(BROTLIDEC)
select_library_configurations(BROTLICOMMON)
endif(@USE_BROTLI@)
if(TARGET Freetype::Freetype)
set_property(TARGET Freetype::Freetype APPEND PROPERTY INTERFACE_LINK_LIBRARIES ZLIB::ZLIB)
if(@USE_ZLIB@)
set_property(TARGET Freetype::Freetype APPEND PROPERTY INTERFACE_LINK_LIBRARIES ZLIB::ZLIB)
endif()
if(@USE_BZIP2@)
set_property(TARGET Freetype::Freetype APPEND PROPERTY INTERFACE_LINK_LIBRARIES BZip2::BZip2)
@ -28,11 +34,16 @@ if(TARGET Freetype::Freetype)
if(@USE_PNG@)
set_property(TARGET Freetype::Freetype APPEND PROPERTY INTERFACE_LINK_LIBRARIES PNG::PNG)
endif()
target_link_libraries(Freetype::Freetype INTERFACE ${BROTLIDEC_LIBRARIES} ${BROTLICOMMON_LIBRARIES})
if(@USE_BROTLI@)
target_link_libraries(Freetype::Freetype INTERFACE ${BROTLIDEC_LIBRARIES} ${BROTLICOMMON_LIBRARIES})
endif()
endif()
if(FREETYPE_LIBRARIES)
list(APPEND FREETYPE_LIBRARIES ${ZLIB_LIBRARIES})
if(@USE_ZLIB@)
list(APPEND FREETYPE_LIBRARIES ${ZLIB_LIBRARIES})
endif()
if(@USE_BZIP2@)
list(APPEND FREETYPE_LIBRARIES ${BZIP2_LIBRARIES})
@ -41,6 +52,8 @@ if(FREETYPE_LIBRARIES)
if(@USE_PNG@)
list(APPEND FREETYPE_LIBRARIES ${PNG_LIBRARIES})
endif()
list(APPEND FREETYPE_LIBRARIES ${BROTLIDEC_LIBRARIES} ${BROTLICOMMON_LIBRARIES})
if(@USE_BROTLI@)
list(APPEND FREETYPE_LIBRARIES ${BROTLIDEC_LIBRARIES} ${BROTLICOMMON_LIBRARIES})
endif()
endif()