Skip to content

Commit

Permalink
[lz4] Install pc file, cleanup (#20108)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
dg0yt authored Sep 13, 2021
1 parent c264772 commit 35c086d
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 19 deletions.
8 changes: 8 additions & 0 deletions ports/lz4/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
35 changes: 20 additions & 15 deletions ports/lz4/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
13 changes: 10 additions & 3 deletions ports/lz4/vcpkg.json
Original file line number Diff line number Diff line change
@@ -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
}
]
}
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -3982,7 +3982,7 @@
},
"lz4": {
"baseline": "1.9.3",
"port-version": 1
"port-version": 2
},
"lzfse": {
"baseline": "1.0",
Expand Down
5 changes: 5 additions & 0 deletions versions/l-/lz4.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "c73172e611edeb3ef440fd1ea7ef4fe746237cfc",
"version": "1.9.3",
"port-version": 2
},
{
"git-tree": "05857030abda5345ee64ed534732f07147844de6",
"version-string": "1.9.3",
Expand Down

0 comments on commit 35c086d

Please sign in to comment.