Page MenuHome GnuPG

No OneTemporary

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 23dc8461..4820be35 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,84 +1,95 @@
# CMakeLists.txt for GpgME++
# Copyright 2025 g10 Code GmbH
# Software engineering by Carl Schwan <carl.schwan@gnupg.com>
# Software engineering by Ingo Klöcker <dev@ingo-kloecker.de>
#
# This file is part of GPGME++.
#
# GPGME++ is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2.1 of the
# License, or (at your option) any later version.
#
# GPGME++ is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
# Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, see <https://gnu.org/licenses/>.
# SPDX-License-Identifier: LGPL-2.1-or-later
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
set(FULL_VERSION "2.0.0")
string(REGEX MATCH "^[0-9]+.[0-9]+.[0-9]+" cmake_compat_version ${FULL_VERSION})
project(gpgmepp VERSION ${cmake_compat_version})
set(VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(VERSION_MICRO ${PROJECT_VERSION_PATCH})
# LT Version numbers, remember to change them just *before* a release.
# (Code changed: REVISION++)
# (Interfaces added/removed/changed: CURRENT++, REVISION=0)
# (Interfaces added: AGE++)
# (Interfaces removed: AGE=0)
set(LIBGPGMEPP_LT_CURRENT "28")
set(LIBGPGMEPP_LT_AGE "22")
set(LIBGPGMEPP_LT_REVISION "0")
math(EXPR LIBGPGMEPP_SOVERSION "${LIBGPGMEPP_LT_CURRENT} - ${LIBGPGMEPP_LT_AGE}")
set(GPG_ERROR_REQUIRED_VERSION "1.47")
set(GPGME_REQUIRED_VERSION "1.24.2")
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
include(G10CMakeSettings)
+
+include(G10AddDistTargets)
include(G10CompilerSettings)
include(G10GetFullVersion)
include(ECMUninstallTarget)
include(FeatureSummary)
include(GNUInstallDirs)
find_package(LibGpgError ${GPG_ERROR_REQUIRED_VERSION})
set_package_properties(LibGpgError PROPERTIES TYPE REQUIRED)
find_package(Gpgme ${GPGME_REQUIRED_VERSION})
set_package_properties(Gpgme PROPERTIES TYPE REQUIRED)
g10_get_full_version()
# create the VERSION file
find_package(Git QUIET)
if (GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
# get the current commit ID
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --verify HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE commit_id
)
string(STRIP "${commit_id}" commit_id) # strip trailing whitespace
file(WRITE "${CMAKE_BINARY_DIR}/VERSION" "${G10_FULL_VERSION}\n${commit_id}\n")
elseif(EXISTS "${CMAKE_SOURCE_DIR}/VERSION")
configure_file("${CMAKE_SOURCE_DIR}/VERSION" "VERSION" COPYONLY)
else()
file(WRITE "${CMAKE_BINARY_DIR}/VERSION" "${G10_FULL_VERSION}\nunknown\n")
endif()
+set(EXTRA_DIST
+ "${CMAKE_BINARY_DIR}/VERSION"
+)
+g10_add_dist_targets(
+ VERSION "${G10_FULL_VERSION}"
+ ARCHIVE_FORMAT "tar.xz"
+ EXTRA_FILES ${EXTRA_DIST}
+)
+
add_subdirectory(src)
if(BUILD_TESTING)
add_subdirectory(tests)
endif()
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
diff --git a/cmake/modules/G10AddDistTargets.cmake b/cmake/modules/G10AddDistTargets.cmake
new file mode 100644
index 00000000..39cc661f
--- /dev/null
+++ b/cmake/modules/G10AddDistTargets.cmake
@@ -0,0 +1,119 @@
+# Copyright 2025 g10 Code GmbH
+# Software engineering by Ingo Klöcker <dev@ingo-kloecker.de>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# SPDX-License-Identifier: BSD-2-Clause
+
+#[=======================================================================[.rst:
+G10AddDistTargets
+-----------------
+
+Add custom targets ``dist`` and ``distcheck`` for packaging the sources.
+
+::
+
+ g10_add_dist_targets(
+ [VERSION <version>]
+ [ARCHIVE_FORMAT <format>]
+ [EXTRA_FILES <filename> [...]]
+ )
+
+
+This function adds the custom targets ``dist`` and ``distcheck`` to the project.
+These targets are similar to the targets with the same names created by
+automake.
+
+The ``dist`` target can be used to create a tarball of the sources.
+It uses ``git archive`` for creating the tarball so that the target can only be
+used with git clones of the project and not with extracted tarballs. The created
+package is named ``<PROJECT_NAME>-<version>.<format>``.
+
+The ``distcheck`` target creates and extracts a tarball of the project and then
+configures, builds, installs, uninstalls, installs with DESTDIR, and uninstalls
+with DESTDIR.
+
+If ``VERSION`` is not given then ``PROJECT_VERSION`` is used.
+
+If ``ARCHIVE_FORMAT`` is not given then ``tar.gz`` is used. ``git archive``
+needs to support the given format.
+
+With ``EXTRA_FILES`` files that are not part of HEAD, e.g. a file generated
+with cmake, can be added to the tarball.
+#]=======================================================================]
+
+function(G10_ADD_DIST_TARGETS)
+ set(options)
+ set(one_value_keywords VERSION ARCHIVE_FORMAT)
+ set(multi_value_keywords EXTRA_FILES)
+
+ cmake_parse_arguments(PARSE_ARGV 0 arg "${options}" "${one_value_keywords}" "${multi_value_keywords}")
+
+ if(arg_UNPARSED_ARGUMENTS)
+ message(FATAL_ERROR "Unknown keywords given to G10_ADD_DIST_TARGETS(): \"${arg_UNPARSED_ARGUMENTS}\"")
+ endif()
+
+ if(arg_VERSION)
+ set(version ${arg_VERSION})
+ else()
+ set(version ${PROJECT_VERSION})
+ endif()
+ if(arg_ARCHIVE_FORMAT)
+ set(archive_format ${arg_ARCHIVE_FORMAT})
+ else()
+ set(archive_format "tar.gz")
+ endif()
+ if(arg_EXTRA_FILES)
+ set(extra_arguments)
+ foreach(extra_file IN LISTS arg_EXTRA_FILES)
+ set(extra_arguments "${extra_arguments} --add-file \"${extra_file}\"")
+ endforeach()
+ endif()
+
+ if (NOT TARGET dist)
+ set(g10_dist_archive_name "${PROJECT_NAME}-${version}")
+ set(g10_dist_archive_format "${archive_format}")
+ set(g10_dist_git_archive_extra_arguments "${extra_arguments}")
+ configure_file("${CMAKE_SOURCE_DIR}/cmake/modules/g10_dist.sh.in" "g10_dist.sh" @ONLY)
+ file(CHMOD "g10_dist.sh"
+ FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
+ add_custom_target(dist
+ COMMENT "Packaging HEAD of sources as ${g10_dist_archive_name}.${g10_dist_archive_format}..."
+ COMMAND "${CMAKE_BINARY_DIR}/g10_dist.sh"
+ WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
+ )
+ endif()
+
+ if (NOT TARGET distcheck)
+ set(g10_distcheck_archive_name "${PROJECT_NAME}-${version}")
+ set(g10_distcheck_archive_format "${archive_format}")
+ configure_file("${CMAKE_SOURCE_DIR}/cmake/modules/g10_distcheck.sh.in" "g10_distcheck.sh" @ONLY)
+ file(CHMOD "g10_distcheck.sh"
+ FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
+ add_custom_target(distcheck
+ COMMAND "${CMAKE_BINARY_DIR}/g10_distcheck.sh"
+ WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
+ )
+ endif()
+
+ add_dependencies(distcheck dist)
+endfunction()
diff --git a/cmake/modules/g10_dist.sh.in b/cmake/modules/g10_dist.sh.in
new file mode 100644
index 00000000..2b4b8aec
--- /dev/null
+++ b/cmake/modules/g10_dist.sh.in
@@ -0,0 +1,49 @@
+#!/bin/sh
+#
+# Copyright 2025 g10 Code GmbH
+# Software engineering by Ingo Klöcker <dev@ingo-kloecker.de>
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <https://www.gnu.org/licenses/>.
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+set -e
+
+tarball_name="@g10_dist_archive_name@"
+tarball_format="@g10_dist_archive_format@"
+tarball_filename="${tarball_name}.${tarball_format}"
+
+if ! git --version >/dev/null 2>&1; then
+ echo "Error: Could not find git." >&2
+ exit 1
+fi
+if [ ! -e "@CMAKE_SOURCE_DIR@/.git" ]; then
+ echo "Error: Source folder @CMAKE_SOURCE_DIR@ is not a git repository." >&2
+ exit 1
+fi
+
+cd "@CMAKE_SOURCE_DIR@"
+
+# check if the requested archive format is supported by git
+if ! ( git archive -l | grep -q "^${tarball_format}$" ); then
+ echo "Warning: git archive doesn't seem to support the format ${tarball_format}."
+ echo " You can tell git how to create an archive of this format with something like this:"
+ echo " git config --global tar.${tarball_format}.command 'fooz -c'"
+fi
+
+git archive --format "${tarball_format}" \
+ --prefix "${tarball_name}/" \
+ --output "@CMAKE_BINARY_DIR@/${tarball_filename}" \
+ @g10_dist_git_archive_extra_arguments@ \
+ HEAD
diff --git a/cmake/modules/g10_distcheck.sh.in b/cmake/modules/g10_distcheck.sh.in
new file mode 100644
index 00000000..5647fe75
--- /dev/null
+++ b/cmake/modules/g10_distcheck.sh.in
@@ -0,0 +1,93 @@
+#!/bin/sh
+#
+# Copyright 2025 g10 Code GmbH
+# Software engineering by Ingo Klöcker <dev@ingo-kloecker.de>
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <https://www.gnu.org/licenses/>.
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+set -e
+
+tarball_name="@g10_distcheck_archive_name@"
+tarball_format="@g10_distcheck_archive_format@"
+tarball_filename="${tarball_name}.${tarball_format}"
+
+cd "@CMAKE_BINARY_DIR@"
+
+# extract the tarball replacing an already existing folder
+if [ -d "${tarball_name}" ]; then
+ find "${tarball_name}" -type d ! -perm -700 -exec chmod u+rwx {} ';'
+ rm -rf "${tarball_name}"
+fi
+case "${tarball_format}" in
+tar.gz)
+ gzip -dc "${tarball_filename}" | tar xf -
+ ;;
+tar.bz2)
+ bzip2 -dc "${tarball_filename}" | tar xf -
+ ;;
+tar.xz)
+ xz -dc "${tarball_filename}" | tar xf -
+ ;;
+*)
+ echo "Error: Only tar.gz, tar.bz2, and tar.xz are supported." >&2
+ exit 1
+ ;;
+esac
+
+# make the sources read-only
+chmod -R a-w "${tarball_name}"
+# create subfolders for building and installing
+chmod u+w "${tarball_name}"
+mkdir "${tarball_name}/_build" "${tarball_name}/_build/sub" "${tarball_name}/_inst"
+chmod a-w "${tarball_name}"
+
+dc_install_base=`cd "${tarball_name}/_inst" && pwd`
+dc_destdir=`mktemp -d --tmpdir "distcheck-${tarball_name}.XXXXXXXXXX"`
+# TODO: support distcheck-hook
+dc_cwd=`pwd`
+
+cd "${tarball_name}/_build/sub"
+@CMAKE_COMMAND@ -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX="${dc_install_base}" ../..
+@CMAKE_COMMAND@ --build .
+@CMAKE_CTEST_COMMAND@ --output-on-failure
+@CMAKE_COMMAND@ --install .
+# TODO: installcheck
+@CMAKE_COMMAND@ --build . -t uninstall
+# TODO: distuninstallcheck
+chmod -R a-w "${dc_install_base}"
+( \
+ { \
+ DESTDIR="${dc_destdir}" @CMAKE_COMMAND@ --install . \
+ && DESTDIR="${dc_destdir}" @CMAKE_COMMAND@ --build . -t uninstall; \
+ } || { \
+ rm -rf "${dc_destdir}"; \
+ exit 1; \
+ } \
+)
+rm -rf "${dc_destdir}"
+
+cd "${dc_cwd}"
+
+if [ -d "${tarball_name}" ]; then
+ find "${tarball_name}" -type d ! -perm -700 -exec chmod u+rwx {} ';'
+ rm -rf "${tarball_name}"
+fi
+
+# print tarballs within "===..." separator lines
+( \
+ echo "${tarball_name} archives ready for distribution: "; \
+ echo "${tarball_filename}" \
+) | sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$p' -e '$x'

File Metadata

Mime Type
text/x-diff
Expires
Sat, May 10, 8:59 AM (1 d, 6 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
9a/0b/529bb83a85f3b7831a2ca07942f5

Event Timeline