Skip to content

Commit

Permalink
[freetype] Make zlib and brotli features (#14917)
Browse files Browse the repository at this point in the history
  • Loading branch information
LRFLEW authored Dec 10, 2020
1 parent d5e6bd5 commit c309037
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 20 deletions.
13 changes: 10 additions & 3 deletions ports/freetype/CONTROL
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
10 changes: 8 additions & 2 deletions ports/freetype/fix-exports.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
Expand Down
14 changes: 12 additions & 2 deletions ports/freetype/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}
)
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand Down
39 changes: 26 additions & 13 deletions ports/freetype/vcpkg-cmake-wrapper.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
_find_package(${ARGS})

find_package(ZLIB)
if(@USE_ZLIB@)
find_package(ZLIB)
endif()

if(@USE_BZIP2@)
find_package(BZip2)
Expand All @@ -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)
Expand All @@ -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})
Expand All @@ -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()

0 comments on commit c309037

Please sign in to comment.