Skip to content

Commit

Permalink
[libarchive] expose zstd as a build feature (#11044)
Browse files Browse the repository at this point in the history
* [libarchive] add zlib and zstd to wrapper and expose zstd as a build feature.

* bump control
  • Loading branch information
Neumann-A authored Apr 27, 2020
1 parent 657becf commit f05560d
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 8 deletions.
8 changes: 6 additions & 2 deletions ports/libarchive/CONTROL
Original file line number Diff line number Diff line change
@@ -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
Expand Down
16 changes: 10 additions & 6 deletions ports/libarchive/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,29 @@ 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")
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
Expand Down
26 changes: 26 additions & 0 deletions ports/libarchive/vcpkg-cmake-wrapper.cmake
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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)
Expand All @@ -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()
Expand All @@ -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 \$<\$<NOT:\$<CONFIG:DEBUG>>:${ZSTD_LIBRARY_RELEASE}>)
endif()
if(ZSTD_LIBRARY_DEBUG)
list(APPEND interface_lib \$<\$<CONFIG:DEBUG>:${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()
Expand Down

0 comments on commit f05560d

Please sign in to comment.