diff options
| author | Ethan Morgan <ethan@gweithio.com> | 2026-02-14 16:44:06 +0000 |
|---|---|---|
| committer | Ethan Morgan <ethan@gweithio.com> | 2026-02-14 16:44:06 +0000 |
| commit | 54409423f767d8b1cf30cb7d0efca6b4ca138823 (patch) | |
| tree | d915ac7828703ce4b963efdd9728a1777ba18c1e /vcpkg/ports/zstd | |
Diffstat (limited to 'vcpkg/ports/zstd')
| -rw-r--r-- | vcpkg/ports/zstd/fix-emscripten-and-clang-cl.patch | 31 | ||||
| -rw-r--r-- | vcpkg/ports/zstd/fix-windows-rc-compile.patch | 13 | ||||
| -rw-r--r-- | vcpkg/ports/zstd/no-static-suffix.patch | 13 | ||||
| -rw-r--r-- | vcpkg/ports/zstd/portfile.cmake | 68 | ||||
| -rw-r--r-- | vcpkg/ports/zstd/usage | 4 | ||||
| -rw-r--r-- | vcpkg/ports/zstd/vcpkg.json | 23 |
6 files changed, 152 insertions, 0 deletions
diff --git a/vcpkg/ports/zstd/fix-emscripten-and-clang-cl.patch b/vcpkg/ports/zstd/fix-emscripten-and-clang-cl.patch new file mode 100644 index 0000000..456978d --- /dev/null +++ b/vcpkg/ports/zstd/fix-emscripten-and-clang-cl.patch @@ -0,0 +1,31 @@ +diff --git a/build/cmake/CMakeModules/AddZstdCompilationFlags.cmake b/build/cmake/CMakeModules/AddZstdCompilationFlags.cmake +index 5f381c6..f1e9b32 100644 +--- a/build/cmake/CMakeModules/AddZstdCompilationFlags.cmake ++++ b/build/cmake/CMakeModules/AddZstdCompilationFlags.cmake +@@ -79,10 +79,22 @@ macro(ADD_ZSTD_COMPILATION_FLAGS) + endif () + # Add noexecstack flags + # LDFLAGS +- EnableCompilerFlag("-Wl,-z,noexecstack" false false true) +- # CFLAGS & CXXFLAGS +- EnableCompilerFlag("-Qunused-arguments" true true false) +- EnableCompilerFlag("-Wa,--noexecstack" true true false) ++ if(MSVC) ++ # UNICODE SUPPORT ++ EnableCompilerFlag("/D_UNICODE" true true false) ++ EnableCompilerFlag("/DUNICODE" true true false) ++ # Enable asserts in Debug mode ++ if (CMAKE_BUILD_TYPE MATCHES "Debug") ++ EnableCompilerFlag("/DDEBUGLEVEL=1" true true false) ++ endif () ++ else() ++ if(NOT EMSCRIPTEN) ++ EnableCompilerFlag("-z noexecstack" false false true) ++ endif() ++ # CFLAGS & CXXFLAGS ++ EnableCompilerFlag("-Qunused-arguments" true true false) ++ EnableCompilerFlag("-Wa,--noexecstack" true true false) ++ endif() + # NOTE: Using 3 nested ifs because the variables are sometimes + # empty if the condition is false, and sometimes equal to false. + # This implicitly converts them to truthy values. There may be diff --git a/vcpkg/ports/zstd/fix-windows-rc-compile.patch b/vcpkg/ports/zstd/fix-windows-rc-compile.patch new file mode 100644 index 0000000..7abde73 --- /dev/null +++ b/vcpkg/ports/zstd/fix-windows-rc-compile.patch @@ -0,0 +1,13 @@ +diff --git a/build/cmake/lib/CMakeLists.txt b/build/cmake/lib/CMakeLists.txt +index 5d514ccb..dd79efb7 100644 +--- a/build/cmake/lib/CMakeLists.txt ++++ b/build/cmake/lib/CMakeLists.txt +@@ -123,7 +123,7 @@ set(PUBLIC_INCLUDE_DIRS ${LIBRARY_DIR}) + set(library_targets) + if (ZSTD_BUILD_SHARED) + add_library(libzstd_shared SHARED ${Sources} ${Headers} ${PlatformDependResources}) +- target_include_directories(libzstd_shared INTERFACE $<BUILD_INTERFACE:${PUBLIC_INCLUDE_DIRS}>) ++ target_include_directories(libzstd_shared PUBLIC $<BUILD_INTERFACE:${PUBLIC_INCLUDE_DIRS}>) + list(APPEND library_targets libzstd_shared) + if (ZSTD_MULTITHREAD_SUPPORT) + set_property(TARGET libzstd_shared APPEND PROPERTY COMPILE_DEFINITIONS "ZSTD_MULTITHREAD") diff --git a/vcpkg/ports/zstd/no-static-suffix.patch b/vcpkg/ports/zstd/no-static-suffix.patch new file mode 100644 index 0000000..89916f4 --- /dev/null +++ b/vcpkg/ports/zstd/no-static-suffix.patch @@ -0,0 +1,13 @@ +diff --git a/build/cmake/lib/CMakeLists.txt b/build/cmake/lib/CMakeLists.txt +index 8234060..765f003 100644 +--- a/build/cmake/lib/CMakeLists.txt ++++ b/build/cmake/lib/CMakeLists.txt +@@ -118,7 +118,7 @@ endif () + + # With MSVC static library needs to be renamed to avoid conflict with import library + if (MSVC OR (WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT MINGW)) +- set(STATIC_LIBRARY_BASE_NAME zstd_static) ++ set(STATIC_LIBRARY_BASE_NAME zstd) + else () + set(STATIC_LIBRARY_BASE_NAME zstd) + endif () diff --git a/vcpkg/ports/zstd/portfile.cmake b/vcpkg/ports/zstd/portfile.cmake new file mode 100644 index 0000000..58f83ad --- /dev/null +++ b/vcpkg/ports/zstd/portfile.cmake @@ -0,0 +1,68 @@ +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO facebook/zstd + REF "v${VERSION}" + SHA512 26e441267305f6e58080460f96ab98645219a90d290a533410b1b0b1d2f870721c95f8384e342ee647c5e968385a5b7e30c2d04340c37f59b3e6d86762c3260c + HEAD_REF dev + PATCHES + no-static-suffix.patch + fix-emscripten-and-clang-cl.patch + fix-windows-rc-compile.patch +) + +string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" ZSTD_BUILD_STATIC) +string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" ZSTD_BUILD_SHARED) + +if("tools" IN_LIST FEATURES) + set(ZSTD_BUILD_PROGRAMS 1) +else() + set(ZSTD_BUILD_PROGRAMS 0) +endif() + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}/build/cmake" + OPTIONS + -DZSTD_BUILD_SHARED=${ZSTD_BUILD_SHARED} + -DZSTD_BUILD_STATIC=${ZSTD_BUILD_STATIC} + -DZSTD_LEGACY_SUPPORT=1 + -DZSTD_BUILD_TESTS=0 + -DZSTD_BUILD_CONTRIB=0 + -DZSTD_MULTITHREAD_SUPPORT=1 + OPTIONS_RELEASE + -DZSTD_BUILD_PROGRAMS=${ZSTD_BUILD_PROGRAMS} + OPTIONS_DEBUG + -DZSTD_BUILD_PROGRAMS=OFF +) + +vcpkg_cmake_install() +vcpkg_copy_pdbs() +vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/zstd) +vcpkg_fixup_pkgconfig() + +file(READ "${CURRENT_PACKAGES_DIR}/share/zstd/zstdTargets.cmake" targets) +if(targets MATCHES "-pthread") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/lib/pkgconfig/libzstd.pc" " -lzstd" " -lzstd -pthread") + if(NOT VCPKG_BUILD_TYPE) + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/libzstd.pc" " -lzstd" " -lzstd -pthread") + endif() +endif() + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include" "${CURRENT_PACKAGES_DIR}/debug/share") + +if(VCPKG_TARGET_IS_WINDOWS AND VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic") + foreach(HEADER IN ITEMS zdict.h zstd.h zstd_errors.h) + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/${HEADER}" "defined(ZSTD_DLL_IMPORT) && (ZSTD_DLL_IMPORT==1)" "1" ) + endforeach() +endif() + +if(VCPKG_TARGET_IS_WINDOWS AND ZSTD_BUILD_PROGRAMS) + vcpkg_copy_tools(TOOL_NAMES zstd AUTO_CLEAN) +endif() + +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") +vcpkg_install_copyright( + COMMENT "ZSTD is dual licensed under BSD and GPLv2." + FILE_LIST + "${SOURCE_PATH}/LICENSE" + "${SOURCE_PATH}/COPYING" +) diff --git a/vcpkg/ports/zstd/usage b/vcpkg/ports/zstd/usage new file mode 100644 index 0000000..ea1dc0a --- /dev/null +++ b/vcpkg/ports/zstd/usage @@ -0,0 +1,4 @@ +zstd provides CMake targets: + + find_package(zstd CONFIG REQUIRED) + target_link_libraries(main PRIVATE zstd::libzstd) diff --git a/vcpkg/ports/zstd/vcpkg.json b/vcpkg/ports/zstd/vcpkg.json new file mode 100644 index 0000000..3d5e298 --- /dev/null +++ b/vcpkg/ports/zstd/vcpkg.json @@ -0,0 +1,23 @@ +{ + "name": "zstd", + "version": "1.5.7", + "description": "Zstandard - Fast real-time compression algorithm", + "homepage": "https://facebook.github.io/zstd/", + "license": "BSD-3-Clause OR GPL-2.0-only", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ], + "features": { + "tools": { + "description": "Build zstd binary", + "supports": "!uwp & static" + } + } +} |