From f05560d8125ff7bea31af4ef4e0432bf57b87eab Mon Sep 17 00:00:00 2001 From: Alexander Neumann <30894796+Neumann-A@users.noreply.github.com> Date: Mon, 27 Apr 2020 15:56:50 +0200 Subject: [PATCH] [libarchive] expose zstd as a build feature (#11044) * [libarchive] add zlib and zstd to wrapper and expose zstd as a build feature. * bump control --- ports/libarchive/CONTROL | 8 +++++-- ports/libarchive/portfile.cmake | 16 ++++++++----- ports/libarchive/vcpkg-cmake-wrapper.cmake | 26 ++++++++++++++++++++++ 3 files changed, 42 insertions(+), 8 deletions(-) diff --git a/ports/libarchive/CONTROL b/ports/libarchive/CONTROL index dc53b2e8296e97..425c2c72c065ac 100644 --- a/ports/libarchive/CONTROL +++ b/ports/libarchive/CONTROL @@ -1,15 +1,19 @@ Source: libarchive -Version: 3.4.1-1 +Version: 3.4.1-2 Homepage: https://github.com/libarchive/libarchive Description: Library for reading and writing streaming archives Build-Depends: zlib -Default-Features: bzip2, libxml2, lz4, lzma, lzo, openssl +Default-Features: bzip2, libxml2, lz4, lzma, lzo, openssl, zstd Supports: !uwp Feature: bzip2 Build-Depends: bzip2 Description: BZip2 support +Feature: zstd +Build-Depends: zstd +Description: zstd support + Feature: libxml2 Build-Depends: libxml2 Description: Libxml2 support diff --git a/ports/libarchive/portfile.cmake b/ports/libarchive/portfile.cmake index 1fdc3a1632af2a..82834f5d03c148 100644 --- a/ports/libarchive/portfile.cmake +++ b/ports/libarchive/portfile.cmake @@ -21,18 +21,20 @@ vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS lzma ENABLE_LZMA lzo ENABLE_LZO openssl ENABLE_OPENSSL + zstd ENABLE_ZSTD # The below features should be added to CONTROL #pcre ENABLE_PCREPOSIX #nettle ENABLE_NETTLE #expat ENABLE_EXPAT #libgcc ENABLE_LibGCC #cng ENABLE_CNG - #tar ENABLE_TAR - #cpio ENABLE_CPIO - #cat ENABLE_CAT - #xattr ENABLE_XATTR - #acl ENABLE_ACL - #iconv ENABLE_ICONV + #tar ENABLE_TAR # Tool build option? + #cpio ENABLE_CPIO # Tool build option? + #cat ENABLE_CAT # Tool build option? + #xattr ENABLE_XATTR # Tool support option? + #acl ENABLE_ACL # Tool support option? + #iconv ENABLE_ICONV # iconv support option? + #libb2 ENABLE_LIBB2 ) if(FEATURES MATCHES "pcre") @@ -40,6 +42,8 @@ else() list(APPEND FEATURE_OPTIONS -DPOSIX_REGEX_LIB=NONE) endif() +list(APPEND FEATURE_OPTIONS -DENABLE_ZLIB=ON) + vcpkg_configure_cmake( SOURCE_PATH ${SOURCE_PATH} PREFER_NINJA diff --git a/ports/libarchive/vcpkg-cmake-wrapper.cmake b/ports/libarchive/vcpkg-cmake-wrapper.cmake index c7e47ea901011d..c7b951a3910e71 100644 --- a/ports/libarchive/vcpkg-cmake-wrapper.cmake +++ b/ports/libarchive/vcpkg-cmake-wrapper.cmake @@ -1,6 +1,10 @@ _find_package(${ARGS}) if("@VCPKG_LIBRARY_LINKAGE@" STREQUAL "static") + if(@ENABLE_ZLIB@) + find_package(ZLIB REQUIRED) + list(APPEND LibArchive_LIBRARIES ZLIB::ZLIB) + endif() if(@ENABLE_BZip2@) find_package(BZip2 REQUIRED) list(APPEND LibArchive_LIBRARIES BZip2::BZip2) @@ -27,6 +31,16 @@ if("@VCPKG_LIBRARY_LINKAGE@" STREQUAL "static") list(APPEND LibArchive_LIBRARIES debug ${LZO_LIBRARY_DEBUG}) endif() endif() + if(@ENABLE_ZSTD@) + find_library(ZSTD_LIBRARY_DEBUG NAMES zstdd zstd NAMES_PER_DIR PATH_SUFFIXES lib PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug" NO_DEFAULT_PATH) + find_library(ZSTD_LIBRARY_RELEASE NAMES zstd NAMES_PER_DIR PATH_SUFFIXES lib PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}" NO_DEFAULT_PATH) + if(ZSTD_LIBRARY_RELEASE) + list(APPEND LibArchive_LIBRARIES optimized ${ZSTD_LIBRARY_RELEASE}) + endif() + if(ZSTD_LIBRARY_DEBUG) + list(APPEND LibArchive_LIBRARIES debug ${ZSTD_LIBRARY_DEBUG}) + endif() + endif() if(@ENABLE_OPENSSL@) find_package(OpenSSL REQUIRED) list(APPEND LibArchive_LIBRARIES OpenSSL::Crypto) @@ -36,6 +50,9 @@ if("@VCPKG_LIBRARY_LINKAGE@" STREQUAL "static") if(@ENABLE_BZip2@) target_link_libraries(LibArchive::LibArchive INTERFACE BZip2::BZip2) endif() + if(@ENABLE_ZLIB@) + target_link_libraries(LibArchive::LibArchive INTERFACE ZLIB::ZLIB) + endif() if(@ENABLE_LIBXML2@) target_link_libraries(LibArchive::LibArchive INTERFACE LibXml2::LibXml2) endif() @@ -54,6 +71,15 @@ if("@VCPKG_LIBRARY_LINKAGE@" STREQUAL "static") endif() set_property(TARGET LibArchive::LibArchive APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${interface_lib}) endif() + if(@ENABLE_ZSTD@) + if(ZSTD_LIBRARY_RELEASE) + list(APPEND interface_lib \$<\$>:${ZSTD_LIBRARY_RELEASE}>) + endif() + if(ZSTD_LIBRARY_DEBUG) + list(APPEND interface_lib \$<\$:${ZSTD_LIBRARY_DEBUG}>) + endif() + set_property(TARGET LibArchive::LibArchive APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${interface_lib}) + endif() if(@ENABLE_OPENSSL@) target_link_libraries(LibArchive::LibArchive INTERFACE OpenSSL::Crypto) endif()