From d55546a5bf05ac68cecc7401e211b2ba2e5dbe7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dawid=20Wr=C3=B3bel?= Date: Wed, 1 Sep 2021 20:19:07 +0200 Subject: [PATCH] [kf5archive] fix cmake.in to allow consumption by static builds (#19194) * [kf5archive] fix cmake.in to allow consumption by static builds * [kf5archive] update versions * [kf5archive] add lzma, zstd features * [kf5archive] update versions * [kf5archive] fix MAYBE_UNUSED_VARIABLES usage * [kf5archive] replace deprecated functions * [kf5archive] use semVer * [kf5archive] update versions * [kf5archive] add vcpkg_check_features * [kf5archive] update versions * [kf5archive] remove redundant option Co-authored-by: NancyLi1013 <46708020+NancyLi1013@users.noreply.github.com> * [kf5archive] wrap all paths in quotes * [kf5archive] update versions * [kf5archive] lookup ZSTD using CMake * [kf5archive] update versions * [kf5archive] fix vcpkg_cmake_config_fixup() usage * [kf5archive] update versions * [kf5archive] rename patch files * [kf5archive] update versions Co-authored-by: NancyLi1013 <46708020+NancyLi1013@users.noreply.github.com> --- .../add_support_for_static_builds.patch | 46 +++++++++++++++++ .../kf5archive/add_zstd_to_cmake_config.patch | 26 ++++++++++ ...pkg_check_modules_if_pkgconfig_found.patch | 27 ++++++++++ ports/kf5archive/portfile.cmake | 32 +++++++----- ports/kf5archive/use_cmake_to_find_zstd.patch | 49 +++++++++++++++++++ ports/kf5archive/vcpkg.json | 27 +++++++++- versions/baseline.json | 2 +- versions/k-/kf5archive.json | 5 ++ 8 files changed, 199 insertions(+), 15 deletions(-) create mode 100644 ports/kf5archive/add_support_for_static_builds.patch create mode 100644 ports/kf5archive/add_zstd_to_cmake_config.patch create mode 100644 ports/kf5archive/only_pkg_check_modules_if_pkgconfig_found.patch create mode 100644 ports/kf5archive/use_cmake_to_find_zstd.patch diff --git a/ports/kf5archive/add_support_for_static_builds.patch b/ports/kf5archive/add_support_for_static_builds.patch new file mode 100644 index 0000000000..7ad973d393 --- /dev/null +++ b/ports/kf5archive/add_support_for_static_builds.patch @@ -0,0 +1,46 @@ +From 5dc3f846c27ee6d55131db475975e3c24cd0c19c Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Dawid=20Wro=CC=81bel?= +Date: Wed, 28 Jul 2021 11:39:30 +0200 +Subject: [PATCH] Add support for static builds + +--- + KF5ArchiveConfig.cmake.in | 20 ++++++++++++++++++++ + 1 file changed, 20 insertions(+) + +diff --git a/KF5ArchiveConfig.cmake.in b/KF5ArchiveConfig.cmake.in +index 3d32642..0a738c2 100644 +--- a/KF5ArchiveConfig.cmake.in ++++ b/KF5ArchiveConfig.cmake.in +@@ -4,9 +4,29 @@ include(CMakeFindDependencyMacro) + find_dependency(Qt5Core @REQUIRED_QT_VERSION@) + + ++set(KArchive_HAVE_ZLIB "@ZLIB_FOUND@") + set(KArchive_HAVE_BZIP2 "@BZIP2_FOUND@") + set(KArchive_HAVE_LZMA "@LIBLZMA_FOUND@") + set(KArchive_HAVE_ZSTD "@LibZstd_FOUND@") + ++if (NOT @BUILD_SHARED_LIBS@) ++ if (@ZLIB_FOUND@) ++ find_dependency(ZLIB) ++ endif() ++ ++ if (@BZIP2_FOUND@) ++ find_dependency(BZip2) ++ endif() ++ ++ if (@LIBLZMA_FOUND@) ++ find_dependency(LibLZMA) ++ endif() ++ ++ if (@LibZstd_FOUND@) ++ find_package(PkgConfig) ++ pkg_check_modules(LibZstd IMPORTED_TARGET "libzstd") ++ endif() ++endif() ++ + include("${CMAKE_CURRENT_LIST_DIR}/KF5ArchiveTargets.cmake") + @PACKAGE_INCLUDE_QCHTARGETS@ +-- +GitLab + diff --git a/ports/kf5archive/add_zstd_to_cmake_config.patch b/ports/kf5archive/add_zstd_to_cmake_config.patch new file mode 100644 index 0000000000..8b960bb4f0 --- /dev/null +++ b/ports/kf5archive/add_zstd_to_cmake_config.patch @@ -0,0 +1,26 @@ +From 5a79756f381e1a1843cb2171bdc151dad53fb7db Mon Sep 17 00:00:00 2001 +From: "Friedrich W. H. Kossebau" +Date: Wed, 7 Jul 2021 03:09:38 +0200 +Subject: [PATCH] Report KArchive_HAVE_ZSTD in CMake Config file to consumers + +Allows users of KArchive to query whether zstd is available, +in the same way as lzma & bzip2 +--- + KF5ArchiveConfig.cmake.in | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/KF5ArchiveConfig.cmake.in b/KF5ArchiveConfig.cmake.in +index 0d59d63..3d32642 100644 +--- a/KF5ArchiveConfig.cmake.in ++++ b/KF5ArchiveConfig.cmake.in +@@ -6,6 +6,7 @@ find_dependency(Qt5Core @REQUIRED_QT_VERSION@) + + set(KArchive_HAVE_BZIP2 "@BZIP2_FOUND@") + set(KArchive_HAVE_LZMA "@LIBLZMA_FOUND@") ++set(KArchive_HAVE_ZSTD "@LibZstd_FOUND@") + + include("${CMAKE_CURRENT_LIST_DIR}/KF5ArchiveTargets.cmake") + @PACKAGE_INCLUDE_QCHTARGETS@ +-- +GitLab + diff --git a/ports/kf5archive/only_pkg_check_modules_if_pkgconfig_found.patch b/ports/kf5archive/only_pkg_check_modules_if_pkgconfig_found.patch new file mode 100644 index 0000000000..f3db3a4fb7 --- /dev/null +++ b/ports/kf5archive/only_pkg_check_modules_if_pkgconfig_found.patch @@ -0,0 +1,27 @@ +From 9ab5f2bfbe59038b0d0b6ca7f1b22d1c9229c67e Mon Sep 17 00:00:00 2001 +From: Dawid Wrobel +Date: Fri, 30 Jul 2021 10:23:48 +0000 +Subject: [PATCH] Only pkg_check_modules() if PkgConfig is found + +--- + CMakeLists.txt | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index bab7661..2cdda70 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -45,7 +45,9 @@ set_package_properties(LibLZMA PROPERTIES + ) + + find_package(PkgConfig) +-pkg_check_modules(LibZstd IMPORTED_TARGET "libzstd") ++if (PkgConfig_FOUND) ++ pkg_check_modules(LibZstd IMPORTED_TARGET "libzstd") ++endif() + add_feature_info(LibZstd LibZstd_FOUND + "Support for zstd compressed files and data streams" + ) +-- +GitLab + diff --git a/ports/kf5archive/portfile.cmake b/ports/kf5archive/portfile.cmake index c9a8e499dc..479b4496f0 100644 --- a/ports/kf5archive/portfile.cmake +++ b/ports/kf5archive/portfile.cmake @@ -4,30 +4,38 @@ vcpkg_from_github( REF v5.84.0 SHA512 82926f62424446df0f4fc300f57ae9bd5baf8e13da2ce4135ac56c0c52a0307bffb06f84ac7e8e658e96ace2ae3d530f27e232061284ac87271404f218e9fdd4 HEAD_REF master + PATCHES + only_pkg_check_modules_if_pkgconfig_found.patch # https://invent.kde.org/frameworks/karchive/-/commit/9ab5f2bfbe59038b0d0b6ca7f1b22d1c9229c67e + add_zstd_to_cmake_config.patch # https://invent.kde.org/frameworks/karchive/-/commit/5a79756f381e1a1843cb2171bdc151dad53fb7db + add_support_for_static_builds.patch # https://invent.kde.org/frameworks/karchive/-/merge_requests/23 + use_cmake_to_find_zstd.patch # https://invent.kde.org/frameworks/karchive/-/merge_requests/24 ) -vcpkg_configure_cmake( +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + INVERTED_FEATURES + "lzma" CMAKE_DISABLE_FIND_PACKAGE_LibLZMA + "zstd" CMAKE_DISABLE_FIND_PACKAGE_ZSTD +) + +vcpkg_cmake_configure( DISABLE_PARALLEL_CONFIGURE SOURCE_PATH ${SOURCE_PATH} - PREFER_NINJA OPTIONS - -DBUILD_HTML_DOCS=OFF - -DBUILD_MAN_DOCS=OFF - -DBUILD_QTHELP_DOCS=OFF -DBUILD_TESTING=OFF + ${FEATURE_OPTIONS} ) -vcpkg_install_cmake() -vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake/KF5Archive) +vcpkg_cmake_install() +vcpkg_cmake_config_fixup(PACKAGE_NAME KF5Archive CONFIG_PATH lib/cmake/KF5Archive) vcpkg_copy_pdbs() if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin") endif() -file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) -file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/etc) -file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/etc) -file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share) +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/etc") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/etc") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") -file(INSTALL ${SOURCE_PATH}/LICENSES/ DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright) +file(INSTALL "${SOURCE_PATH}/LICENSES/" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright") diff --git a/ports/kf5archive/use_cmake_to_find_zstd.patch b/ports/kf5archive/use_cmake_to_find_zstd.patch new file mode 100644 index 0000000000..ee7dfd555b --- /dev/null +++ b/ports/kf5archive/use_cmake_to_find_zstd.patch @@ -0,0 +1,49 @@ +From 82fc20234d4cf8abdec1a2b4fea9823154f1aecc Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Dawid=20Wro=CC=81bel?= +Date: Fri, 27 Aug 2021 01:48:53 +0200 +Subject: [PATCH] Use CMake to find ZSTD + +--- + CMakeLists.txt | 11 +++++------ + KF5ArchiveConfig.cmake.in | 3 +-- + 2 files changed, 6 insertions(+), 8 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 8ab85f4..ece1f77 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -44,12 +44,11 @@ set_package_properties(LibLZMA PROPERTIES + PURPOSE "Support for xz compressed files and data streams" + ) + +-find_package(PkgConfig) +-if (PkgConfig_FOUND) +- pkg_check_modules(LibZstd IMPORTED_TARGET "libzstd") +-endif() +-add_feature_info(LibZstd LibZstd_FOUND +- "Support for zstd compressed files and data streams" ++find_package(ZSTD) ++set_package_properties(LibZstd PROPERTIES ++ URL "http://www.zstd.net" ++ DESCRIPTION "Support for zstd compressed files and data streams" ++ PURPOSE "Support for zstd compressed files and data streams" + ) + + include(ECMSetupVersion) +diff --git a/KF5ArchiveConfig.cmake.in b/KF5ArchiveConfig.cmake.in +index 0a738c2..d868324 100644 +--- a/KF5ArchiveConfig.cmake.in ++++ b/KF5ArchiveConfig.cmake.in +@@ -23,8 +23,7 @@ if (NOT @BUILD_SHARED_LIBS@) + endif() + + if (@LibZstd_FOUND@) +- find_package(PkgConfig) +- pkg_check_modules(LibZstd IMPORTED_TARGET "libzstd") ++ find_dependency(ZSTD) + endif() + endif() + +-- +GitLab + diff --git a/ports/kf5archive/vcpkg.json b/ports/kf5archive/vcpkg.json index 9cc00aa03d..2ece7aa506 100644 --- a/ports/kf5archive/vcpkg.json +++ b/ports/kf5archive/vcpkg.json @@ -1,12 +1,35 @@ { "name": "kf5archive", - "version": "5.84.0", + "version-semver": "5.84.0", + "port-version": 1, "description": "File compression", "homepage": "https://api.kde.org/frameworks/karchive/html/index.html", "dependencies": [ "bzip2", "ecm", "qt5-base", + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + }, "zlib" - ] + ], + "features": { + "lzma": { + "description": "Support for xz compressed files and data streams", + "dependencies": [ + "liblzma" + ] + }, + "zstd": { + "description": "Support for zstd compressed files and data streams", + "dependencies": [ + "zstd" + ] + } + } } diff --git a/versions/baseline.json b/versions/baseline.json index 04d23ca35e..15aed3900b 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -2882,7 +2882,7 @@ }, "kf5archive": { "baseline": "5.84.0", - "port-version": 0 + "port-version": 1 }, "kf5attica": { "baseline": "5.84.0", diff --git a/versions/k-/kf5archive.json b/versions/k-/kf5archive.json index bb5f443c99..068b74c7a5 100644 --- a/versions/k-/kf5archive.json +++ b/versions/k-/kf5archive.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "03f6943556e1d7600443c1f30445560de3f9b2f7", + "version-semver": "5.84.0", + "port-version": 1 + }, { "git-tree": "bc7b88da4daf014c751e4ab246a0104d850f5785", "version": "5.84.0",