vcpkg/ports/libarchive/vcpkg-cmake-wrapper.cmake.in
Kai Pastor 845a5fda11
[libarchive,lz4] Fix pc file, modernize portfile (#20146)
* Fix pc file

* Modernize portfile

* OpenSSL unused on 'Darwin'

* x-add-version

* More port cleanup (CR requests)

* Revise wrapper, using find_package

* Don't use pkgconfig modules for windows openssl

* Update versions

* Use namespaced variables for custom lzo lookup

* Wrapper needs CMP0012

* Skip dependencies if not LibArchive_FOUND

* Update versions

* Fix liblz4.pc debug lib fixup

* Update versions

Co-authored-by: NancyLi1013 <lirui09@beyondsoft.com>
2021-09-24 12:06:17 -07:00

66 lines
2.6 KiB
CMake

cmake_policy(PUSH)
cmake_policy(SET CMP0012 NEW)
cmake_policy(SET CMP0057 NEW)
set(z_vcpkg_libarchive_args "")
if("REQUIRED" IN_LIST ARGS)
list(APPEND z_vcpkg_libarchive_args "REQUIRED")
endif()
if("QUIET" IN_LIST ARGS)
list(APPEND z_vcpkg_libarchive_args "QUIET")
endif()
_find_package(${ARGS})
if(LibArchive_FOUND AND "@VCPKG_LIBRARY_LINKAGE@" STREQUAL "static")
set(z_vcpkg_libarchive_libs "")
find_package(ZLIB ${z_vcpkg_libarchive_args})
list(APPEND z_vcpkg_libarchive_libs ZLIB::ZLIB)
if(@ENABLE_BZip2@)
find_package(BZip2 ${z_vcpkg_libarchive_args})
list(APPEND z_vcpkg_libarchive_libs BZip2::BZip2)
endif()
if(@ENABLE_LIBXML2@)
find_package(LibXml2 ${z_vcpkg_libarchive_args})
list(APPEND z_vcpkg_libarchive_libs LibXml2::LibXml2)
endif()
if(@ENABLE_LZ4@)
find_package(lz4 CONFIG ${z_vcpkg_libarchive_args})
list(APPEND z_vcpkg_libarchive_libs lz4::lz4)
endif()
if(@ENABLE_LZMA@)
find_package(LibLZMA ${z_vcpkg_libarchive_args})
list(APPEND z_vcpkg_libarchive_libs LibLZMA::LibLZMA)
endif()
if(@ENABLE_LZO@)
include(SelectLibraryConfigurations)
find_library(Z_VCPKG_LZO_LIBRARY_DEBUG NAMES lzo2d lzo2 PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/lib" NO_DEFAULT_PATH)
find_library(Z_VCPKG_LZO_LIBRARY_RELEASE NAMES lzo2 PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib" NO_DEFAULT_PATH)
select_library_configurations(Z_VCPKG_LZO)
if(Z_VCPKG_LZO_LIBRARY)
list(APPEND z_vcpkg_libarchive_libs ${Z_VCPKG_LZO_LIBRARY})
else()
set(LibArchive_FOUND FALSE)
endif()
endif()
if(@ENABLE_ZSTD@)
find_package(zstd ${z_vcpkg_libarchive_args})
if(TARGET zstd::libzstd_shared)
list(APPEND z_vcpkg_libarchive_libs zstd::libzstd_shared)
else(TARGET zstd::libzstd_shared)
list(APPEND z_vcpkg_libarchive_libs zstd::libzstd_static)
endif(TARGET zstd::libzstd_shared)
endif()
if(@ENABLE_OPENSSL@ AND NOT CMAKE_SYSTEM_NAME MATCHES "Darwin")
find_package(OpenSSL ${z_vcpkg_libarchive_args})
list(APPEND z_vcpkg_libarchive_libs OpenSSL::Crypto)
endif()
list(APPEND LibArchive_LIBRARIES ${z_vcpkg_libarchive_libs})
if(TARGET LibArchive::LibArchive)
set_property(TARGET LibArchive::LibArchive APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${z_vcpkg_libarchive_libs})
endif()
unset(z_vcpkg_libarchive_libs)
endif()
unset(z_vcpkg_libarchive_args)
cmake_policy(POP)