vcpkg/ports/lz4/portfile.cmake
Eddy Pronk 2666deec0c
[lz4] Patch for CVE-2021-3520 (#25421)
* [lz4] Patch for CVE-2021-3520

See https://nvd.nist.gov/vuln/detail/CVE-2021-3520 for more details

This is the upstream patch by Jasper Lievisse Adriaanse.

"Fix potential memory corruption with negative memmove() size"
https://github.com/lz4/lz4/pull/972

* Added license to lz4/vcpkg.json
2022-06-29 12:40:29 -07:00

43 lines
1.3 KiB
CMake

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO lz4/lz4
REF v1.9.3
SHA512 c246b0bda881ee9399fa1be490fa39f43b291bb1d9db72dba8a85db1a50aad416a97e9b300eee3d2a4203c2bd88bda2762e81bc229c3aa409ad217eb306a454c
HEAD_REF dev
PATCHES
0001-Fix-potential-memory-corruption-with-negative-memmov.patch
)
file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}")
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS_DEBUG
-DCMAKE_DEBUG_POSTFIX=d
)
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)
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/${FILE}"
"defined(LZ4_DLL_IMPORT) && (LZ4_DLL_IMPORT==1)"
"${DLL_IMPORT}"
)
endforeach()
vcpkg_cmake_config_fixup()
vcpkg_fixup_pkgconfig()
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/liblz4.pc" " -llz4" " -llz4d")
endif()
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
file(INSTALL "${SOURCE_PATH}/lib/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)