[fontconfig] add vcpkg cmake wrapper. (#15144)

* [fontconfig] add vcpkg cmake wrapper.

* fix empty statement in the wrapper

* dont depend on Freetype::Freetype if it is unavailable

* rename wrapper to cmake.in

* Update ports/fontconfig/portfile.cmake

Co-authored-by: ras0219 <533828+ras0219@users.noreply.github.com>

Co-authored-by: ras0219 <533828+ras0219@users.noreply.github.com>
This commit is contained in:
Alexander Neumann 2021-01-11 09:27:46 +01:00 committed by GitHub
parent 13293851e3
commit 6b2f51fc7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 54 additions and 3 deletions

View File

@ -1,6 +1,6 @@
Source: fontconfig Source: fontconfig
Version: 2.13.1 Version: 2.13.1
Port-Version: 2 Port-Version: 3
Homepage: https://www.freedesktop.org/software/fontconfig/front.html Homepage: https://www.freedesktop.org/software/fontconfig/front.html
Description: Library for configuring and customizing font access. Description: Library for configuring and customizing font access.
Build-Depends: freetype, expat, libiconv, dirent, pthread, json-c, dirent, libuuid (!windows&!osx), gettext Build-Depends: freetype, expat, libiconv, dirent, pthread, json-c, dirent, libuuid (!windows&!osx), gettext

View File

@ -45,7 +45,7 @@ vcpkg_configure_make(
vcpkg_install_make(ADD_BIN_TO_PATH) vcpkg_install_make(ADD_BIN_TO_PATH)
vcpkg_copy_pdbs() vcpkg_copy_pdbs()
vcpkg_fixup_pkgconfig(SYSTEM_LIBRARIES uuid) vcpkg_fixup_pkgconfig()
# Fix paths in debug pc file. # Fix paths in debug pc file.
set(_file "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/fontconfig.pc") set(_file "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/fontconfig.pc")
@ -98,4 +98,9 @@ endif()
if(VCPKG_TARGET_IS_WINDOWS) if(VCPKG_TARGET_IS_WINDOWS)
# Unnecessary make rule creating the fontconfig cache dir on windows. # Unnecessary make rule creating the fontconfig cache dir on windows.
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}LOCAL_APPDATA_FONTCONFIG_CACHE") file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}LOCAL_APPDATA_FONTCONFIG_CACHE")
endif() endif()
if(NOT VCPKG_TARGET_IS_LINUX)
set(VCPKG_TARGET_IS_LINUX 0) # To not leave empty AND statements in the wrapper
endif()
configure_file("${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake.in" "${CURRENT_PACKAGES_DIR}/share/${PORT}/vcpkg-cmake-wrapper.cmake" @ONLY)

View File

@ -0,0 +1,46 @@
_find_package(${ARGS})
if(Fontconfig_FOUND) # theoretically this could be skipped. If the wrapper is installed it should be found!
find_package(Freetype)
if(Freetype_FOUND AND TARGET Fontconfig::Fontconfig)
if(TARGET Freetype::Freetype)
set_property(TARGET Fontconfig::Fontconfig APPEND PROPERTY INTERFACE_LINK_LIBRARIES "Freetype::Freetype")
else()
# TODO link Freetype libraries to the target if the target Freetype::Freetype is not defined;
endif()
endif()
if(FREETYPE_LIBRARIES)
list(APPEND Fontconfig_LIBRARIES "${FREETYPE_LIBRARIES}")
endif()
find_package(EXPAT)
if(EXPAT_FOUND AND TARGET Fontconfig::Fontconfig)
set_property(TARGET Fontconfig::Fontconfig APPEND PROPERTY INTERFACE_LINK_LIBRARIES "EXPAT::EXPAT")
endif()
if(EXPAT_LIBRARIES)
list(APPEND Fontconfig_LIBRARIES "${EXPAT_LIBRARIES}")
endif()
include(SelectLibraryConfigurations)
find_library(Fontconfig_LIBRARY_DEBUG NAMES fontconfig fontconfigd NAMES_PER_DIR PATH_SUFFIXES lib PATHS "${_INSTALLED_DIR}/debug" NO_DEFAULT_PATH)
find_library(Fontconfig_LIBRARY_RELEASE NAMES fontconfig NAMES_PER_DIR PATH_SUFFIXES lib PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}" NO_DEFAULT_PATH)
select_library_configurations(Fontconfig)
if(@VCPKG_TARGET_IS_LINUX@)
find_library(UUID_LIBRARY_DEBUG NAMES uuid uuidd uuid_d NAMES_PER_DIR PATH_SUFFIXES lib PATHS "${_INSTALLED_DIR}/debug" NO_DEFAULT_PATH)
find_library(UUID_LIBRARY_RELEASE NAMES uuid NAMES_PER_DIR PATH_SUFFIXES lib PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}" NO_DEFAULT_PATH)
select_library_configurations(UUID)
endif()
if(Fontconfig_LIBRARY_DEBUG AND TARGET Fontconfig::Fontconfig)
set_target_properties(Fontconfig::Fontconfig PROPERTIES IMPORTED_LOCATION_DEBUG "${Fontconfig_LIBRARY_DEBUG}")
if(UUID_LIBRARY_DEBUG AND @VCPKG_TARGET_IS_LINUX@)
set_property(TARGET Fontconfig::Fontconfig APPEND PROPERTY INTERFACE_LINK_LIBRARIES "$<$<CONFIG:DEBUG>:${UUID_LIBRARY_DEBUG}>")
endif()
endif()
if(Fontconfig_LIBRARY_RELEASE AND TARGET Fontconfig::Fontconfig)
set_target_properties(Fontconfig::Fontconfig PROPERTIES IMPORTED_LOCATION_RELEASE "${Fontconfig_LIBRARY_RELEASE}")
if(UUID_LIBRARY_RELEASE AND @VCPKG_TARGET_IS_LINUX@)
set_property(TARGET Fontconfig::Fontconfig APPEND PROPERTY INTERFACE_LINK_LIBRARIES "$<$<NOT:$<CONFIG:DEBUG>>:${UUID_LIBRARY_RELEASE}>")
endif()
endif()
if(UUID_LIBRARIES AND @VCPKG_TARGET_IS_LINUX@)
list(APPEND Fontconfig_LIBRARIES "${UUID_LIBRARIES}")
endif()
endif()