Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'libarchive' package #293

Merged
merged 6 commits into from Oct 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions cmake/configs/default.cmake
Expand Up @@ -338,6 +338,7 @@ hunter_default_version(kbproto VERSION 1.0.7)
hunter_default_version(lcms VERSION 2.9-p0)
hunter_default_version(lehrfempp VERSION 0.7.21)
hunter_default_version(leveldb VERSION 1.22)
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)
Expand Down
38 changes: 38 additions & 0 deletions cmake/projects/libarchive/hunter.cmake
@@ -0,0 +1,38 @@
# !!! DO NOT PLACE HEADER GUARDS HERE !!!

include(hunter_add_version)
include(hunter_configuration_types)
include(hunter_pick_scheme)
include(hunter_download)
include(hunter_cacheable)
include(hunter_cmake_args)

hunter_add_version(
PACKAGE_NAME
libarchive
VERSION
"3.4.3"
URL
"https://libarchive.org/downloads/libarchive-3.4.3.tar.gz"
SHA1
6528f38fa03a44bfcf58435ec8512ffea2851c99
)

hunter_configuration_types(libarchive CONFIGURATION_TYPES Release)
hunter_pick_scheme(DEFAULT url_sha1_autotools)

hunter_cmake_args(
libarchive
CMAKE_ARGS
PKGCONFIG_EXPORT_TARGETS=libarchive
EXTRA_FLAGS=--without-iconv
)

hunter_cacheable(libarchive)
hunter_download(
PACKAGE_NAME libarchive
PACKAGE_INTERNAL_DEPS_ID "1"
PACKAGE_UNRELOCATABLE_TEXT_FILES
"lib/libarchive.la"
"lib/pkgconfig/libarchive.pc"
)
21 changes: 21 additions & 0 deletions docs/packages/pkg/libarchive.rst
@@ -0,0 +1,21 @@
.. spelling::

cpp
libarchive

.. index::
single: compression ; libarchive

.. _pkg.libarchive:

libarchive
==========

- `Official <https://github.com/libarchive/libarchive>`__
- `Example <https://github.com/cpp-pm/hunter/blob/master/examples/libarchive/CMakeLists.txt>`__
- Added by `Timothy Stack <https://github.com/tstack>`__ (`pr-293 <https://github.com/cpp-pm/hunter/pull/293>`__)

.. literalinclude:: /../examples/libarchive/CMakeLists.txt
:language: cmake
:start-after: # DOCUMENTATION_START {
:end-before: # DOCUMENTATION_END }
18 changes: 18 additions & 0 deletions examples/libarchive/CMakeLists.txt
@@ -0,0 +1,18 @@
# Copyright (c) 2020, Timothy Stack
# All rights reserved.

cmake_minimum_required(VERSION 3.2)

# Emulate HunterGate:
# * https://github.com/hunter-packages/gate
include("../common.cmake")

project(test-libarchive)

# DOCUMENTATION_START {
hunter_add_package(libarchive)
find_package(libarchive CONFIG REQUIRED)

add_executable(boo boo.cpp)
target_link_libraries(boo PUBLIC PkgConfig::libarchive)
# DOCUMENTATION_END }
27 changes: 27 additions & 0 deletions examples/libarchive/boo.cpp
@@ -0,0 +1,27 @@

#include <string>

#include <archive.h>
#include <archive_entry.h>

int main(int argc, char *argv[])
{
static std::string CONTENT = "Hello, World!\n";

char buf[32 * 1024];
size_t used;
auto arc = archive_write_new();
archive_write_add_filter_gzip(arc);
archive_write_set_format_pax_restricted(arc);
archive_write_open_memory(arc, buf, sizeof(buf), &used);
auto entry = archive_entry_new();
archive_entry_set_pathname(entry, "hw.txt");
archive_entry_set_size(entry, CONTENT.size());
archive_entry_set_filetype(entry, AE_IFREG);
archive_entry_set_perm(entry, 0644);
archive_write_header(arc, entry);
archive_write_data(arc, CONTENT.c_str(), CONTENT.size());
archive_entry_free(entry);
archive_write_close(arc);
archive_write_free(arc);
}