From 35c086d05011b6018affc5be9146aed507f0dab9 Mon Sep 17 00:00:00 2001 From: Kai Pastor Date: Mon, 13 Sep 2021 22:25:29 +0200 Subject: [PATCH] [lz4] Install pc file, cleanup (#20108) * Drop unused xxhash dependency * Modernize portfile * Install pc file * x-add-version * Switch to 'version' field * Update versions * Fix liblz4 pc file name * Update versions --- ports/lz4/CMakeLists.txt | 8 ++++++++ ports/lz4/portfile.cmake | 35 ++++++++++++++++++++--------------- ports/lz4/vcpkg.json | 13 ++++++++++--- versions/baseline.json | 2 +- versions/l-/lz4.json | 5 +++++ 5 files changed, 44 insertions(+), 19 deletions(-) diff --git a/ports/lz4/CMakeLists.txt b/ports/lz4/CMakeLists.txt index 1e272dd456..142a229006 100644 --- a/ports/lz4/CMakeLists.txt +++ b/ports/lz4/CMakeLists.txt @@ -47,3 +47,11 @@ install(EXPORT lz4Config # Export the package for use from the build-tree (this registers the build-tree with a global CMake-registry) export(PACKAGE lz4) + +# Create pkgconfig module file +file(STRINGS "lib/lz4.h" LZ4_H REGEX "^#define LZ4_VERSION_(MAJOR|MINOR|RELEASE) ") +string(REGEX REPLACE "^.*MAJOR +([0-9]+).*MINOR +([0-9]+).*RELEASE +([0-9]+).*$" "\\1.\\2.\\3" VERSION "${LZ4_H}") +set(INCLUDEDIR [[${prefix}/include]]) +set(LIBDIR [[${prefix}/lib]]) +configure_file(lib/liblz4.pc.in lib/liblz4.pc) +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/lib/liblz4.pc" DESTINATION "lib/pkgconfig") diff --git a/ports/lz4/portfile.cmake b/ports/lz4/portfile.cmake index 9b035c8ae5..63e858ba8b 100644 --- a/ports/lz4/portfile.cmake +++ b/ports/lz4/portfile.cmake @@ -6,30 +6,35 @@ vcpkg_from_github( HEAD_REF dev ) -file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH}) +file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}") -vcpkg_configure_cmake( - SOURCE_PATH ${SOURCE_PATH} - PREFER_NINJA +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" OPTIONS_DEBUG -DCMAKE_DEBUG_POSTFIX=d ) -vcpkg_install_cmake() +vcpkg_cmake_install() vcpkg_copy_pdbs() +if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic") + set(DLL_IMPORT "1 && defined(_MSC_VER)") +else() + set(DLL_IMPORT "0") +endif() foreach(FILE lz4.h lz4frame.h) - file(READ ${CURRENT_PACKAGES_DIR}/include/${FILE} LZ4_HEADER) - if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic") - string(REPLACE "defined(LZ4_DLL_IMPORT) && (LZ4_DLL_IMPORT==1)" "1 && defined(_MSC_VER)" LZ4_HEADER "${LZ4_HEADER}") - else() - string(REPLACE "defined(LZ4_DLL_IMPORT) && (LZ4_DLL_IMPORT==1)" "0" LZ4_HEADER "${LZ4_HEADER}") - endif() - file(WRITE ${CURRENT_PACKAGES_DIR}/include/${FILE} "${LZ4_HEADER}") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/${FILE}" + "defined(LZ4_DLL_IMPORT) && (LZ4_DLL_IMPORT==1)" + "${DLL_IMPORT}" + ) endforeach() -vcpkg_fixup_cmake_targets() +vcpkg_cmake_config_fixup() +vcpkg_fixup_pkgconfig() +if(EXISTS "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/lz4.pc") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/lz4.pc" " -llz4" " -llz4d") +endif() -file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") -file(INSTALL ${SOURCE_PATH}/lib/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) +file(INSTALL "${SOURCE_PATH}/lib/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) diff --git a/ports/lz4/vcpkg.json b/ports/lz4/vcpkg.json index f38d5defb7..0faa462910 100644 --- a/ports/lz4/vcpkg.json +++ b/ports/lz4/vcpkg.json @@ -1,10 +1,17 @@ { "name": "lz4", - "version-string": "1.9.3", - "port-version": 1, + "version": "1.9.3", + "port-version": 2, "description": "Lossless compression algorithm, providing compression speed at 400 MB/s per core.", "homepage": "https://github.com/lz4/lz4", "dependencies": [ - "xxhash" + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } ] } diff --git a/versions/baseline.json b/versions/baseline.json index 476e25956d..63373ccf35 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -3982,7 +3982,7 @@ }, "lz4": { "baseline": "1.9.3", - "port-version": 1 + "port-version": 2 }, "lzfse": { "baseline": "1.0", diff --git a/versions/l-/lz4.json b/versions/l-/lz4.json index 273f8d9480..b8801b1d59 100644 --- a/versions/l-/lz4.json +++ b/versions/l-/lz4.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "c73172e611edeb3ef440fd1ea7ef4fe746237cfc", + "version": "1.9.3", + "port-version": 2 + }, { "git-tree": "05857030abda5345ee64ed534732f07147844de6", "version-string": "1.9.3",