diff --git a/cmake/configs/default.cmake b/cmake/configs/default.cmake index 35b527b45e..82502a2ef1 100644 --- a/cmake/configs/default.cmake +++ b/cmake/configs/default.cmake @@ -374,6 +374,7 @@ hunter_default_version(libarchive VERSION 3.4.3) hunter_default_version(libbacktrace VERSION 1.0.0-ca0de051) hunter_default_version(libcpuid VERSION 0.4.0) hunter_default_version(libdaemon VERSION 0.14) +hunter_default_version(libdeflate VERSION 1.24-p0) hunter_default_version(libdill VERSION 1.6) hunter_default_version(libevhtp VERSION 1.2.16-p4) hunter_default_version(libffi VERSION 3.2.1) diff --git a/cmake/projects/libdeflate/hunter.cmake b/cmake/projects/libdeflate/hunter.cmake new file mode 100644 index 0000000000..8742d34330 --- /dev/null +++ b/cmake/projects/libdeflate/hunter.cmake @@ -0,0 +1,36 @@ +# Copyright (c) 2016-2020, Rahul Sheth, Ruslan Baratov +# All rights reserved. + +# !!! DO NOT PLACE HEADER GUARDS HERE !!! + +include(hunter_add_version) +include(hunter_cmake_args) +include(hunter_cacheable) +include(hunter_download) +include(hunter_pick_scheme) + +# need to use hunter fork, v1.24 isn't relocatable yet +# open PR: https://github.com/ebiggers/libdeflate/pull/434 +hunter_add_version( + PACKAGE_NAME + libdeflate + VERSION + 1.24-p0 + URL + "https://github.com/cpp-pm/libdeflate/archive/refs/tags/v1.24-p0.tar.gz" + SHA1 + 07f1a72f3938377615da6e4bb48be77d1e8938a4 +) + +hunter_cmake_args( + libdeflate + CMAKE_ARGS + LIBDEFLATE_BUILD_STATIC_LIB=YES + LIBDEFLATE_BUILD_SHARED_LIB=NO + LIBDEFLATE_USE_SHARED_LIB=NO + LIBDEFLATE_BUILD_TESTS=NO +) + +hunter_pick_scheme(DEFAULT url_sha1_cmake) +hunter_cacheable(libdeflate) +hunter_download(PACKAGE_NAME libdeflate) diff --git a/docs/packages/pkg/libdeflate.md b/docs/packages/pkg/libdeflate.md new file mode 100644 index 0000000000..6032404f85 --- /dev/null +++ b/docs/packages/pkg/libdeflate.md @@ -0,0 +1,22 @@ +```{spelling:word-list} + +libdeflate +``` + +```{index} single: compression ; libdeflate +``` + +(pkg.libdeflate)= + +# libdeflate + +- [Official](https://github.com/ebiggers/libdeflate) +- [Hunterized](https://github.com/cpp-pm/libdeflate) +- [Example](https://github.com/cpp-pm/hunter/blob/master/examples/libdeflate/CMakeLists.txt) +- Added by [NeroBurner](https://github.com/neroburner) ([pr-812](https://github.com/cpp-pm/hunter/pull/812)) + +```{literalinclude} /../examples/libdeflate/CMakeLists.txt +:language: cmake +:start-after: "# DOCUMENTATION_START {" +:end-before: "# DOCUMENTATION_END }" +``` diff --git a/examples/libdeflate/CMakeLists.txt b/examples/libdeflate/CMakeLists.txt new file mode 100644 index 0000000000..fcf9a2e71b --- /dev/null +++ b/examples/libdeflate/CMakeLists.txt @@ -0,0 +1,18 @@ +# Copyright (c) 2025, NeroBurner +# All rights reserved. + +cmake_minimum_required(VERSION 3.10) + +# Emulate HunterGate: +# * https://github.com/hunter-packages/gate +include("../common.cmake") + +project(download-libdeflate) + +# DOCUMENTATION_START { +hunter_add_package(libdeflate) +find_package(libdeflate CONFIG REQUIRED) + +add_executable(boo boo.cpp) +target_link_libraries(boo PUBLIC libdeflate::libdeflate_static) +# DOCUMENTATION_END } diff --git a/examples/libdeflate/boo.cpp b/examples/libdeflate/boo.cpp new file mode 100644 index 0000000000..e0ed803c24 --- /dev/null +++ b/examples/libdeflate/boo.cpp @@ -0,0 +1,10 @@ +#include +#include + +int main() { + std::cout << "libdeflate version: " << LIBDEFLATE_VERSION_STRING << std::endl; + libdeflate_compressor *compressor = libdeflate_alloc_compressor(0); + size_t compressed_bound = libdeflate_deflate_compress_bound(compressor, 1337); + std::cout << "libdeflate_deflate_compress_bound(1337) => " << compressed_bound << std::endl; + libdeflate_free_compressor(compressor); +}