First Commit

This commit is contained in:
2025-02-06 22:24:29 +08:00
parent ed7df4c81e
commit 7539e6a53c
18116 changed files with 6181499 additions and 0 deletions

View File

@@ -0,0 +1,63 @@
parse: {}
format:
line_width: 80
tab_size: 2
use_tabchars: false
fractional_tab_policy: use-space
max_subgroups_hwrap: 2
max_pargs_hwrap: 6
max_rows_cmdline: 2
separate_ctrl_name_with_space: false
separate_fn_name_with_space: false
dangle_parens: false
dangle_align: prefix
min_prefix_chars: 4
max_prefix_chars: 10
max_lines_hwrap: 2
line_ending: unix
command_case: canonical
keyword_case: unchanged
always_wrap: []
enable_sort: true
autosort: false
require_valid_layout: false
layout_passes: {}
markup:
bullet_char: "*"
enum_char: .
first_comment_is_literal: false
literal_comment_pattern: null
fence_pattern: ^\s*([`~]{3}[`~]*)(.*)$
ruler_pattern: ^\s*[^\w\s]{3}.*[^\w\s]{3}$
explicit_trailing_pattern: "#<"
hashruler_min_length: 10
canonicalize_hashrulers: true
enable_markup: true
lint:
disabled_codes:
- C0103 # Invalid argument name
- C0113 # Missing COMMENT in statement which allows it
- C0111 # Missing docstring on function or macro declaration
function_pattern: "[0-9a-z_]+"
macro_pattern: "[0-9A-Z_]+"
global_var_pattern: "[A-Z][0-9A-Z_]+"
internal_var_pattern: _[A-Z][0-9A-Z_]+
local_var_pattern: "[a-z][a-z0-9_]+"
private_var_pattern: _[0-9a-z_]+
public_var_pattern: "[A-Z][0-9A-Z_]+"
argument_var_pattern: "[a-z][a-z0-9_]+"
keyword_pattern: "[A-Z][0-9A-Z_]+"
max_conditionals_custom_parser: 2
min_statement_spacing: 1
max_statement_spacing: 2
max_returns: 6
max_branches: 30 # Default target: 12
max_arguments: 6 # Default target: 5
max_localvars: 15
max_statements: 110 # Default target: 50
encode:
emit_byteorder_mark: false
input_encoding: utf-8
output_encoding: utf-8
misc:
per_command: {}

View File

@@ -0,0 +1,5 @@
{
"extends": [
"@commitlint/config-conventional"
]
}

View File

@@ -0,0 +1,120 @@
# Enable Powerlevel11k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
#ZSH_THEME="codespaces"
ZSH_THEME="codespaces"
# Set list of themes to pick from when loading at random
# Setting this variable when ZSH_THEME="codespaces"
# a theme from this variable instead of looking in $ZSH/themes/
# If set to an empty array, this variable will have no effect.
# Enable Powerlevel11k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"
# Uncomment the following line to use hyphen-insensitive completion.
# Case-sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"
# Uncomment one of the following lines to change the auto-update behavior
# zstyle ':omz:update' mode disabled # disable automatic updates
# zstyle ':omz:update' mode auto # update automatically without asking
# zstyle ':omz:update' mode reminder # just remind me to update when it's time
# Uncomment the following line to change how often to auto-update (in days).
# zstyle ':omz:update' frequency 13
# Uncomment the following line if pasting URLs and other text is messed up.
# DISABLE_MAGIC_FUNCTIONS="true"
# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"
# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"
# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"
# Uncomment the following line to display red dots whilst waiting for completion.
# You can also set it to another string to have that shown instead of the default red dots.
# e.g. COMPLETION_WAITING_DOTS="%F{yellow}waiting...%f"
# Caution: this setting can cause issues with multiline prompts in zsh < 5.7.1 (see #5765)
# COMPLETION_WAITING_DOTS="true"
# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"
# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# You can set one of the optional three formats:
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# or set a custom format using the strftime function format specifications,
# see 'man strftime' for details.
# HIST_STAMPS="mm/dd/yyyy"
# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder
# Which plugins would you like to load?
# Standard plugins can be found in $ZSH/plugins/
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(git debian zsh-autosuggestions zsh-syntax-highlighting)
source $ZSH/oh-my-zsh.sh
# User configuration
# export MANPATH="/usr/local/man:$MANPATH"
# You may need to manually set your language environment
# export LANG=en_US.UTF-8
# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
# export EDITOR='vim'
# else
# export EDITOR='mvim'
# fi
# Compilation flags
# export ARCHFLAGS="-arch x86_64"
# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
DISABLE_AUTO_UPDATE=true
DISABLE_UPDATE_PROMPT=true
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh

View File

@@ -0,0 +1,58 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.205.2/containers/python-3/.devcontainer/base.Dockerfile
# [Choice] Python version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.10, 3.9, 3.8, 3.7, 3.6, 3-bullseye, 3.10-bullseye, 3.9-bullseye, 3.8-bullseye, 3.7-bullseye, 3.6-bullseye, 3-buster, 3.10-buster, 3.9-buster, 3.8-buster, 3.7-buster, 3.6-buster
ARG VARIANT="3.10-bullseye"
FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT}
# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
ARG NODE_VERSION="none"
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install lsb-release wget software-properties-common \
&& apt-get -y install build-essential ninja-build valgrind gdb lcov doxygen graphviz
# Install minimum cmake 3.21.7 so we can test with the minimukm required version
RUN apt-get -y install libidn11
RUN wget https://github.com/Kitware/CMake/releases/download/v3.21.7/cmake-3.21.7-Linux-x86_64.sh \
-q -O /tmp/cmake-install.sh \
&& chmod u+x /tmp/cmake-install.sh \
&& /tmp/cmake-install.sh --skip-license --prefix=/usr \
&& rm /tmp/cmake-install.sh
# Install clang-14
RUN wget -qO - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
RUN add-apt-repository 'deb http://apt.llvm.org/bullseye/ llvm-toolchain-bullseye-14 main'
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install clang-14 clangd-14 lldb-14 llvm-14 clang-format-14 clang-tidy-14
RUN update-alternatives --install /usr/bin/clang clang /usr/bin/clang-14 100
RUN update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-14 100
RUN update-alternatives --install /usr/bin/clang-apply-replacements clang-apply-replacements /usr/bin/clang-apply-replacements-14 100
RUN update-alternatives --install /usr/bin/clang-check clang-check /usr/bin/clang-check-14 100
RUN update-alternatives --install /usr/bin/clang-query clang-query /usr/bin/clang-query-14 100
RUN update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-14 100
RUN update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-14 100
RUN update-alternatives --install /usr/bin/scan-build scan-build /usr/bin/scan-build-14 100
RUN update-alternatives --install /usr/bin/scan-view scan-view /usr/bin/scan-view-14 100
RUN update-alternatives --install /usr/bin/llvm-cov llvm-cov /usr/bin/llvm-cov-14 100
RUN update-alternatives --install /usr/bin/llvm-profdata llvm-profdata /usr/bin/llvm-profdata-14 100
# Install global node packages and enable husky.
RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g husky standard-version @commitlint/cli @commitlint/config-conventional " 2>&1
# Clean-up
RUN apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*
# Setup oh-my-zsh and plugins for user vscode
ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID
COPY --chown=$USER_UID:$USER_GID .devcontainer/.zshrc /home/$USERNAME
RUN chmod 644 /home/$USERNAME/.zshrc
# the user we're applying this too (otherwise it most likely install for root)
USER $USERNAME
RUN git clone https://github.com/romkatv/powerlevel10k.git ~/.oh-my-zsh/custom/themes/powerlevel10k
RUN git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
RUN git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
ENV SHELL=/bin/zsh

View File

@@ -0,0 +1,33 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.205.2/containers/python-3
{
"name": "cryptopp-cmake_dev",
"build": {
"dockerfile": "Dockerfile",
"context": "..",
"args": {
// Update 'VARIANT' to pick a Python version: 3, 3.10, 3.9, 3.8, 3.7, 3.6
// Append -bullseye or -buster to pin to an OS version.
// Use -bullseye variants on local on arm64/Apple Silicon.
"VARIANT": "3.10-bullseye",
// Options
"NODE_VERSION": "16"
}
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"cheshirekow.cmake-format",
"donjayamanne.githistory",
"editorconfig.editorconfig",
"ms-vscode.cmake-tools",
"redhat.vscode-yaml",
"stkb.rewrap",
"streetsidesoftware.code-spell-checker"
],
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "npx husky install < /dev/null",
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}

12
externals/cryptopp-cmake/.gitattributes vendored Normal file
View File

@@ -0,0 +1,12 @@
# Set default behavior to automatically normalize line endings.
* text=auto eol=lf
# Force batch scripts to always use CRLF line endings so that if a repo is accessed
# in Windows via a file share from Linux, the scripts will work.
*.{cmd,[cC][mM][dD]} text eol=crlf
*.{bat,[bB][aA][tT]} text eol=crlf
# Force bash scripts to always use LF line endings so that if a repo is accessed
# in Unix via a file share from Windows, the scripts will work.
*.sh text eol=lf
.husky/commit-msg eol=lf

View File

@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: "github-actions" # See documentation for possible values
directory: ".github" # Location of package manifests
schedule:
interval: "weekly"

View File

@@ -0,0 +1,358 @@
name: CI Matrix
on: [push, pull_request]
jobs:
Windows:
name: Windows ${{ matrix.runs.generator }} (${{ matrix.build-type }})
runs-on: ${{ matrix.runs.os }}
strategy:
fail-fast: false
matrix:
build-type: [Release, Debug]
runs: [
{generator: "Ninja", os: windows-latest},
{generator: "NMake Makefiles", os: windows-latest},
{generator: "Visual Studio 16 2019", os: windows-2019}]
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Print env
run: |
echo github.event.action: ${{ github.event.action }}
echo github.event_name: ${{ github.event_name }}
- name: Setup Ninja
uses: abdes/gha-setup-ninja@master
with:
version: 1.11.0
- name: Setup cmake
uses: jwlawson/actions-setup-cmake@v1.14
with:
cmake-version: 3.21.x
- name: Setup ccache
# If ccache behaves badly on windows, skip this step
# if: runner.os != 'Windows'
uses: Chocobo1/setup-ccache-action@v1
with:
install_ccache: true
update_packager_index: true
prepend_symlinks_to_path: true
windows_compile_environment: msvc # this field is required
- name: Set environment
uses: ilammy/msvc-dev-cmd@v1
- name: Configure
run: |
cmake `
-S . `
-B build `
-D CMAKE_BUILD_TYPE=${{ matrix.build-type }} `
-G "${{ matrix.runs.generator }}" `
-D USE_CCACHE=ON `
-D CMAKE_VERBOSE_MAKEFILE=ON
- name: Build
run: cmake --build build --config ${{ matrix.build-type }}
- name: Run cryptest
run: ctest --verbose -j40 -R cryptest --test-dir build -C ${{ matrix.build-type }}
- name: Run build tests
run: ctest -j40 -E cryptest --output-on-failure --test-dir build -C ${{ matrix.build-type }}
MacOS:
name: ${{ matrix.config.name }} ${{matrix.generator }} (${{ matrix.build-type }})
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
build-type: [Release, Debug]
generator: [Ninja, Xcode]
config:
- {
name: "MacOS",
omp: "OFF",
}
- {
name: "MacOS-omp-homebrew",
omp: "ON",
}
- {
name: "MacOS-omp-macports",
omp: "ON",
}
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Print env
run: |
echo github.event.action: ${{ github.event.action }}
echo github.event_name: ${{ github.event_name }}
- name: Setup Ninja
uses: abdes/gha-setup-ninja@master
with:
version: 1.11.0
- name: Setup cmake
uses: jwlawson/actions-setup-cmake@v1.14
with:
cmake-version: 3.21.x
- name: Setup ccache
uses: Chocobo1/setup-ccache-action@v1
with:
install_ccache: true
update_packager_index: true
prepend_symlinks_to_path: false
windows_compile_environment: msvc # this field is required
- name: Install macports
uses: melusina-org/setup-macports@v1
if: endsWith(matrix.config.name, 'macports')
- name: Install libomp (macports)
run: |
port install libomp
brew uninstall --ignore-dependencies --zap libomp
if: endsWith(matrix.config.name, 'macports')
- name: Setup XCode
uses: mobiledevops/xcode-select-version-action@v1
with:
xcode-select-version: 13.1
if: matrix.generator == 'Xcode'
- name: Configure
run: |
cmake \
-S . \
-B build \
-G ${{ matrix.generator }} \
-D USE_CCACHE=ON \
-D CMAKE_VERBOSE_MAKEFILE=ON \
-D USE_OPENMP=${{ matrix.config.omp }} \
-D CMAKE_BUILD_TYPE=${{ matrix.build-type }}
- name: Build
run: |
NINJA_STATUS="[%f/%t %o/sec] " export NINJA_STATUS
cmake --build build --config ${{ matrix.build-type }}
- name: Run cryptest
run: ctest -j40 --verbose -R "cryptest" --test-dir build -C ${{ matrix.build-type }}
- name: Run build tests
run: ctest -j40 -E "cryptest" --output-on-failure --test-dir build -C ${{ matrix.build-type }}
Ubuntu:
name: ${{ matrix.config.name }} (${{ matrix.build-type }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
build-type: [Release, Debug]
config:
- {
name: "ubuntu",
cc: "gcc-10",
cxx: "g++-10",
generators: "Ninja",
}
- {
name: "ubuntu-gcc12",
cc: "gcc-12",
cxx: "g++-12",
generators: "Ninja",
}
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Print env
run: |
echo github.event.action: ${{ github.event.action }}
echo github.event_name: ${{ github.event_name }}
- name: Setup Ninja
uses: abdes/gha-setup-ninja@master
with:
version: 1.11.0
- name: Setup cmake
uses: jwlawson/actions-setup-cmake@v1.14
with:
cmake-version: 3.21.x
- name: Install ccache
shell: cmake -P {0}
run: |
set(ccache_version "4.6.3")
set(ccache_dist "ccache-${ccache_version}-linux-x86_64")
set(ccache_url "https://github.com/ccache/ccache/releases/download/v${ccache_version}/${ccache_dist}.tar.xz")
file(DOWNLOAD "${ccache_url}" ./ccache.tar.xz SHOW_PROGRESS)
execute_process(COMMAND ${CMAKE_COMMAND} -E tar zxvf ./ccache.tar.xz)
# Add to PATH environment variable
file(TO_CMAKE_PATH "$ENV{GITHUB_WORKSPACE}/${ccache_dist}" ccache_dir)
set(path_separator ":")
file(APPEND "$ENV{GITHUB_PATH}" "$ENV{GITHUB_WORKSPACE}${path_separator}${ccache_dir}")
- name: Setup ccache
uses: Chocobo1/setup-ccache-action@v1
with:
install_ccache: false
update_packager_index: false
prepend_symlinks_to_path: false
windows_compile_environment: msvc # this field is required
- name: Configure
run: |
export CC=${{ matrix.config.cc }}
export CXX=${{ matrix.config.cxx }}
export PATH=${GITHUB_WORKSPACE}:${PATH}
cmake \
-S . \
-B build \
-D CMAKE_BUILD_TYPE=$ENV{BUILD_TYPE} \
-G Ninja \
-D CMAKE_MAKE_PROGRAM=ninja \
-D USE_CCACHE=ON \
-D CMAKE_VERBOSE_MAKEFILE=ON \
-D CMAKE_BUILD_TYPE=${{ matrix.build-type }}
- name: Build
run: |
export NINJA_STATUS="[%f/%t %o/sec] "
cmake --build build --target all --config ${{ matrix.build-type }}
- name: Run cryptest
run: ctest -j40 --verbose -R cryptest --test-dir build -C ${{ matrix.build-type }}
- name: Run build tests
run: |
export CC=${{ matrix.config.cc }}
export CXX=${{ matrix.config.cxx }}
ctest -j40 -E cryptest --output-on-failure --test-dir build -C ${{ matrix.build-type }}
MSys:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
build-type: [Release, Debug]
sys: [mingw32, mingw64, ucrt64, clang64]
config:
- {
name: "with OMP ",
omp: ON,
}
- {
name: "",
omp: "OFF",
}
exclude:
- sys: mingw32
build-type: Debug
name: MSys - ${{ matrix.sys }} ${{ matrix.config.name }}(${{ matrix.build-type }})
defaults:
run:
shell: msys2 {0}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup MSYS2
uses: msys2/setup-msys2@v2
with:
msystem: ${{ matrix.sys }}
update: true
install: >-
git
make
pacboy: >-
toolchain:p
cmake:p
- name: Setup ccache
uses: Chocobo1/setup-ccache-action@v1
with:
prepend_symlinks_to_path: false
windows_compile_environment: msys2
- name: Configure
run: |
cmake -G"Unix Makefiles" \
-S . \
-B build \
-DCMAKE_VERBOSE_MAKEFILE=ON \
-DCMAKE_BUILD_TYPE=${{ matrix.build-type }} \
-DUSE_OPENMP=${{ matrix.config.omp }} \
-D USE_CCACHE=ON
- name: Build
run: cmake --build build --config ${{ matrix.build-type }}
- name: Run cryptest
run: ctest -j40 --verbose -R cryptest --test-dir build -C ${{ matrix.build-type }}
- name: Run tests
run: ctest -j40 -E cryptest --output-on-failure --test-dir build -C ${{ matrix.build-type }}
cygwin:
strategy:
fail-fast: false
matrix:
build-type: [Release]
config:
- {
name: "with OMP ",
omp: ON,
}
- {
name: "",
omp: "OFF",
}
runs-on: windows-latest
defaults:
run:
shell: C:\cygwin\bin\bash.exe --login -o igncr '{0}'
name: Cygwin ${{ matrix.config.name }}(${{ matrix.build-type }})
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup cygwin
uses: cygwin/cygwin-install-action@master
with:
packages: >-
ccache
cmake
gcc-core
gcc-g++
ninja
- name: Configure
run: |
cmake /cygdrive/d/a/cryptopp-cmake/cryptopp-cmake \
-B build \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_VERBOSE_MAKEFILE=ON \
-G Ninja \
-DCMAKE_BUILD_TYPE=${{ matrix.build-type }} \
-DUSE_OPENMP=${{ matrix.config.omp }} \
-D USE_CCACHE=ON
- name: Build
run: cmake --build build --config ${{ matrix.build-type }}
- name: Run cryptest
run: ctest -j40 --verbose -R cryptest --test-dir build -C ${{ matrix.build-type }}
- name: Run tests
run: ctest -j40 -E cryptest --output-on-failure --test-dir build -C ${{ matrix.build-type }}

View File

@@ -0,0 +1,25 @@
name: Run commitlint on PR
on:
pull_request:
jobs:
run-commitlint-on-pr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: 14.x
- name: Install dependencies
run: npm install -g @commitlint/cli @commitlint/config-conventional
- name: Validate all commits from PR
run: |
npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose

View File

@@ -0,0 +1,339 @@
name: Release Matrix
on:
release:
types: [published]
env:
BUILD_TYPE: Release
jobs:
build:
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- {
name: "windows-latest",
os: windows-latest,
artifact: "Windows-MSVC.7z",
build_type: "Release",
cc: "cl",
cxx: "cl",
environment_script: "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat",
archiver: "7z a",
generators: "Visual Studio 17 2022",
}
- {
name: "ubuntu-latest",
os: ubuntu-latest,
artifact: "Linux.7z",
build_type: "Release",
cc: "gcc-10",
cxx: "g++-10",
archiver: "7z a",
generators: "Ninja",
}
- {
name: "macos-latest",
os: macos-latest,
artifact: "macOS.7z",
build_type: "Release",
cc: "clang",
cxx: "clang++",
archiver: "7za a",
generators: "Ninja",
}
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Print env
run: |
echo github.event.action: ${{ github.event.action }}
echo github.event_name: ${{ github.event_name }}
- name: Setup Ninja
uses: abdes/gha-setup-ninja@master
with:
version: 1.11.0
- name: Setup cmake
uses: jwlawson/actions-setup-cmake@v1.13
with:
cmake-version: 3.21.x
- name: Install ccache
shell: cmake -P {0}
run: |
if("${{ runner.os }}" STREQUAL "Windows")
# If ccache behaves badly on windows, skip this step
execute_process(COMMAND choco install ccache)
elseif("${{ runner.os }}" STREQUAL "macOS")
execute_process(COMMAND brew install ccache)
elseif("${{ runner.os }}" STREQUAL "Linux")
set(ccache_version "4.6.3")
set(ccache_dist "ccache-${ccache_version}-linux-x86_64")
set(ccache_url "https://github.com/ccache/ccache/releases/download/v${ccache_version}/${ccache_dist}.tar.xz")
file(DOWNLOAD "${ccache_url}" ./ccache.tar.xz SHOW_PROGRESS)
execute_process(COMMAND ${CMAKE_COMMAND} -E tar zxvf ./ccache.tar.xz)
# Add to PATH environment variable
file(TO_CMAKE_PATH "$ENV{GITHUB_WORKSPACE}/${ccache_dist}" ccache_dir)
set(path_separator ":")
file(APPEND "$ENV{GITHUB_PATH}" "$ENV{GITHUB_WORKSPACE}${path_separator}${ccache_dir}")
else()
message(FATAL_ERROR, "${{ runner.os }} is not supported")
endif()
- name: Setup ccache
# If ccache behaves badly on windows, skip this step
# if: runner.os != 'Windows'
uses: Chocobo1/setup-ccache-action@v1
with:
install_ccache: false
update_packager_index: false
prepend_symlinks_to_path: false
windows_compile_environment: msvc # this field is required
- name: Configure
shell: cmake -P {0}
run: |
set(ENV{CC} ${{ matrix.config.cc }})
set(ENV{CXX} ${{ matrix.config.cxx }})
if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x")
execute_process(
COMMAND "${{ matrix.config.environment_script }}" && set
OUTPUT_FILE environment_script_output.txt
)
file(STRINGS environment_script_output.txt output_lines)
foreach(line IN LISTS output_lines)
if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$")
set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}")
endif()
endforeach()
endif()
set(path_separator ":")
if ("${{ runner.os }}" STREQUAL "Windows")
set(path_separator ";")
endif()
set(ENV{PATH} "$ENV{GITHUB_WORKSPACE}${path_separator}$ENV{PATH}")
# If ccache shows some strange behavior on windows, you can easily
# disable it here by setting the variable to "OFF"
if (NOT "${{ runner.os }}" STREQUAL "Windows")
set(enable_ccache "ON")
else()
set(enable_ccache "ON")
endif()
if ("${{ matrix.config.name }}" STREQUAL "macos-latest-omp-homebrew" OR "${{ matrix.config.name }}" STREQUAL "macos-latest-omp-macports")
set(OMP "ON")
else()
set(OMP "OFF")
endif()
execute_process(
COMMAND cmake
-S .
-B build
-D CMAKE_BUILD_TYPE=$ENV{BUILD_TYPE}
-G Ninja
-D CMAKE_MAKE_PROGRAM=ninja
-D USE_CCACHE=${enable_ccache}
-D CMAKE_VERBOSE_MAKEFILE=ON
-D USE_OPENMP=${OMP}
RESULT_VARIABLE result
)
if (NOT result EQUAL 0)
message(FATAL_ERROR "Bad exit status")
endif()
- name: Build
shell: cmake -P {0}
run: |
set(ENV{NINJA_STATUS} "[%f/%t %o/sec] ")
if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x")
file(STRINGS environment_script_output.txt output_lines)
foreach(line IN LISTS output_lines)
if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$")
set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}")
endif()
endforeach()
endif()
execute_process(
COMMAND cmake --build build --target all
RESULT_VARIABLE result
OUTPUT_VARIABLE output
ERROR_VARIABLE output
ECHO_OUTPUT_VARIABLE ECHO_ERROR_VARIABLE
)
if (NOT result EQUAL 0)
string(REGEX MATCH "FAILED:.*$" error_message "${output}")
string(REPLACE "\n" "%0A" error_message "${error_message}")
message("::error::${error_message}")
message(FATAL_ERROR "Build failed")
endif()
- name: Run cryptest
shell: cmake -P {0}
run: |
# Do not run tests in parallel as we share things between them to
# speed up the build and enable caching. The benefit of caching is
# much higher than parallel tests.
set(ENV{CTEST_OUTPUT_ON_FAILURE} "ON")
execute_process(
COMMAND ctest "--verbose" "-R" "cryptest"
WORKING_DIRECTORY build
RESULT_VARIABLE result
OUTPUT_VARIABLE output
ERROR_VARIABLE output
ECHO_OUTPUT_VARIABLE ECHO_ERROR_VARIABLE
)
if (NOT result EQUAL 0)
string(REGEX MATCH "[0-9]+% tests.*[0-9.]+ sec.*$" test_results "${output}")
string(REPLACE "\n" "%0A" test_results "${test_results}")
message("::error::${test_results}")
message(FATAL_ERROR "Running tests failed!")
endif()
- name: Run build tests
shell: cmake -P {0}
run: |
# Do not run tests in parallel as we share things between them to
# speed up the build and enable caching. The benefit of caching is
# much higher than parallel tests.
set(ENV{CC} ${{ matrix.config.cc }})
set(ENV{CXX} ${{ matrix.config.cxx }})
set(ENV{CTEST_OUTPUT_ON_FAILURE} "ON")
if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x")
execute_process(
COMMAND "${{ matrix.config.environment_script }}" && set
OUTPUT_FILE environment_script_output.txt
)
file(STRINGS environment_script_output.txt output_lines)
foreach(line IN LISTS output_lines)
if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$")
set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}")
endif()
endforeach()
endif()
execute_process(
COMMAND ctest "-E" "cryptest"
WORKING_DIRECTORY build
RESULT_VARIABLE result
OUTPUT_VARIABLE output
ERROR_VARIABLE output
ECHO_OUTPUT_VARIABLE ECHO_ERROR_VARIABLE
)
if (NOT result EQUAL 0)
string(REGEX MATCH "[0-9]+% tests.*[0-9.]+ sec.*$" test_results "${output}")
string(REPLACE "\n" "%0A" test_results "${test_results}")
message("::error::${test_results}")
message(FATAL_ERROR "Running tests failed!")
endif()
- name: Install Strip
run: cmake --install build --prefix instdir --strip
- name: Pack
working-directory: instdir
run: cmake -E tar cfv ../${{ matrix.config.artifact }} --format=7zip .
- name: Upload
if: ${{ !env.ACT }}
uses: actions/upload-artifact@v1
with:
path: ./${{ matrix.config.artifact }}
name: ${{ matrix.config.artifact }}
release:
if: contains(github.ref, 'tags/CRYPTOPP_')
runs-on: ubuntu-latest
needs: build
steps:
- name: Create Release
id: create_release
uses: actions/create-release@v1.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: Store Release url
run: |
echo "${{ steps.create_release.outputs.upload_url }}" > ./upload_url
- uses: actions/upload-artifact@v1
with:
path: ./upload_url
name: upload_url
publish:
if: contains(github.ref, 'tags/CRYPTOPP_')
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- {
name: "Windows Latest MSVC",
artifact: "Windows-MSVC.7z",
os: windows-latest,
}
- {
name: "Ubuntu Latest GCC",
artifact: "Linux.7z",
os: ubuntu-latest,
}
- {
name: "macOS Latest Clang",
artifact: "macOS.7z",
os: macos-latest,
}
needs: release
steps:
- name: Download artifact
uses: actions/download-artifact@v1
with:
name: ${{ matrix.config.artifact }}
path: ./
- name: Download URL
uses: actions/download-artifact@v1
with:
name: upload_url
path: ./
- id: set_upload_url
shell: bash
run: |
upload_url=`cat ./upload_url`
echo "{upload_url}={$upload_url}" >> $GITHUB_OUTPUT
- name: Upload to Release
id: upload_to_release
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.set_upload_url.outputs.upload_url }}
asset_path: ./${{ matrix.config.artifact }}
asset_name: ${{ matrix.config.artifact }}
asset_content_type: application/x-gtar

15
externals/cryptopp-cmake/.gitignore vendored Normal file
View File

@@ -0,0 +1,15 @@
# Visual Studio 2015/2017 cache/options directory
.vs/
.idea/
# Build directories
build/
_build/
cmake-build*/
out
# Mac garbage
.DS_Store
#vagrant
.vagrant

View File

@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx --no-install commitlint -x $(npm root -g)/@commitlint/config-conventional --edit $1

View File

@@ -0,0 +1,54 @@
{
"types": [
{
"type": "feat",
"section": "Features"
},
{
"type": "fix",
"section": "Bug Fixes"
},
{
"type": "chore",
"hidden": true
},
{
"type": "docs",
"section": "Documentation"
},
{
"type": "style",
"hidden": true
},
{
"type": "refactor",
"hidden": true
},
{
"type": "perf",
"hidden": true
},
{
"type": "test",
"hidden": true
},
{
"type": "build",
"hidden": true
},
{
"type": "ops",
"hidden": true
}
],
"bumpFiles": [
{
"filename": "CMakeLists.txt",
"updater": "cmake/scripts/standard-version-updater.js"
}
],
"commitUrlFormat": "http://github.com/abdes/asap/commit/{{hash}}",
"compareUrlFormat": "http://github.com/abdes/asap/compare/{{previousTag}}...{{currentTag}}",
"issueUrlFormat": "http://github.com/abdes/asap/issues/{{id}}",
"userUrlFormat": "http://github.com/abdes"
}

View File

@@ -0,0 +1,11 @@
{
"recommendations": [
"cheshirekow.cmake-format",
"donjayamanne.githistory",
"editorconfig.editorconfig",
"ms-vscode.cmake-tools",
"redhat.vscode-yaml",
"stkb.rewrap",
"streetsidesoftware.code-spell-checker",
]
}

View File

@@ -0,0 +1,18 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "cppvsdbg",
"request": "launch",
"name": "cryptest",
"program": "${workspaceFolder}/build/cryptopp/cryptest",
"args": [
"v"
],
"cwd": "${workspaceFolder}/build"
}
]
}

View File

@@ -0,0 +1,37 @@
{
"editor.rulers": [
80,
100
],
"rewrap.wrappingColumn": 80,
"rewrap.autoWrap.enabled": true,
"editor.detectIndentation": false,
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"git.autofetch": true,
"git.confirmSync": false,
"git.enableSmartCommit": true,
"editor.bracketPairColorization.enabled": true,
"workbench.colorCustomizations": {
"[Default Dark+]": {
"editorBracketHighlight.foreground3": "#9CDCFE"
}
},
"cmake.configureOnOpen": true,
"cmake.preferredGenerators": [
"Ninja"
],
"cmake.configureArgs": [
"-DCMAKE_INSTALL_PREFIX=${workspaceFolder}/build/install",
"-DCMAKE_VERBOSE_MAKEFILE=ON"
],
"rewrap.reformat": true,
"search.exclude": {
"**/.idea": true,
"**/out": true
},
"cSpell.words": [
"cmake",
"pkgconfig"
],
}

174
externals/cryptopp-cmake/CHANGELOG.md vendored Normal file
View File

@@ -0,0 +1,174 @@
# Changelog
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
## [8.9.0](http://github.com/abdes/asap/compare/v8.8.0...v8.9.0) (2023-10-02)
### Known Issues
- [#101](https://github.com/abdes/cryptopp-cmake/issues/101)
When defining `CRYPTOPP_DISABLE_ASM` to a truthful value, the build will fail if
the compiler is MSVC on Windows or clang on MSys. A fix has been done on the
master branch of crypto++
(https://github.com/weidai11/cryptopp/commit/121014baf0e8).
cryptopp-cmake tracks the released versions of crypto++ and will be re-released
when crypto++ is.
### Features
- update source files for crypto++ 8.9.0 ([fa72356](http://github.com/abdes/asap/commit/fa72356c0b89b7346292f2e914ee45bbc742d503)), closes [#88](http://github.com/abdes/asap/issues/88)
### Bug Fixes
- link to omp if requested ([#92](http://github.com/abdes/asap/issues/92)) ([899542f](http://github.com/abdes/asap/commit/899542f1f7f0e55cfa1f41cfb3e9aa9dc157eace))
- make MacOS $(ARCHS_STANDARD) a valid value for CMAKE_OSX_ARCHITECTURES ([6bb6463](http://github.com/abdes/asap/commit/6bb64630c563937e4263b721755c724c0e1ba6e1)), closes [#99](http://github.com/abdes/asap/issues/99)
## [8.8.0](http://github.com/abdes/asap/compare/v8.7.0...v8.8.0) (2023-06-25)
### Features
- make compiler caching work for the library build ([#28](http://github.com/abdes/asap/issues/28)) ([baf2b13](http://github.com/abdes/asap/commit/baf2b132f78f0cdb3e5cf28e15e98d877ceb76e5))
- support cygwin builds ([#87](http://github.com/abdes/asap/issues/87)) ([d5d855a](http://github.com/abdes/asap/commit/d5d855a4f216ac251592cab16b7084877b4402d0))
### Bug Fixes
- [#29](http://github.com/abdes/asap/issues/29) use GNUInstallDirs variables to test for expected files ([79b8702](http://github.com/abdes/asap/commit/79b870277f20ff9ac29cedd4336a9ed37a1119ce))
- [#30](http://github.com/abdes/asap/issues/30) properly compile asm in c++ for armv7 ([9359344](http://github.com/abdes/asap/commit/93593446b3d01b9ee082f6f7065f0f3ec089146e))
- adjust project-name to not overwrite everthing ([010fa7b](http://github.com/abdes/asap/commit/010fa7b7a73065f8d3e94b8b7993277659c3f058))
- also set compiler env for the tests ([#53](http://github.com/abdes/asap/issues/53)) ([dfb8445](http://github.com/abdes/asap/commit/dfb844567a15415c784b89f12153f7bafc42566c))
- Android build for armv7-a platform ([#45](http://github.com/abdes/asap/issues/45)) ([#46](http://github.com/abdes/asap/issues/46)) ([b13d402](http://github.com/abdes/asap/commit/b13d4023cee2d8e297a7ea1c942a4f80d03553d2))
- building for arm32 without default neon flags ([#48](http://github.com/abdes/asap/issues/48)) ([13cb0fe](http://github.com/abdes/asap/commit/13cb0fe7e76410258b76975e77fd407400e3f2d1))
- check_compile_link_option should use CRYPTOPP_COMPILE_DEFINITIONS ([#37](http://github.com/abdes/asap/issues/37)) ([22a1c47](http://github.com/abdes/asap/commit/22a1c47b13ce0683a2625bca152d0470b7c17f66))
- detection and compileflag for cygwin ([7772b09](http://github.com/abdes/asap/commit/7772b09764278dcec8f1481068c1777f531d4f0a))
- detection and compileflags for mingw32 ([0b250db](http://github.com/abdes/asap/commit/0b250dba081689e856a090f660223d6c6f4c555c))
- detection of mingw64 ([fd6434b](http://github.com/abdes/asap/commit/fd6434bcfa9a2c801d3f7e1329689ffb935c988a))
- need to still include `sse_simd.cpp` in sources even when CRYPTOPP_DISABLE_ASM=1 ([0886b6e](http://github.com/abdes/asap/commit/0886b6e912a1461c0271aa617b0e7b2d2773d877))
- prepend project dir to asm source files for arm builds ([3c677c0](http://github.com/abdes/asap/commit/3c677c05288266be135197f136b5358b8a0ecb8b))
- reenable unit-tests ([c756134](http://github.com/abdes/asap/commit/c756134e1e6ab88935d297ac97f0951ef62bebb5))
- target arch detection not working on Mac ([#35](http://github.com/abdes/asap/issues/35)) ([#38](http://github.com/abdes/asap/issues/38)) ([3d8a0a5](http://github.com/abdes/asap/commit/3d8a0a576bccb718cebd4ed97a09feb520e60641))
- Typo in sources.cmake resulted in failed source deduplication ([#41](http://github.com/abdes/asap/issues/41)) ([206aab4](http://github.com/abdes/asap/commit/206aab4cb1e6e78b8460b8c0fe08449c280e321e))
- Universal macOS build failing due to unquoted architectures string ([#42](http://github.com/abdes/asap/issues/42)) ([15798ac](http://github.com/abdes/asap/commit/15798ac9c2611d5c7f9ba832e2c9159bdd8945f2))
- use correct flags for lsh512_sse.cpp ([f31a130](http://github.com/abdes/asap/commit/f31a130112a3d13014c5be381748452221a66703))
- use repos via CPM in tests consistently ([#65](http://github.com/abdes/asap/issues/65)) ([e8e5ab7](http://github.com/abdes/asap/commit/e8e5ab72918205c4b081a3214c4a8088cb055cea))
- workaround gcc-12 with -fno-devirtualize ([#25](http://github.com/abdes/asap/issues/25)) ([e7e0baa](http://github.com/abdes/asap/commit/e7e0baa12f961e227f8ab636df8f2d51495a18ca)), closes [#3](http://github.com/abdes/asap/issues/3)
## 8.7.0 (2022-09-19)
### ⚠ BREAKING CHANGES
- shared lib build is no longer allowed, until crypto++ properly supports DLL
symbol exports and managed visibility.
### Features
- add support for cmake-presets
([c22d49a](http://github.com/abdes/asap/commit/c22d49a432993201b1a4ae189adef540342a58b3))
- align pkgconfig file with crypto++ project
([1bb96f6](http://github.com/abdes/asap/commit/1bb96f628d6a1e185db5a1b3440c37eb390d6326))
- set cmake minimum required version to 3.21
([31b02c4](http://github.com/abdes/asap/commit/31b02c4d1d584257e449c9d4d6fcff4913cb4a53))
- build acceleration with ccache and parallel compilation
### Bug Fixes
- [#10](http://github.com/abdes/asap/issues/10) cloning of crypto++ should be
done in `CRYPTOPP_INCLUDE_PREFIX`
([feb0e11](http://github.com/abdes/asap/commit/feb0e11fdd81652d7579355783142f048fba6338))
- [#22](http://github.com/abdes/asap/issues/22) add missing neon_simd.cpp to
sources
([c0f9743](http://github.com/abdes/asap/commit/c0f97430d904ead8a903f51603afaa6b1d97d003))
- [#23](http://github.com/abdes/asap/issues/23) properly detect ARM on windows
([6a13b4f](http://github.com/abdes/asap/commit/6a13b4fe73335e5fa768bec9d4f09fdc63603e78))
- [#24](http://github.com/abdes/asap/issues/24) apply additional compiler
options to test sources
([fa5bbc1](http://github.com/abdes/asap/commit/fa5bbc1cc7cee8e71b28d773a46e158b68c4b068))
- [#4](http://github.com/abdes/asap/issues/4) build generates PIC even for
static library
([476364c](http://github.com/abdes/asap/commit/476364c2a779cfaebaa236a0f886ab94d01425fb))
- [#5](http://github.com/abdes/asap/issues/5) prefix includes in build interface
with cryptopp
([a6ece10](http://github.com/abdes/asap/commit/a6ece101eed109043c4dcc5a819a3541344a2c03))
- add prefix where needed and use -l to link against lib
([c555112](http://github.com/abdes/asap/commit/c55511285c9d4557b0f8741cbb17fe9dbaa5ef49))
- download crypto++ sources into the CURRENT cmake binary dir
([1c92d03](http://github.com/abdes/asap/commit/1c92d03e4963ec25d00d7d098ca7195e70889b25))
- include interface should work when package is used via find_package
([eaf4ca0](http://github.com/abdes/asap/commit/eaf4ca0d3540f94e28b26e7bff561e1451420a5c))
- install header files under cryptopp folder
([5d72716](http://github.com/abdes/asap/commit/5d727164019790aa1d0c8e2301dfdcfef387a644))
- only detect `arm` as ARM32 if it's not a substring
([4f52cc6](http://github.com/abdes/asap/commit/4f52cc63b6e0bdd2a02a18745ba8984bcdad79e6))
- prefix includes in install interface with cryptopp
([2dbdc8a](http://github.com/abdes/asap/commit/2dbdc8a2dfc587967ed83d6b62e22fb17400fb52))
- rollback [#4](http://github.com/abdes/asap/issues/4)
([26f786e](http://github.com/abdes/asap/commit/26f786e98212f0e8c952df55a22d132458b5f78b))
- set MSVC specific options within if(MSVC) block
([add97fb](http://github.com/abdes/asap/commit/add97fb07b43767913be0c3a9ce4a45d3ced9dbd))
- wrong '-D' when adding to COMPILE_DEFINITIONS
([1561116](http://github.com/abdes/asap/commit/1561116182906a160d342b0446798e78fff486fc))
- wrong linker flags generated in pkgconfig.pc
([7252030](http://github.com/abdes/asap/commit/7252030e64410710bdbcdb2b921d236c2c6c960f))
- wrong test when setting CRYPTOPP_PROJECT_DIR
([22016ce](http://github.com/abdes/asap/commit/22016cebdbe7f204b2072dee76bdab185a6f59a3))
- cleanup library targets to align with cmake best practices
([b4e850b](http://github.com/abdes/asap/commit/b4e850b112593073bcca64d1f88d2192926c05d5))
- many more fixes and tweaks...
### Documentation
- add a `before you ask` section
([f071c14](http://github.com/abdes/asap/commit/f071c14eb7c1a2813f6a949c5ed99bed0c0410d3))
- add link to change of repo announcement
([63f4e10](http://github.com/abdes/asap/commit/63f4e10af10c8c51dc53827e430cec89748db6e4))
- small corrections to contribution guide
([439b1aa](http://github.com/abdes/asap/commit/439b1aa357290784881a7af3083dd63de873bc23))
- update project intro and new direction
([234aac7](http://github.com/abdes/asap/commit/234aac76e6b51a66e9e6c6fc3fd07f236814d2c5))
- update to refer to the new link target names
([6cab962](http://github.com/abdes/asap/commit/6cab962e7cbbac533da1dde9023de185a9ef0238))
## From original repo
### Features
- cache results of check compile/link operations
([8e92fe0](http://github.com/abdes/asap/commit/8e92fe0544755d34ec569d5f561f62c419fa42dc))
- flexible fetching of crypto++ sources
([82a137e](http://github.com/abdes/asap/commit/82a137ed6696fe48ddcd704f65710a7588f3b8a4))
### Bug Fixes
- [#88](http://github.com/abdes/asap/issues/88)
[#90](http://github.com/abdes/asap/issues/90)
[#91](http://github.com/abdes/asap/issues/91)
[#92](http://github.com/abdes/asap/issues/92)
[#93](http://github.com/abdes/asap/issues/93)
([6833a02](http://github.com/abdes/asap/commit/6833a024644f742fb5ecda24841708843327eccb))
- [#93](http://github.com/abdes/asap/issues/93) properly set compiler options
([8fb2f02](http://github.com/abdes/asap/commit/8fb2f02377307f6ab86191b56d036cf7d85d31f0))
- [#97](http://github.com/abdes/asap/issues/97) cryptest runs in wrong directory
when in sub-project
([dea86d4](http://github.com/abdes/asap/commit/dea86d4316ae85cfbe18b521edf56af92c22d07f))
- [#98](http://github.com/abdes/asap/issues/98) standard-cpm test case not
running properly when in a sub-project
([96a78f7](http://github.com/abdes/asap/commit/96a78f741bda12a7730ca3943ace4c24070dd431))
- adjust header files path for install
([e28a9b1](http://github.com/abdes/asap/commit/e28a9b133f0aea370b317feb1ed7feafc7311752))
- duplicate cryptest.exe target
([2c39b76](http://github.com/abdes/asap/commit/2c39b764bf88ffb4029becdf6e04208c79bc9c98))
- missing compiler definitions for c++ files
([8e6ed7f](http://github.com/abdes/asap/commit/8e6ed7f95b1db2e0806e1e55aafdd25d41a3a196))
- reorganize options and disable tests when CRYPTOPP_BUILD_TESTING is OFF
([#96](http://github.com/abdes/asap/issues/96))
([cbed9fb](http://github.com/abdes/asap/commit/cbed9fb37ed698a09bca5174cbdf5e2d5d428b6f))
- use correct lib in linker options
([184f30b](http://github.com/abdes/asap/commit/184f30b56bcbca24582ae374a50b0b28a517c4f4))
### Documentation
- add instruction for conventional commits and changelog
([26194ff](http://github.com/abdes/asap/commit/26194ff3d1db5c50fd1c81ed59ec0115eb26b73c))
- add warning regarding version format in tags
([96f73bb](http://github.com/abdes/asap/commit/96f73bb12777e4679c12c22e761f6e95e6a9abfd))
- update after refactoring
([ff63aa4](http://github.com/abdes/asap/commit/ff63aa4694334161c922ab0f8d434340d2993644))

289
externals/cryptopp-cmake/CMakeLists.txt vendored Normal file
View File

@@ -0,0 +1,289 @@
# ===-----------------------------------------------------------------------===#
# Distributed under the 3-Clause BSD License. See accompanying file LICENSE or
# copy at https://opensource.org/licenses/BSD-3-Clause).
# SPDX-License-Identifier: BSD-3-Clause
# ===-----------------------------------------------------------------------===#
# ------------------------------------------------------------------------------
# CMake basic options
# ------------------------------------------------------------------------------
include(${CMAKE_CURRENT_LIST_DIR}/cmake/cmake_minimum_required.cmake)
cmake_minimum_required(VERSION ${CRYPTOPP_MINIMUM_CMAKE_VERSION})
# List of directories specifying a search path for CMake modules to be loaded by
# the include() or find_package() commands before checking the default modules
# that come with CMake.
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
# Setup our override file, in which we may cleanup cmake's default compiler
# options, based on what we are doing.
set(CMAKE_USER_MAKE_RULES_OVERRIDE "ResetInitialCompilerOptions")
# ------------------------------------------------------------------------------
# Project description and (meta) information
# ------------------------------------------------------------------------------
# Get git revision
include(GetGitRevisionDescription)
get_git_head_revision(GIT_REFSPEC GIT_SHA1)
string(SUBSTRING "${GIT_SHA1}" 0 12 GIT_REV)
if(NOT GIT_SHA1)
set(GIT_REV "0")
endif()
set(META_PROJECT_NAME "cryptopp-cmake")
set(META_PROJECT_DESCRIPTION "Free C++ class library of cryptographic schemes")
set(META_GITHUB_REPO "https://github.com/weidai11/cryptopp")
set(META_VERSION_MAJOR "8")
set(META_VERSION_MINOR "9")
set(META_VERSION_PATCH "0")
set(META_VERSION_REVISION "${GIT_REV}")
set(META_VERSION
"${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH}"
)
set(META_NAME_VERSION
"${META_PROJECT_NAME} v${META_VERSION} (${META_VERSION_REVISION})"
)
# ------------------------------------------------------------------------------
# Project Declaration
# ------------------------------------------------------------------------------
# Declare project
project(
"${META_PROJECT_NAME}"
VERSION "${META_VERSION}"
DESCRIPTION "${META_PROJECT_DESCRIPTION}"
HOMEPAGE_URL "${META_GITHUB_REPO}"
LANGUAGES CXX C ASM
)
# cmake-format: on
message("=> Project : ${PROJECT_NAME} v${cryptopp-cmake_VERSION}")
# ============================================================================
# Settable options
# ============================================================================
function(cryptopp_deprecated_option old_name new_name description default)
if(DEFINED ${old_name})
message(
DEPRECATION
"${old_name} is a deprecated option and will be ignored after 8.8.x + 3. Use ${new_name} instead"
)
set(default ${${old_name}})
endif()
option(${new_name} ${description} ${default})
endfunction()
option(
CRYPTOPP_USE_INTERMEDIATE_OBJECTS_TARGET
"Use a common intermediate objects target for the static and shared library targets"
ON
)
if(CRYPTOPP_INCLUDE_PREFIX)
set(CRYPTOPP_INCLUDE_PREFIX
${CRYPTOPP_INCLUDE_PREFIX}
CACHE STRING
"Set the dir where the headers get installed. Defaults to cryptopp."
)
else()
set(CRYPTOPP_INCLUDE_PREFIX
"cryptopp"
CACHE STRING
"Set the dir where the headers get installed. Defaults to cryptopp."
)
endif()
if(CRYPTOPP_SOURCES)
set(CRYPTOPP_SOURCES
${CRYPTOPP_SOURCES}
CACHE PATH
"Use the provided location for crypto++ sources; do not fetch"
)
else()
set(CRYPTOPP_SOURCES
""
CACHE PATH
"Use the provided location for crypto++ sources; do not fetch"
)
endif()
cryptopp_deprecated_option(
USE_OPENMP
CRYPTOPP_USE_OPENMP
"Enable OpenMP to parallelize some of the algorithms. Note that this isn't always faster, see https://www.cryptopp.com/wiki/OpenMP"
OFF
)
# These are IA-32 options.
cryptopp_deprecated_option(DISABLE_ASM CRYPTOPP_DISABLE_ASM "Disable ASM" OFF)
cryptopp_deprecated_option(DISABLE_SSSE3 CRYPTOPP_DISABLE_SSSE3 "Disable SSSE3" OFF)
cryptopp_deprecated_option(DISABLE_SSE4 CRYPTOPP_DISABLE_SSE4 "Disable SSE4" OFF)
cryptopp_deprecated_option(DISABLE_AESNI CRYPTOPP_DISABLE_AESNI "Disable AES-NI" OFF)
cryptopp_deprecated_option(DISABLE_CLMUL CRYPTOPP_DISABLE_CLMUL "Disable CLMUL" OFF)
cryptopp_deprecated_option(DISABLE_SHA CRYPTOPP_DISABLE_SHA "Disable SHA" OFF)
cryptopp_deprecated_option(DISABLE_AVX CRYPTOPP_DISABLE_AVX "Disable AVX" OFF)
cryptopp_deprecated_option(DISABLE_AVX2 CRYPTOPP_DISABLE_AVX2 "Disable AVX2" OFF)
# These are ARM A-32 options
cryptopp_deprecated_option(DISABLE_ARM_NEON CRYPTOPP_DISABLE_ARM_NEON "Disable NEON" OFF)
# These are Aarch64 options
cryptopp_deprecated_option(DISABLE_ARM_AES CRYPTOPP_DISABLE_ARM_AES "Disable ASIMD" OFF)
cryptopp_deprecated_option(DISABLE_ARM_AES CRYPTOPP_DISABLE_ARM_AES "Disable AES" OFF)
cryptopp_deprecated_option(DISABLE_ARM_PMULL CRYPTOPP_DISABLE_ARM_PMULL "Disable PMULL" OFF)
cryptopp_deprecated_option(DISABLE_ARM_SHA CRYPTOPP_DISABLE_ARM_SHA "Disable SHA" OFF)
# These are PowerPC options
cryptopp_deprecated_option(DISABLE_ALTIVEC CRYPTOPP_DISABLE_ALTIVEC "Disable Altivec" OFF)
cryptopp_deprecated_option(DISABLE_POWER7 CRYPTOPP_DISABLE_POWER7 "Disable POWER7" OFF)
cryptopp_deprecated_option(DISABLE_POWER8 CRYPTOPP_DISABLE_POWER8 "Disable POWER8" OFF)
cryptopp_deprecated_option(DISABLE_POWER9 CRYPTOPP_DISABLE_POWER9 "Disable POWER9" OFF)
option(
CRYPTOPP_USE_MASTER_BRANCH
"Get crypto++ from the master branch, not from a release tag"
FALSE
)
option(CRYPTOPP_BUILD_TESTING "Build library tests" ON)
option(
CRYPTOPP_BUILD_DOCUMENTATION
"Use Doxygen to create the HTML-based API documentation"
OFF
)
# Override the CRYPTOPP_INSTALL option to ON/OFF to respectively force
# install/no-install behavior for cryptopp module. This is particularly useful
# when `cryptopp` is used as a sub-project with CMake and the user publicly
# depends on it and wants to have a self-contained install.
option(CRYPTOPP_INSTALL "Generate the install target for this project." ON)
# Crypto++ DOES NOT properly support DLL builds. The old DLL was the FIPS one,
# which is being abandoned. Therefore, we only allow static builds until that
# situation is solved.
#
# See https://cryptopp.com/wiki/Wrapper_DLL for a workaround.
option(CRYPTOPP_BUILD_SHARED "Build shared library" OFF)
if(${CRYPTOPP_BUILD_SHARED})
message(
FATAL_ERROR
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
"Crypto++ DOES NOT properly support DLL builds. The old DLL was the FIPS"
"one which is being abandoned.\nTherefore, we only allow static builds"
"until that situation changes.\n"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
)
endif()
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
set(CRYPTOPP_DEFAULT_BUILD_TYPE "Debug")
else()
set(CRYPTOPP_DEFAULT_BUILD_TYPE "Release")
endif(EXISTS "${CMAKE_SOURCE_DIR}/.git")
# Set the possible values of build type for cmake-gui
if(CMAKE_CONFIGURATION_TYPES)
set(CMAKE_CONFIGURATION_TYPES
"Debug;Release"
CACHE STRING
"Semicolon separated list of supported configuration types, only supports debug and release, anything else will be ignored"
FORCE
)
set_property(
CACHE CMAKE_CONFIGURATION_TYPES
PROPERTY STRINGS "Debug" "Release"
)
endif()
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(
STATUS
"Setting build type to '${CRYPTOPP_DEFAULT_BUILD_TYPE}' as none was specified."
)
set(CMAKE_BUILD_TYPE
"${CRYPTOPP_DEFAULT_BUILD_TYPE}"
CACHE STRING
"Choose the type of build."
FORCE
)
endif()
# ---- Speedup build using ccache (needs CPM) ----
include(cmake/FasterBuild.cmake)
# ------------------------------------------------------------------------------
# Fetch / Find crypto++
# ------------------------------------------------------------------------------
# If CMake is invoked with an explicit option (cryptopp_SOURCE_DIR), setting
# the location for user-provided sources of crypto++, or if the automatic
# download fails, we use that option value to find the sources.
find_package(Git)
if(NOT CRYPTOPP_SOURCES)
include(GetCryptoppSources)
if(EXISTS ${cryptopp_SOURCE_DIR})
message(STATUS "Crypto++ auto fetched at: ${cryptopp_SOURCE_DIR}")
else()
message(FATAL_ERROR "Crypto++ auto fetch failed; cannot continue!")
endif()
else()
if(EXISTS ${CRYPTOPP_SOURCES})
message(
STATUS
"Crypto++ from user-specified location at: ${CRYPTOPP_SOURCES}"
)
set(cryptopp_SOURCE_DIR ${CRYPTOPP_SOURCES})
else()
message(
FATAL_ERROR
"User-provided location (${CRYPTOPP_SOURCES}) for crypto++ sources does not exit!"
)
endif()
endif()
if(Git_FOUND)
get_filename_component(
CRYPTOPP_CMAKE_PARENT_DIR
${cryptopp-cmake_SOURCE_DIR}
DIRECTORY
)
execute_process(
COMMAND
${CMAKE_COMMAND} -E env
GIT_CEILING_DIRECTORIES="${CRYPTOPP_CMAKE_PARENT_DIR}"
${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${cryptopp-cmake_SOURCE_DIR}
RESULT_VARIABLE cryptopp_CMAKE_GIT_RESULT
OUTPUT_VARIABLE cryptopp_GIT_BRANCH
ERROR_QUIET
)
if(cryptopp_CMAKE_GIT_RESULT EQUAL 0)
string(STRIP ${cryptopp_GIT_BRANCH} cryptopp_GIT_BRANCH)
endif()
endif()
if(NOT cryptopp_GIT_BRANCH)
set(cryptopp_GIT_BRANCH "master")
endif()
message(STATUS "Using branch ${cryptopp_GIT_BRANCH} for tests")
# ------------------------------------------------------------------------------
# Testing
# ------------------------------------------------------------------------------
if(CRYPTOPP_BUILD_TESTING)
enable_testing()
add_subdirectory(test)
endif()
# ------------------------------------------------------------------------------
# Add cryptopp CMake subdirectory
# ------------------------------------------------------------------------------
message("=> Module : cryptopp")
add_subdirectory(cryptopp)

View File

@@ -0,0 +1,237 @@
{
"version": 3,
"cmakeMinimumRequired": {
"major": 3,
"minor": 20,
"patch": 0
},
"configurePresets": [
{
"name": "base",
"description": "Base preset",
"hidden": true,
"generator": "Ninja",
"binaryDir": "${sourceDir}/out/build/${presetName}",
"installDir": "${sourceDir}/out/install/${presetName}",
"environment": {
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
},
"cacheVariables": {
"CRYPTOPP_BUILD_TESTING": "ON",
"USE_CCACHE": "ON"
}
},
{
"name": "debug",
"description": "Debug build",
"hidden": true,
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "release",
"description": "Release build",
"hidden": true,
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "x64",
"description": "64bit build (on windows)",
"hidden": true,
"architecture": {
"value": "x64",
"strategy": "external"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
}
},
{
"name": "compiler-clang",
"hidden": true,
"description": "Use clang as the C/C++ compiler",
"cacheVariables": {
"CMAKE_C_COMPILER": "/usr/bin/clang",
"CMAKE_CXX_COMPILER": "/usr/bin/clang++"
},
"condition": {
"type": "inList",
"string": "${hostSystemName}",
"list": ["Linux", "Darwin"]
}
},
{
"name": "compiler-gcc",
"hidden": true,
"description": "Use GCC as the C/C++ compiler",
"cacheVariables": {
"CMAKE_C_COMPILER": "/usr/bin/gcc",
"CMAKE_CXX_COMPILER": "/usr/bin/g++"
},
"condition": {
"type": "inList",
"string": "${hostSystemName}",
"list": ["Linux", "Darwin"]
}
},
{
"name": "dev-windows",
"description": "Default build in a dev environment",
"inherits": ["base", "debug", "x64"]
},
{
"name": "dev-linux",
"description": "Default build in a dev environment",
"inherits": ["base", "debug", "compiler-clang"]
},
{
"name": "dev-mac",
"description": "Default build in a dev environment",
"inherits": ["base", "debug", "compiler-clang"],
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Darwin"
}
},
{
"name": "dev-clang",
"description": "Basic build in a dev environment using clang",
"inherits": ["base", "debug", "compiler-clang"]
},
{
"name": "dev-gcc",
"description": "Basic build in a dev environment using clang",
"inherits": ["base", "debug", "compiler-gcc"]
},
{
"name": "rel-windows",
"description": "Default build in a dev environment",
"inherits": ["base", "release", "x64"]
},
{
"name": "rel-linux",
"description": "Default build in a dev environment",
"inherits": ["base", "release", "compiler-clang"]
},
{
"name": "rel-mac",
"description": "Default build in a dev environment",
"inherits": ["base", "release", "compiler-clang"],
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Darwin"
}
}
],
"buildPresets": [
{
"name": "dev-base",
"hidden": true,
"jobs": 4,
"verbose": true
},
{
"name": "dev-windows",
"configurePreset": "dev-windows",
"inherits": ["dev-base"]
},
{
"name": "dev-clang",
"configurePreset": "dev-clang",
"inherits": ["dev-base"]
},
{
"name": "dev-linux",
"configurePreset": "dev-linux",
"inherits": ["dev-clang"]
},
{
"name": "dev-mac",
"configurePreset": "dev-mac",
"inherits": ["dev-clang"]
},
{
"name": "dev-gcc",
"configurePreset": "dev-gcc",
"inherits": ["dev-base"]
},
{
"name": "rel-base",
"hidden": true,
"jobs": 4,
"verbose": true
},
{
"name": "rel-windows",
"configurePreset": "rel-windows",
"inherits": ["rel-base"]
},
{
"name": "rel-linux",
"configurePreset": "rel-linux",
"inherits": ["rel-base"]
},
{
"name": "rel-mac",
"configurePreset": "rel-mac",
"inherits": ["rel-base"]
}
],
"testPresets": [
{
"name": "test-base",
"description": "Enable output on failure",
"hidden": true,
"output": {
"outputOnFailure": true
}
},
{
"name": "dev-test-windows",
"inherits": "test-base",
"configurePreset": "dev-windows"
},
{
"name": "rel-test-windows",
"inherits": "test-base",
"configurePreset": "rel-windows"
},
{
"name": "dev-test-linux",
"inherits": "test-base",
"configurePreset": "dev-linux"
},
{
"name": "rel-test-linux",
"inherits": "test-base",
"configurePreset": "rel-linux"
},
{
"name": "dev-test-mac",
"inherits": "test-base",
"configurePreset": "dev-mac"
},
{
"name": "rel-test-mac",
"inherits": "test-base",
"configurePreset": "rel-mac"
},
{
"name": "dev-test-clang",
"inherits": "test-base",
"configurePreset": "dev-clang"
},
{
"name": "dev-test-gcc",
"inherits": "test-base",
"configurePreset": "dev-gcc"
}
]
}

View File

@@ -0,0 +1,89 @@
# Contributing to this project
👍🎉 Thanks for taking the time to contribute! 🎉👍
## Table of Contents
- [Conventional Commits](#conventional-commits)
- [Conventional Changelog](#conventional-changelog)
- [New Release Process](#new-release-process)
- [Testing](#testing)
- [GitHub Actions](#github-actions)
## Conventional Commits
The project is setup for husky and [conventional
commits](https://www.conventionalcommits.org/en/v1.0.0/) to keep some standard
for the commit messages.
In order to be able to use that, have `nodejs` and `npm` installed in your
environment and run the following just one time after you clone this project:
```shell
npx husky install
npm install -g @commitlint/cli @commitlint/config-conventional
```
Commit message are linted automatically.
## Conventional Changelog
The project is also setup for [conventional
changelog](https://github.com/conventional-changelog/standard-version) to
automatically generate change logs.
In order to be able to use that, have `nodejs` and `npm` installed in your
environment and run the following just one time after you clone this project:
```shell
npm install -g standard-version
```
When the project is ready for a new release, run the following command in the
project root to update the `CHANGELOG.md` and the `CMakeLists.txt` files:
```shell
npx standard-version --skip.commit --skip.tag -r M.m.p
```
M.m.p is version number to be released:
The version number will be automatically bumped in the `CMakeLists.txt` and the
`CHANGELOG.md` file will be automatically updated. Open both of them, check the
changes, lint and format the `CHANGELOG.md` and write any additional notes, then
commit.
## Testing
Testing is integrated into the project and is automated via `ctest`.
## New release process
Create a new tag for the release by using the following command:
```shell
git tag -a CRYPTOPP_M_m_p -m "Blah blah blah..."
```
> :warning: **Pay attention to the format of the tag**: the version uses `_` and
> not `.`!
> Also note that *patch tags* will also have a sequential number suffix (e.g.
> CRYPTOPP_8_7_0_1).
Push with the following command:
```shell
git push --follow-tags
```
## GitHub Actions
The automatic GitHub actions will take care of the rest, including the
multi-platform builds, the testing, and when everything is successful, the
creation of a release and its associated artifacts.
> Here are the links where you can check the result of the actions:
>
> [GitHubActions](https://github.com/abdes/cryptopp-cmake/actions)
>
> [GitHub Releases](https://github.com/abdes/cryptopp-cmake/releases)

29
externals/cryptopp-cmake/LICENSE vendored Normal file
View File

@@ -0,0 +1,29 @@
BSD 3-Clause License
Copyright (c) 2018, The Authors.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT HOLDER OR CONTRIBUTORS 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.

185
externals/cryptopp-cmake/README.md vendored Normal file
View File

@@ -0,0 +1,185 @@
# Crypto++ CMake
<div align="center">
-+- Build Status -+-
[![Build status - master][build-status-master-badge]][build-matrix]
-+-
[![Latest release][release-badge]][latest-release]
[![Commits][last-commit-badge]][commits]
[![Linux][linux-badge]][latest-release]
[![Windows][windows-badge]][latest-release]
[![Mac OS][macos-badge]][latest-release]
[![License][license-badge]][license]
</div>
## Introduction
This repository contains CMake files for Wei Dai's Crypto++
(<https://github.com/weidai11/cryptopp>) for those who use the library in
[**Modern CMake**](https://cliutils.gitlab.io/modern-cmake/) projects.
See this
[announcement](https://groups.google.com/g/cryptopp-users/c/9oDbTm8qWps) from
crypto++ maintainers.
The emphasis on _Modern_ here is very important. In 2022, we have some really
good solutions to many of the build problems developers used to waste a lot of
time on. CMake in particular has made so much progress to become one of the most
widely used build systems for C++. But, we're not talking about CMake 2.x here.
We're talking about CMake 3.11+ and maybe even CMake 3.24+.
For more details on this topic, see down below...
## Table of Contents
- [Crypto++ CMake](#crypto-cmake)
- [Introduction](#introduction)
- [Table of Contents](#table-of-contents)
- [Before you ask](#before-you-ask)
- [Versioning principles](#versioning-principles)
- [Standard usage](#standard-usage)
- [Using a local copy of crypto++](#using-a-local-copy-of-crypto)
- [Requesting the master branch of cryptopp](#requesting-the-master-branch-of-cryptopp)
- [Other ways](#other-ways)
- [Why Modern CMake?](#why-modern-cmake)
## Before you ask
- **Can you support an older version of CMake? You really don't need 3.21...**
No.
This is an opinionated fork with the main purpose being to stay always on a
recent version of CMake. We believe that the build system should be the latest
unlike compilers and Operating Systems. If you want to stay on old versions,
please take a look at the old repo.
- **Can you fix the shared library build? I really like DLLs...**
Me too, but No.
Crypto++ does not properly export symbols and manage visibility. You can
request this feature from the crypto++ project maintainers. The old DLL build
was only for FIPS version, with limited symbol exports. That version is going
end-of-life and there is no point from supporting it here.
If you love DLLs, you can make a [_Wrapper
DLL_](https://cryptopp.com/wiki/Wrapper_DLL) as explained on crypto++ wiki.
The CMakeLists.txt in this project are already built for shared and static
builds, but the shared build is locked until crypto++ is ready for it.
- **Why did you change XXX? It used to work like YYY before...**
I don't know.
I use crypto++ in my project, and I use it in a way that I learnt and
improved over time through experience, extensive reading of other peoples'
experiences, and sticking as close as possible to modern cmake practices. I'm
open to new ways and suggestions, especially if they come via a tracked issue,
a rationale and a pull request. If you have a valid use case, please document
it in an issue and let's find someone to help make it happen for you. It's
Open Source :smiley:
## Versioning principles
This project releases track the [crypto++](https://github.com/weidai11/cryptopp)
releases. In other words, every time a new release of _crypto++_ happens, this
project gets updated to take into account changes in source files, compiler
options etc, and will see a new release with the same number than _crypto++_.
At times, bug fixes in this project will happen before a new _crypto++_ release
is published. When a certain number of fixes have been added, and depending on
the criticality of the defects, an additional release tag may be made. These
_patch tags_ will never introduce any additional changes in `crypto++` itself.
Main release tags will have the format: `CRYPTOPP_M_m_p`, while _patch tags_
will have the format `CRYPTOPP_M_m_p_f`, where `M.m.p` represents the `crypto++`
version and `f` is a suffix number incremented each time a _patch tag_ is
created. _Patch tags_ will keep the same `crypto++` version as the main release
tag.
> As always, if you want to get the latest and greatest, always track the
> master branch.
## Standard usage
- Get this project using your favorite method (clone as submodule, get with
[FetchContent](https://cmake.org/cmake/help/latest/module/FetchContent.html),
get with [CPM](https://github.com/cpm-cmake/CPM.cmake)...)
- In your master CMakeLists.txt, add the following:
```cmake
add_subdirectory(xxxx)
# where xxx is the location where you put the cryptopp-cmake files
```
That's pretty much it. You'll be able to link against `cryptopp` or the scoped
alias `cryptopp::cryptopp` and have cmake handle everything else for you.
An example is located in the
[test/standard-cpm](https://github.com/abdes/cryptopp-cmake/tree/master/test)
directory.
## Using a local copy of crypto++
Certain users would prefer to have a fully disconnected project, and in such
scenario both the crypto++ source package and the cryptopp-cmake source package
would be pre-downloaded and then unpacked somewhere.
You would still need to add cryptopp-cmake as a subdirectory in your master
`CMakeLists.txt`, and you can set it up in such a way to use your local copy of
crypto++ via the option `CRYPTOPP_SOURCES`. Just set that option in the cmake
command line or in your CMakeLists.txt to point to the crypto++ source
directory. The rest will be taken care of for you.
## Requesting the master branch of cryptopp
If you want to test the bleeding edge of crypto++ with cmake, simply set the
option `CRYPTOPP_USE_MASTER_BRANCH` in your CMakeLists.txt or the cmake command
line and as usual, add the cryptopp-cmake as a subdirectory.
## Other ways
There are many other ways to use this project, including by directly picking the
files you need and adding them to your own project, by getting the package via
conan, etc... Take some time to read the source code, and make suggestions if
you need a new usage scenario via a new issue.
## Why Modern CMake?
Have a look at [Installing
CMake](https://cliutils.gitlab.io/modern-cmake/chapters/intro/installing.html)
from the online 'Modern CMake' book, to see a recent snapshot of which version
of CMake is being installed by default on Linux distributions.
![Packaging Status](https://repology.org/badge/vertical-allrepos/cmake.svg?columns=3&minversion=3.10.0)
And more than that, it's so easy to install a modern version of CMake on
Linux/MacOS/Windows, and many other OSes.
Looking at the release notes of CMake versions from 3.0 till now, a minimum
version requirement of
[3.21](https://cmake.org/cmake/help/latest/release/3.21.html) is a good starting
point. That release brings in particular presets and some nice quality of life
features that will make the maintenance and the use of this project much simpler
and pleasant. After all, there is no justification for doing free Open Source
without pleasure :smiley:
[build-matrix]: https://github.com/abdes/cryptopp-cmake/actions/workflows/cmake-build.yml
[build-status-master-badge]: https://github.com/abdes/cryptopp-cmake/actions/workflows/cmake-build.yml/badge.svg?branch=master
[commits]: https://github.com/abdes/cryptopp-cmake/commits
[last-commit-badge]: https://img.shields.io/github/last-commit/abdes/cryptopp-cmake
[latest-release]: https://github.com/abdes/cryptopp-cmake/releases/latest
[license-badge]: https://img.shields.io/github/license/abdes/cryptopp-cmake
[license]: https://opensource.org/licenses/BSD-3-Clause
[linux-badge]: https://img.shields.io/badge/OS-linux-blue
[macos-badge]: https://img.shields.io/badge/OS-macOS-blue
[release-badge]: https://img.shields.io/github/v/release/abdes/cryptopp-cmake
[windows-badge]: https://img.shields.io/badge/OS-windows-blue

View File

@@ -0,0 +1,35 @@
# ===-----------------------------------------------------------------------===#
# Distributed under the 3-Clause BSD License. See accompanying file LICENSE or
# copy at https://opensource.org/licenses/BSD-3-Clause).
# SPDX-License-Identifier: BSD-3-Clause
# ===-----------------------------------------------------------------------===#
set(CPM_DOWNLOAD_VERSION 0.38.5)
if(CPM_SOURCE_CACHE)
# Expand relative path. This is important if the provided path contains a
# tilde (~)
get_filename_component(CPM_SOURCE_CACHE ${CPM_SOURCE_CACHE} ABSOLUTE)
set(CPM_DOWNLOAD_LOCATION
"${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake"
)
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
set(CPM_DOWNLOAD_LOCATION
"$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake"
)
else()
set(CPM_DOWNLOAD_LOCATION
"${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake"
)
endif()
if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}")
file(
DOWNLOAD
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
${CPM_DOWNLOAD_LOCATION}
)
endif()
include(${CPM_DOWNLOAD_LOCATION})

View File

@@ -0,0 +1,42 @@
# ===-----------------------------------------------------------------------===#
# Distributed under the 3-Clause BSD License. See accompanying file LICENSE or
# copy at https://opensource.org/licenses/BSD-3-Clause).
# SPDX-License-Identifier: BSD-3-Clause
# ===-----------------------------------------------------------------------===#
include(CMakePackageConfigHelpers)
# ------------------------------------------------------------------------------
# Generate module config files for cmake and pkgconfig
# ------------------------------------------------------------------------------
function(_module_cmake_config_files)
message(STATUS "[cryptopp] Generating cmake package config files")
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/cryptoppConfigVersion.cmake
COMPATIBILITY SameMajorVersion
)
endfunction()
function(_module_pkgconfig_files)
message(STATUS "[cryptopp] Generating pkgconfig files")
set(MODULE_PKGCONFIG_FILE cryptopp.pc)
if(CMAKE_BUILD_TYPE EQUAL "Debug")
get_target_property(target_debug_postfix cryptopp DEBUG_POSTFIX)
if(${target_debug_postfix} MATCHES "-NOTFOUND$")
set(target_debug_postfix "")
endif()
endif()
set(MODULE_LINK_LIBS "-lcryptopp${target_debug_postfix}")
configure_file(
config.pc.in
${CMAKE_CURRENT_BINARY_DIR}/${MODULE_PKGCONFIG_FILE}
@ONLY
)
endfunction()
function(create_module_config_files)
_module_cmake_config_files()
_module_pkgconfig_files()
endfunction()

View File

@@ -0,0 +1,23 @@
# ===-----------------------------------------------------------------------===#
# Distributed under the 3-Clause BSD License. See accompanying file LICENSE or
# copy at https://opensource.org/licenses/BSD-3-Clause).
# SPDX-License-Identifier: BSD-3-Clause
# ===-----------------------------------------------------------------------===#
# ------------------------------------------------------------------------------
# Reduce build time by using ccache when available
# ------------------------------------------------------------------------------
find_program(CCACHE_TOOL_PATH ccache)
if(NOT WIN32 AND USE_CCACHE AND CCACHE_TOOL_PATH)
message(STATUS "Using ccache (${CCACHE_TOOL_PATH}) (via wrapper).")
# see https://github.com/TheLartians/Ccache.cmake enables CCACHE support
# through the USE_CCACHE flag possible values are: YES, NO or equivalent
include("${CMAKE_CURRENT_LIST_DIR}/CPM.cmake")
cpmaddpackage("gh:TheLartians/Ccache.cmake@1.2.3")
elseif(WIN32 AND USE_CCACHE AND CCACHE_TOOL_PATH)
set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_TOOL_PATH} CACHE STRING "" FORCE)
set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_TOOL_PATH} CACHE STRING "" FORCE)
message(STATUS "Using ccache (${CCACHE_TOOL_PATH}).")
endif()

View File

@@ -0,0 +1,43 @@
# ===-----------------------------------------------------------------------===#
# Distributed under the 3-Clause BSD License. See accompanying file LICENSE or
# copy at https://opensource.org/licenses/BSD-3-Clause).
# SPDX-License-Identifier: BSD-3-Clause
# ===-----------------------------------------------------------------------===#
include(FetchContent)
set(version_underscore
"${cryptopp-cmake_VERSION_MAJOR}_${cryptopp-cmake_VERSION_MINOR}_${cryptopp-cmake_VERSION_PATCH}"
)
if(GIT_FOUND)
if(${CRYPTOPP_USE_MASTER_BRANCH})
set(source_location "master")
else()
set(source_location "CRYPTOPP_${version_underscore}")
endif()
fetchcontent_declare(
cryptopp
GIT_REPOSITORY ${cryptopp-cmake_HOMEPAGE_URL}
GIT_TAG ${source_location}
QUIET
SOURCE_DIR
${CRYPTOPP_INCLUDE_PREFIX}
)
else()
message(STATUS "Downloading crypto++ from URL...")
cmake_policy(SET CMP0135 NEW)
set(source_location "${cryptopp-cmake_HOMEPAGE_URL}/")
if(NOT ${CRYPTOPP_USE_MASTER_BRANCH})
string(
APPEND
source_location
"releases/download/CRYPTOPP_${version_underscore}/cryptopp${cryptopp-cmake_VERSION_MAJOR}${cryptopp-cmake_VERSION_MINOR}${cryptopp-cmake_VERSION_PATCH}"
)
else()
string(APPEND source_location "archive/refs/heads/master")
endif()
fetchcontent_declare(
cryptopp
URL "${source_location}.zip" QUIET SOURCE_DIR ${CRYPTOPP_INCLUDE_PREFIX}
)
endif()
fetchcontent_populate(cryptopp)

View File

@@ -0,0 +1,126 @@
# * Returns a version string from Git
#
# These functions force a re-configure on each git commit so that you can trust
# the values of the variables in your build system.
#
# get_git_head_revision(<refspecvar> <hashvar> [<additional arguments to git
# describe> ...])
#
# Returns the refspec and sha hash of the current head revision
#
# git_describe(<var> [<additional arguments to git describe> ...])
#
# Returns the results of git describe on the source tree, and adjusting the
# output so that it tests false if an error occurs.
#
# git_get_exact_tag(<var> [<additional arguments to git describe> ...])
#
# Returns the results of git describe --exact-match on the source tree, and
# adjusting the output so that it tests false if there was no exact matching
# tag.
#
# Requires CMake 2.6 or newer (uses the 'function' command)
#
# Original Author: 2009-2010 Ryan Pavlik <rpavlik@iastate.edu>
# <abiryan@ryand.net> http://academic.cleardefinition.com Iowa State University
# HCI Graduate Program/VRAC
#
# Copyright Iowa State University 2009-2010. Distributed under the Boost
# Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy
# at http://www.boost.org/LICENSE_1_0.txt)
if(__get_git_revision_description)
return()
endif()
set(__get_git_revision_description YES)
# We must run the following at "include" time, not at function call time, to
# find the path to this module rather than the path to a calling list file
get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH)
function(get_git_head_revision _refspecvar _hashvar)
set(GIT_PARENT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(GIT_DIR "${GIT_PARENT_DIR}/.git")
while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories
set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}")
get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH)
if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT)
# We have reached the root directory, we are not in git
set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
return()
endif()
set(GIT_DIR "${GIT_PARENT_DIR}/.git")
endwhile()
# check if this is a submodule
if(NOT IS_DIRECTORY ${GIT_DIR})
file(READ ${GIT_DIR} submodule)
string(
REGEX REPLACE
"gitdir: (.*)\n$"
"\\1"
GIT_DIR_RELATIVE
${submodule}
)
get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH)
get_filename_component(
GIT_DIR
${SUBMODULE_DIR}/${GIT_DIR_RELATIVE}
ABSOLUTE
)
endif()
set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data")
if(NOT EXISTS "${GIT_DATA}")
file(MAKE_DIRECTORY "${GIT_DATA}")
endif()
if(NOT EXISTS "${GIT_DIR}/HEAD")
return()
endif()
set(HEAD_FILE "${GIT_DATA}/HEAD")
configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY)
configure_file(
"${_gitdescmoddir}/GetGitRevisionDescription.cmake.in"
"${GIT_DATA}/grabRef.cmake"
@ONLY
)
include("${GIT_DATA}/grabRef.cmake")
set(${_refspecvar} "${HEAD_REF}" PARENT_SCOPE)
set(${_hashvar} "${HEAD_HASH}" PARENT_SCOPE)
endfunction()
function(git_describe _var)
if(NOT GIT_FOUND)
find_package(Git QUIET)
endif()
get_git_head_revision(refspec hash)
if(NOT GIT_FOUND)
set(${_var} "GIT-NOTFOUND" PARENT_SCOPE)
return()
endif()
if(NOT hash)
set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE)
return()
endif()
execute_process(
COMMAND "${GIT_EXECUTABLE}" describe ${hash} ${ARGN}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
RESULT_VARIABLE res
OUTPUT_VARIABLE out
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT res EQUAL 0)
set(out "${out}-${res}-NOTFOUND")
endif()
set(${_var} "${out}" PARENT_SCOPE)
endfunction()
function(git_get_exact_tag _var)
git_describe(out --exact-match ${ARGN})
set(${_var} "${out}" PARENT_SCOPE)
endfunction()

View File

@@ -0,0 +1,46 @@
#
# Internal file for GetGitRevisionDescription.cmake
#
# Requires CMake 2.6 or newer (uses the 'function' command)
#
# Original Author:
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
# http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC
#
# Copyright Iowa State University 2009-2010.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
set(HEAD_HASH)
set(HEAD_REF)
if (NOT EXISTS "@HEAD_FILE@")
return()
endif()
file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024)
string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS)
if(HEAD_CONTENTS MATCHES "ref")
# named branch
string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}")
if(EXISTS "@GIT_DIR@/${HEAD_REF}")
configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
elseif(EXISTS "@GIT_DIR@/packed-refs")
configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY)
file(READ "@GIT_DATA@/packed-refs" PACKED_REFS)
if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}")
set(HEAD_HASH "${CMAKE_MATCH_1}")
endif()
endif()
else()
# detached HEAD
configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY)
endif()
if(NOT HEAD_HASH AND EXISTS "@GIT_DATA@/head-ref")
file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024)
string(STRIP "${HEAD_HASH}" HEAD_HASH)
endif()

View File

@@ -0,0 +1,34 @@
# ===-----------------------------------------------------------------------===#
# Distributed under the 3-Clause BSD License. See accompanying file LICENSE or
# copy at https://opensource.org/licenses/BSD-3-Clause).
# SPDX-License-Identifier: BSD-3-Clause
# ===-----------------------------------------------------------------------===#
# This module is loaded by `cmake` while enabling support for each language from
# either the project() or enable_language() commands. It is loaded after CMake's
# builtin compiler and platform information modules have been loaded but before
# the information is used. The file may set platform information variables to
# override CMake's defaults.
#
# To load this module, set the variable `CMAKE_USER_MAKE_RULES_OVERRIDE` before
# you declare the project or enable a language:
# ~~~
# set(CMAKE_USER_MAKE_RULES_OVERRIDE "ResetInitialCompilerOptions")
# ~~~
# We use this module to strip compiler options that are not really needed but
# will cause compatibility issues with `ccache`.
if(MSVC AND USE_CCACHE)
# As of ccache 4.6, /Zi option automatically added by cmake is unsupported.
# Given that we are doing ccache only in development environments (USE_CCACHE
# controls if ccache is enabled), we can just strip that option.
macro(strip_unwanted_options_from cmake_flags)
if(${cmake_flags} MATCHES "/Zi")
string(REPLACE "/Zi" "/Z7" ${cmake_flags} ${${cmake_flags}})
endif()
endmacro()
strip_unwanted_options_from(CMAKE_CXX_FLAGS_DEBUG_INIT)
strip_unwanted_options_from(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT)
strip_unwanted_options_from(CMAKE_C_FLAGS_DEBUG_INIT)
strip_unwanted_options_from(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT)
endif()

View File

@@ -0,0 +1,139 @@
# Based on the Qt 5 processor detection code, so should be very accurate
# https://qt.gitorious.org/qt/qtbase/blobs/master/src/corelib/global/qprocessordetection.h
# Currently handles arm (v5, v6, v7), x86 (32/64), ia64, and ppc (32/64)
# Regarding POWER/PowerPC, just as is noted in the Qt source, "There are many
# more known variants/revisions that we do not handle/detect."
set(archdetect_c_code
"
/*
ARM family, known revisions: V5, V6, V7, V8
*/
#if defined(__arm__) || defined(__TARGET_ARCH_ARM) || defined(_M_ARM) || defined(_M_ARM64) || defined(_M_ARM64EC) || defined(__aarch64__) || defined(__ARM64__)
# if defined(__aarch64__) || defined(__ARM64__) || defined(_M_ARM64) || defined(_M_ARM64EC)
# error cmake_ARCH arm64
# else
# error cmake_ARCH arm
# endif
#elif defined(__CYGWIN__)
#error cmake_ARCH cygwin
#elif defined(__MINGW64__)
#error cmake_ARCH mingw64
#elif defined(__MINGW32__)
#error cmake_ARCH mingw32
#elif defined(__i386) || defined(__i386__) || defined(_M_IX86)
#error cmake_ARCH i386
#elif defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(_M_X64)
#error cmake_ARCH x86_64
#elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64)
#error cmake_ARCH ia64
#elif defined(__ppc__) || defined(__ppc) || defined(__powerpc__) \\
|| defined(_ARCH_COM) || defined(_ARCH_PWR) || defined(_ARCH_PPC) \\
|| defined(_M_MPPC) || defined(_M_PPC)
#if defined(__ppc64__) || defined(__powerpc64__) || defined(__64BIT__)
#error cmake_ARCH ppc64
#else
#error cmake_ARCH ppc
#endif
#endif
#error cmake_ARCH unknown
"
)
# Set ppc_support to TRUE before including this file or ppc and ppc64 will be
# treated as invalid architectures since they are no longer supported by Apple
function(target_architecture output_var)
if(APPLE AND CMAKE_OSX_ARCHITECTURES)
# On OS X we use CMAKE_OSX_ARCHITECTURES *if* it was set First let's
# normalize the order of the values
# Note that it's not possible to compile PowerPC applications if you are
# using the OS X SDK version 10.6 or later - you'll need 10.4/10.5 for that,
# so we disable it by default See this page for more information:
# http://stackoverflow.com/questions/5333490/how-can-we-restore-ppc-ppc64-as-well-as-full-10-4-10-5-sdk-support-to-xcode-4
# Architecture defaults to i386 or ppc on OS X 10.5 and earlier, depending
# on the CPU type detected at runtime. On OS X 10.6+ the default is x86_64
# if the CPU supports it, i386 otherwise.
foreach(osx_arch ${CMAKE_OSX_ARCHITECTURES})
if("${osx_arch}" STREQUAL "ppc" AND ppc_support)
set(osx_arch_ppc TRUE)
elseif("${osx_arch}" STREQUAL "i386")
set(osx_arch_i386 TRUE)
elseif("${osx_arch}" STREQUAL "x86_64")
set(osx_arch_x86_64 TRUE)
elseif("${osx_arch}" STREQUAL "ppc64" AND ppc_support)
set(osx_arch_ppc64 TRUE)
elseif("${osx_arch}" STREQUAL "arm64")
set(osx_arch_arm64 TRUE)
elseif("${osx_arch}" STREQUAL "$(ARCHS_STANDARD)")
set(osx_arch_arm64 TRUE)
set(osx_arch_x86_64 TRUE)
else()
message(FATAL_ERROR "Invalid OS X arch name: ${osx_arch}")
endif()
endforeach()
# Now add all the architectures in our normalized order
if(osx_arch_ppc)
list(APPEND ARCH ppc)
endif()
if(osx_arch_i386)
list(APPEND ARCH i386)
endif()
if(osx_arch_x86_64)
list(APPEND ARCH x86_64)
endif()
if(osx_arch_ppc64)
list(APPEND ARCH ppc64)
endif()
if(osx_arch_arm64)
list(APPEND ARCH arm64)
endif()
else()
file(WRITE "${CMAKE_BINARY_DIR}/arch.c" "${archdetect_c_code}")
enable_language(C)
# Detect the architecture in a rather creative way... This compiles a small
# C program which is a series of ifdefs that selects a particular #error
# preprocessor directive whose message string contains the target
# architecture. The program will always fail to compile (both because file
# is not a valid C program, and obviously because of the presence of the
# #error preprocessor directives... but by exploiting the preprocessor in
# this way, we can detect the correct target architecture even when
# cross-compiling, since the program itself never needs to be run (only the
# compiler/preprocessor)
try_run(
run_result_unused
compile_result_unused
"${CMAKE_BINARY_DIR}"
"${CMAKE_BINARY_DIR}/arch.c"
COMPILE_OUTPUT_VARIABLE ARCH
CMAKE_FLAGS CMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}
)
# Parse the architecture name from the compiler output
string(REGEX MATCH "cmake_ARCH ([a-zA-Z0-9_]+)" ARCH "${ARCH}")
# Get rid of the value marker leaving just the architecture name
string(REPLACE "cmake_ARCH " "" ARCH "${ARCH}")
# If we are compiling with an unknown architecture this variable should
# already be set to "unknown" but in the case that it's empty (i.e. due to a
# typo in the code), then set it to unknown
if(NOT ARCH)
set(ARCH unknown)
endif()
endif()
set(${output_var} "${ARCH}" PARENT_SCOPE)
endfunction()

View File

@@ -0,0 +1 @@
set(CRYPTOPP_MINIMUM_CMAKE_VERSION 3.20)

View File

@@ -0,0 +1,96 @@
//===----------------------------------------------------------------------===//
// Distributed under the 3-Clause BSD License. See accompanying file LICENSE or
// copy at https://opensource.org/licenses/BSD-3-Clause).
// SPDX-License-Identifier: BSD-3-Clause
//===----------------------------------------------------------------------===//
// -----------------------------------------------------------------------------
// Detect the dominant newline character of a string, from 'detect-newline'
// https://github.com/sindresorhus/detect-newline
//
// MIT License
// -----------------------------------------------------------------------------
function detectNewline(string) {
if (typeof string !== 'string') {
throw new TypeError('Expected a string');
}
const newlines = string.match(/(?:\r?\n)/g) || [];
if (newlines.length === 0) {
return;
}
const crlf = newlines.filter(newline => newline === '\r\n').length;
const lf = newlines.length - crlf;
return crlf > lf ? '\r\n' : '\n';
}
function detectNewlineGraceful(string) {
return (typeof string === 'string' && detectNewline(string)) || '\n';
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Version reader/updated for standard-version that uses the mETA information in
// the CmakeLists.txt file
// -----------------------------------------------------------------------------
const major_rex = /set\(META_VERSION_MAJOR\s+\"(\d+)\"\)/;
const minor_rex = /set\(META_VERSION_MINOR\s+\"(\d+)\"\)/;
const patch_rex = /set\(META_VERSION_PATCH\s+\"(\d+)\"\)/;
module.exports.readVersion = function (contents) {
var major = null, minor = null, patch = null;
const lines = contents.split(/\r?\n/);
for (let index in lines) {
let line = lines[index];
var match = null;
if (major == null) {
var match = major_rex.exec(line);
if (match != null) {
major = match[1];
}
}
if (match == null && minor == null) {
var match = minor_rex.exec(line);
if (match != null) {
minor = match[1];
}
}
if (match == null && patch == null) {
var match = patch_rex.exec(line);
if (match != null) {
patch = match[1];
}
}
if (major != null && minor != null && patch != null) break;
};
if (major == null)
console.error("Your CmakeLists.txt is missing META_VERSION_MAJOR variable!");
if (minor == null)
console.error("Your CmakeLists.txt is missing META_VERSION_MINOR variable!");
if (patch == null)
console.error("Your CmakeLists.txt is missing META_VERSION_PATCH variable!");
return major + "." + minor + "." + patch;
}
module.exports.writeVersion = function (contents, version) {
var [major, minor, patch] = version.split(".");
var newContents = [];
const lines = contents.split(/\r?\n/);
lines.forEach(line => {
var newLine = line.replace(major_rex, "set(META_VERSION_MAJOR \"" + major + "\")")
.replace(minor_rex, "set(META_VERSION_MINOR \"" + minor + "\")")
.replace(patch_rex, "set(META_VERSION_PATCH \"" + patch + "\")");
newContents.push(newLine);
});
let newline = detectNewlineGraceful(contents)
return newContents.join(newline);
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,14 @@
# Crypto++ package configuration file
prefix=@CMAKE_INSTALL_PREFIX@
libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
datadir=${prefix}/@CMAKE_INSTALL_DATAROOTDIR@/cryptopp
Name: Crypto++
URL: https://cryptopp.com/
Description: Crypto++ cryptographic library (built with CMake)
Version: @cryptopp-cmake_VERSION@
Cflags: -I${includedir}
Libs: -L${libdir} @MODULE_LINK_LIBS@

View File

@@ -0,0 +1,73 @@
# ===-----------------------------------------------------------------------===#
# Distributed under the MIT License (https://opensource.org/licenses/MIT).
# SPDX-License-Identifier: MIT
#
# See details at:
# https://alexreinking.com/blog/building-a-dual-shared-and-static-library-with-cmake.html
# and full source at https://github.com/alexreinking/SharedStaticStarter
# ===-----------------------------------------------------------------------===#
cmake_minimum_required(VERSION 3.12)
set(cryptopp_known_comps static shared)
set(cryptopp_comp_static NO)
set(cryptopp_comp_shared NO)
foreach(cryptopp_comp IN LISTS ${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS)
if(cryptopp_comp IN_LIST cryptopp_known_comps)
set(cryptopp_comp_${cryptopp_comp} YES)
else()
set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE
"cryptopp does not recognize component `${cryptopp_comp}`."
)
set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
return()
endif()
endforeach()
if(cryptopp_comp_static AND cryptopp_comp_shared)
set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE
"cryptopp `static` and `shared` components are mutually exclusive."
)
set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
return()
endif()
set(cryptopp_static_targets
"${CMAKE_CURRENT_LIST_DIR}/cryptopp-static-targets.cmake"
)
set(cryptopp_shared_targets
"${CMAKE_CURRENT_LIST_DIR}/cryptopp-shared-targets.cmake"
)
macro(cryptopp_load_targets type)
if(NOT EXISTS "${cryptopp_${type}_targets}")
set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE
"cryptopp `${type}` libraries were requested but not found."
)
set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
return()
endif()
include("${cryptopp_${type}_targets}")
endmacro()
if(cryptopp_comp_static)
cryptopp_load_targets(static)
elseif(cryptopp_comp_shared)
cryptopp_load_targets(shared)
elseif(DEFINED cryptopp_SHARED_LIBS AND cryptopp_SHARED_LIBS)
cryptopp_load_targets(shared)
elseif(DEFINED cryptopp_SHARED_LIBS AND NOT cryptopp_SHARED_LIBS)
cryptopp_load_targets(static)
elseif(BUILD_SHARED_LIBS)
if(EXISTS "${cryptopp_shared_targets}")
cryptopp_load_targets(shared)
else()
cryptopp_load_targets(static)
endif()
else()
if(EXISTS "${cryptopp_static_targets}")
cryptopp_load_targets(static)
else()
cryptopp_load_targets(shared)
endif()
endif()

View File

@@ -0,0 +1,450 @@
# This file must be generated at every release using the crypto++ Makefile:
#
# $ make sources
#
# ***** Library sources *****
set(cryptopp_SOURCES
cryptlib.cpp
cpu.cpp
integer.cpp
3way.cpp
adler32.cpp
algebra.cpp
algparam.cpp
allocate.cpp
arc4.cpp
aria.cpp
ariatab.cpp
asn.cpp
authenc.cpp
base32.cpp
base64.cpp
basecode.cpp
bfinit.cpp
blake2.cpp
blake2b_simd.cpp
blake2s_simd.cpp
blowfish.cpp
blumshub.cpp
camellia.cpp
cast.cpp
casts.cpp
cbcmac.cpp
ccm.cpp
chacha.cpp
chacha_avx.cpp
chacha_simd.cpp
chachapoly.cpp
cham.cpp
cham_simd.cpp
channels.cpp
cmac.cpp
crc.cpp
crc_simd.cpp
darn.cpp
default.cpp
des.cpp
dessp.cpp
dh.cpp
dh2.cpp
dll.cpp
donna_32.cpp
donna_64.cpp
donna_sse.cpp
dsa.cpp
eax.cpp
ec2n.cpp
eccrypto.cpp
ecp.cpp
elgamal.cpp
emsa2.cpp
eprecomp.cpp
esign.cpp
files.cpp
filters.cpp
fips140.cpp
fipstest.cpp
gcm.cpp
gcm_simd.cpp
gf256.cpp
gf2_32.cpp
gf2n.cpp
gf2n_simd.cpp
gfpcrypt.cpp
gost.cpp
gzip.cpp
hc128.cpp
hc256.cpp
hex.cpp
hight.cpp
hmac.cpp
hrtimer.cpp
ida.cpp
idea.cpp
iterhash.cpp
kalyna.cpp
kalynatab.cpp
keccak.cpp
keccak_core.cpp
keccak_simd.cpp
lea.cpp
lea_simd.cpp
lsh256.cpp
lsh256_avx.cpp
lsh256_sse.cpp
lsh512.cpp
lsh512_avx.cpp
lsh512_sse.cpp
luc.cpp
mars.cpp
marss.cpp
md2.cpp
md4.cpp
md5.cpp
misc.cpp
modes.cpp
mqueue.cpp
mqv.cpp
nbtheory.cpp
neon_simd.cpp
oaep.cpp
osrng.cpp
padlkrng.cpp
panama.cpp
pkcspad.cpp
poly1305.cpp
polynomi.cpp
ppc_simd.cpp
primetab.cpp
pssr.cpp
pubkey.cpp
queue.cpp
rabbit.cpp
rabin.cpp
randpool.cpp
rc2.cpp
rc5.cpp
rc6.cpp
rdrand.cpp
rdtables.cpp
rijndael.cpp
rijndael_simd.cpp
ripemd.cpp
rng.cpp
rsa.cpp
rw.cpp
safer.cpp
salsa.cpp
scrypt.cpp
seal.cpp
seed.cpp
serpent.cpp
sha.cpp
sha3.cpp
sha_simd.cpp
shacal2.cpp
shacal2_simd.cpp
shake.cpp
shark.cpp
sharkbox.cpp
simeck.cpp
simon.cpp
simon128_simd.cpp
skipjack.cpp
sm3.cpp
sm4.cpp
sm4_simd.cpp
sosemanuk.cpp
speck.cpp
speck128_simd.cpp
square.cpp
squaretb.cpp
sse_simd.cpp
strciphr.cpp
tea.cpp
tftables.cpp
threefish.cpp
tiger.cpp
tigertab.cpp
ttmac.cpp
tweetnacl.cpp
twofish.cpp
vmac.cpp
wake.cpp
whrlpool.cpp
xed25519.cpp
xtr.cpp
xtrcrypt.cpp
xts.cpp
zdeflate.cpp
zinflate.cpp
zlib.cpp
)
# ***** Library headers *****
set(cryptopp_HEADERS
3way.h
adler32.h
adv_simd.h
aes.h
aes_armv4.h
algebra.h
algparam.h
allocate.h
arc4.h
argnames.h
aria.h
arm_simd.h
asn.h
authenc.h
base32.h
base64.h
basecode.h
blake2.h
blowfish.h
blumshub.h
camellia.h
cast.h
cbcmac.h
ccm.h
chacha.h
chachapoly.h
cham.h
channels.h
cmac.h
config.h
config_align.h
config_asm.h
config_cpu.h
config_cxx.h
config_dll.h
config_int.h
config_misc.h
config_ns.h
config_os.h
config_ver.h
cpu.h
crc.h
cryptlib.h
darn.h
default.h
des.h
dh.h
dh2.h
dll.h
dmac.h
donna.h
donna_32.h
donna_64.h
donna_sse.h
drbg.h
dsa.h
eax.h
ec2n.h
eccrypto.h
ecp.h
ecpoint.h
elgamal.h
emsa2.h
eprecomp.h
esign.h
fhmqv.h
files.h
filters.h
fips140.h
fltrimpl.h
gcm.h
gf256.h
gf2_32.h
gf2n.h
gfpcrypt.h
gost.h
gzip.h
hashfwd.h
hc128.h
hc256.h
hex.h
hight.h
hkdf.h
hmac.h
hmqv.h
hrtimer.h
ida.h
idea.h
integer.h
iterhash.h
kalyna.h
keccak.h
lea.h
lsh.h
lubyrack.h
luc.h
mars.h
md2.h
md4.h
md5.h
mdc.h
mersenne.h
misc.h
modarith.h
modes.h
modexppc.h
mqueue.h
mqv.h
naclite.h
nbtheory.h
nr.h
oaep.h
oids.h
osrng.h
ossig.h
padlkrng.h
panama.h
pch.h
pkcspad.h
poly1305.h
polynomi.h
ppc_simd.h
pssr.h
pubkey.h
pwdbased.h
queue.h
rabbit.h
rabin.h
randpool.h
rc2.h
rc5.h
rc6.h
rdrand.h
rijndael.h
ripemd.h
rng.h
rsa.h
rw.h
safer.h
salsa.h
scrypt.h
seal.h
secblock.h
secblockfwd.h
seckey.h
seed.h
serpent.h
serpentp.h
sha.h
sha1_armv4.h
sha256_armv4.h
sha3.h
sha512_armv4.h
shacal2.h
shake.h
shark.h
simeck.h
simon.h
simple.h
siphash.h
skipjack.h
sm3.h
sm4.h
smartptr.h
sosemanuk.h
speck.h
square.h
stdcpp.h
strciphr.h
tea.h
threefish.h
tiger.h
trap.h
trunhash.h
ttmac.h
tweetnacl.h
twofish.h
vmac.h
wake.h
whrlpool.h
words.h
xed25519.h
xtr.h
xtrcrypt.h
xts.h
zdeflate.h
zinflate.h
zlib.h
)
# ***** Test sources *****
set(cryptopp_SOURCES_TEST
# adhoc.cpp
test.cpp
bench1.cpp
bench2.cpp
bench3.cpp
datatest.cpp
dlltest.cpp
fipsalgt.cpp
validat0.cpp
validat1.cpp
validat2.cpp
validat3.cpp
validat4.cpp
validat5.cpp
validat6.cpp
validat7.cpp
validat8.cpp
validat9.cpp
validat10.cpp
regtest1.cpp
regtest2.cpp
regtest3.cpp
regtest4.cpp
)
# ***** Test headers *****
set(cryptopp_HEADERS_TEST bench.h factory.h validate.h)
list(
REMOVE_ITEM
cryptopp_SOURCES
cryptlib.cpp
cpu.cpp
integer.cpp
pch.cpp
simple.cpp
)
set(cryptopp_SOURCES cryptlib.cpp cpu.cpp integer.cpp ${cryptopp_SOURCES})
# Build the sources lists with full paths
set(sources_tmp)
foreach(src ${cryptopp_SOURCES})
list(APPEND sources_tmp "${cryptopp_SOURCE_DIR}/${src}")
endforeach()
set(cryptopp_SOURCES ${sources_tmp})
set(sources_tmp)
foreach(src ${cryptopp_SOURCES_TEST})
list(APPEND sources_tmp "${cryptopp_SOURCE_DIR}/${src}")
endforeach()
set(cryptopp_SOURCES_TEST ${sources_tmp})
set(sources_tmp)
foreach(src ${cryptopp_HEADERS})
list(APPEND sources_tmp "${cryptopp_SOURCE_DIR}/${src}")
endforeach()
set(cryptopp_HEADERS ${sources_tmp})
# Initially we start with an empty list for ASM sources. It will be populated
# based on the compiler, target architecture and whether the user requested to
# disable ASM or not.
set(cryptopp_SOURCES_ASM)
# Adjust for Android
if(ANDROID)
include_directories(${ANDROID_NDK}/sources/android/cpufeatures)
list(
APPEND
cryptopp_SOURCES
${ANDROID_NDK}/sources/android/cpufeatures/cpu-features.c
)
endif()

View File

@@ -0,0 +1,19 @@
# ===-----------------------------------------------------------------------===#
# Distributed under the 3-Clause BSD License. See accompanying file LICENSE or
# copy at https://opensource.org/licenses/BSD-3-Clause).
# SPDX-License-Identifier: BSD-3-Clause
# ===-----------------------------------------------------------------------===#
set(TEST_CMAKE_FILES_DIR ${CMAKE_SOURCE_DIR}/cmake)
set(TEST_EXAMPLE_SOURCES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/example-src)
# set(FETCHCONTENT_BASE_DIR ${CMAKE_CURRENT_BINARY_DIR}) cmake_path(APPEND
# FETCHCONTENT_BASE_DIR _deps)
add_subdirectory(unit)
add_subdirectory(integration)
add_custom_target(
test-verbose
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/.."
COMMAND ${CMAKE_CTEST_COMMAND} --verbose --output-on-failure)

View File

@@ -0,0 +1,22 @@
//===----------------------------------------------------------------------===//
// Distributed under the 3-Clause BSD License. See accompanying file LICENSE or
// copy at https://opensource.org/licenses/BSD-3-Clause).
// SPDX-License-Identifier: BSD-3-Clause
//===----------------------------------------------------------------------===//
#include <array>
#include <cstdint>
#ifdef CRYPTOPP_INCLUDE_PREFIX
#define CRYPTOPP_HEADER(hdr) <CRYPTOPP_INCLUDE_PREFIX/hdr>
#include CRYPTOPP_HEADER(osrng.h)
#else
#include <cryptopp/osrng.h> // for random number generation
#endif
int main(int argc, char **argv) {
constexpr size_t c_buffer_size = 16;
std::array<uint8_t, c_buffer_size> output;
CryptoPP::AutoSeededRandomPool rng;
rng.GenerateBlock(output.data(), c_buffer_size);
}

View File

@@ -0,0 +1,128 @@
# ===-----------------------------------------------------------------------===#
# Distributed under the 3-Clause BSD License. See accompanying file LICENSE or
# copy at https://opensource.org/licenses/BSD-3-Clause).
# SPDX-License-Identifier: BSD-3-Clause
# ===-----------------------------------------------------------------------===#
set(INT_TEST_CMAKE_FILES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
set(CRYPTOPP_CMAKE_INSTALL_ROOT
"${CMAKE_BINARY_DIR}/test-dirs/install")
define_property(TEST PROPERTY install_dir
BRIEF_DOCS "Install-dir of the test"
FULL_DOCS "Just set because not optional (yet)")
file(GLOB tests "${CMAKE_CURRENT_SOURCE_DIR}/int-install-*")
foreach(test ${tests})
cmake_path(GET test FILENAME test_name)
message(STATUS "Adding install integration test: ${test_name}")
string (REPLACE "int-" "" short_name cryptopp-${test_name})
# Configure
add_test(
NAME cryptopp-${test_name}-configure
COMMAND
${CMAKE_COMMAND}
-G${CMAKE_GENERATOR}
# Pass the locations for common cmake test files
-D "TEST_CMAKE_FILES_DIR=${TEST_CMAKE_FILES_DIR}"
-D "INT_TEST_CMAKE_FILES_DIR=${INT_TEST_CMAKE_FILES_DIR}"
# Pass the locations for common test source files
-D "TEST_EXAMPLE_SOURCES_DIR=${TEST_EXAMPLE_SOURCES_DIR}"
# Use ccache
-D "USE_CCACHE=TRUE"
# Override cmake compiler flags for ccache/MSVC
-D
"CMAKE_USER_MAKE_RULES_OVERRIDE=${TEST_CMAKE_FILES_DIR}/ResetInitialCompilerOptions.cmake"
# Set the install prefix
-D "CMAKE_INSTALL_PREFIX=${CRYPTOPP_CMAKE_INSTALL_ROOT}/${test_name}"
# Setup cmake source/build dirs
-S "${CMAKE_CURRENT_SOURCE_DIR}/${test_name}" -B
"${CMAKE_BINARY_DIR}/test-dirs/${test_name}"
# Use local source code for cryptopp-cmake
-D "CPM_cryptopp-cmake_SOURCE=${CMAKE_CURRENT_SOURCE_DIR}/../.."
# Enable verbose makefiles so we can see the full compile command line
-D "CMAKE_VERBOSE_MAKEFILE=ON"
# Throw the version in
-D CRYPTOPP_MINIMUM_CMAKE_VERSION=${CRYPTOPP_MINIMUM_CMAKE_VERSION}
# Set the build-type to what we are building
-D CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE})
set_tests_properties(cryptopp-${test_name}-configure PROPERTIES
FIXTURES_SETUP ${test_name}-config
install_dir "${CRYPTOPP_CMAKE_INSTALL_ROOT}/${test_name}"
LABELS "cryptopp;cryptopp-integration-tests;${short_name}")
# Build
add_test(NAME cryptopp-${test_name}-build
COMMAND ${CMAKE_COMMAND} --build
"${CMAKE_BINARY_DIR}/test-dirs/${test_name}"
--config ${CMAKE_BUILD_TYPE})
set_tests_properties(cryptopp-${test_name}-build PROPERTIES
FIXTURES_SETUP ${test_name}-build
FIXTURES_REQUIRED ${test_name}-config
LABELS "cryptopp;cryptopp-integration-tests;${short_name}")
# Install
add_test(
NAME cryptopp-${test_name}-install
COMMAND ${CMAKE_COMMAND} --build
"${CMAKE_BINARY_DIR}/test-dirs/${test_name}" --target install
--config ${CMAKE_BUILD_TYPE})
set_tests_properties(cryptopp-${test_name}-install PROPERTIES
FIXTURES_SETUP ${test_name}-install
FIXTURES_REQUIRED ${test_name}-build
LABELS "cryptopp;cryptopp-integration-tests;${short_name}")
# Check installed files
add_test(
NAME cryptopp-${test_name}-checks
COMMAND ${CMAKE_COMMAND} --build
"${CMAKE_BINARY_DIR}/test-dirs/${test_name}" --target do-checks
--config ${CMAKE_BUILD_TYPE})
set_tests_properties(cryptopp-${test_name}-checks PROPERTIES
FIXTURES_REQUIRED ${test_name}-install
LABELS "cryptopp;cryptopp-integration-tests;${short_name}")
endforeach()
# ------------------------------------------------------------------------------
# Use cryptopp via find_package
# ------------------------------------------------------------------------------
set(test_name "int-find-package")
get_test_property(cryptopp-int-install-default-configure
install_dir CRYPTOPP_SEARCH_ROOT)
# Configure
add_test(
NAME cryptopp-${test_name}-configure
COMMAND
${CMAKE_COMMAND}
-G${CMAKE_GENERATOR}
# Pass the locations for common test source files
-D "TEST_EXAMPLE_SOURCES_DIR=${TEST_EXAMPLE_SOURCES_DIR}"
# Set the install prefix
-D "CRYPTOPP_CMAKE_INSTALL_ROOT=${CRYPTOPP_CMAKE_INSTALL_ROOT}"
# Setup cmake source/build dirs
-S "${CMAKE_CURRENT_SOURCE_DIR}/${test_name}" -B
"${CMAKE_BINARY_DIR}/test-dirs/${test_name}"
# Enable verbose makefiles so we can see the full compile command line
-D "CMAKE_VERBOSE_MAKEFILE=ON"
# Throw the version in
-D CRYPTOPP_MINIMUM_CMAKE_VERSION=${CRYPTOPP_MINIMUM_CMAKE_VERSION}
# Set the build-type to what we are building
-D CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
# Tell the test where to find installed package
-D cryptopp_DIR=${CRYPTOPP_SEARCH_ROOT}/share/cmake/cryptopp)
set_tests_properties(cryptopp-${test_name}-configure PROPERTIES
FIXTURES_SETUP ${test_name}-config
FIXTURES_REQUIRED "int-install-default-install"
LABELS "cryptopp;cryptopp-find_package")
# Build
add_test(NAME cryptopp-${test_name}-build
COMMAND ${CMAKE_COMMAND} --build
"${CMAKE_BINARY_DIR}/test-dirs/${test_name}"
--config ${CMAKE_BUILD_TYPE})
set_tests_properties(cryptopp-${test_name}-build PROPERTIES
FIXTURES_REQUIRED ${test_name}-config
LABELS "cryptopp;cryptopp-find_package")

View File

@@ -0,0 +1,12 @@
# ===-----------------------------------------------------------------------===#
# Distributed under the 3-Clause BSD License. See accompanying file LICENSE or
# copy at https://opensource.org/licenses/BSD-3-Clause).
# SPDX-License-Identifier: BSD-3-Clause
# ===-----------------------------------------------------------------------===#
# Helper script to check if a file exists at build time
message(STATUS "Checking if installed file \"${FILE_TO_CHECK}\" exists")
if(NOT EXISTS ${FILE_TO_CHECK})
message(FATAL_ERROR "\"${FILE_TO_CHECK}\" doesn't exist.")
endif()

View File

@@ -0,0 +1,36 @@
# ===-----------------------------------------------------------------------===#
# Distributed under the 3-Clause BSD License. See accompanying file LICENSE or
# copy at https://opensource.org/licenses/BSD-3-Clause).
# SPDX-License-Identifier: BSD-3-Clause
# ===-----------------------------------------------------------------------===#
include(GNUInstallDirs)
# add custom target to check the installed files at build time
add_custom_target(do-checks)
function(check_file_exists file_to_check)
add_custom_command(
TARGET do-checks
POST_BUILD
COMMAND ${CMAKE_COMMAND} -DFILE_TO_CHECK=${file_to_check} -P
${CMAKE_CURRENT_LIST_DIR}/CheckFileExists.cmake
COMMENT "Checking if ${file_to_check} exists...")
endfunction()
if(MSVC)
if(CRYPTOPP_BUILD_SHARED)
check_file_exists(${CMAKE_INSTALL_FULL_LIBDIR}/cryptopp.dll)
else()
check_file_exists(${CMAKE_INSTALL_FULL_LIBDIR}/cryptopp.lib)
endif()
else()
check_file_exists(${CMAKE_INSTALL_FULL_LIBDIR}/$<TARGET_FILE_NAME:cryptopp>)
endif()
check_file_exists(${CMAKE_INSTALL_FULL_INCLUDEDIR}/${CRYPTOPP_INCLUDE_PREFIX})
check_file_exists(
${CMAKE_INSTALL_FULL_INCLUDEDIR}/${CRYPTOPP_INCLUDE_PREFIX}/config.h)
check_file_exists(${CMAKE_INSTALL_FULL_DATAROOTDIR}/pkgconfig/cryptopp.pc)
check_file_exists(${CMAKE_INSTALL_FULL_DATAROOTDIR}/cmake/cryptopp)
check_file_exists(
${CMAKE_INSTALL_FULL_DATAROOTDIR}/cmake/cryptopp/cryptoppConfig.cmake)

View File

@@ -0,0 +1,19 @@
# ===-----------------------------------------------------------------------===#
# Distributed under the 3-Clause BSD License. See accompanying file LICENSE or
# copy at https://opensource.org/licenses/BSD-3-Clause).
# SPDX-License-Identifier: BSD-3-Clause
# ===-----------------------------------------------------------------------===#
cmake_minimum_required(VERSION ${CRYPTOPP_MINIMUM_CMAKE_VERSION})
# Test project for cryptopp-cmake installation
project(CryptoppCmakeFindPackageTest)
# Explicitly request the static library component to avoid cmake defaulting to
# the shared component, which is currently not being built.
find_package(cryptopp REQUIRED static)
# compile and link a test program using crypto++
add_executable(rng-test ${TEST_EXAMPLE_SOURCES_DIR}/main.cpp)
target_link_libraries(rng-test cryptopp::cryptopp)
target_compile_features(rng-test PRIVATE cxx_constexpr)

View File

@@ -0,0 +1,35 @@
# ===-----------------------------------------------------------------------===#
# Distributed under the 3-Clause BSD License. See accompanying file LICENSE or
# copy at https://opensource.org/licenses/BSD-3-Clause).
# SPDX-License-Identifier: BSD-3-Clause
# ===-----------------------------------------------------------------------===#
cmake_minimum_required(VERSION ${CRYPTOPP_MINIMUM_CMAKE_VERSION})
# Test project for cryptopp-cmake installation
project(CryptoppCmakeInstallDefaultTest)
# ---- Add dependencies via CPM ----
# see https://github.com/TheLartians/CPM.cmake for more info
include(${TEST_CMAKE_FILES_DIR}/CPM.cmake)
# ---- Speedup build using ccache (needs CPM) ----
include(${TEST_CMAKE_FILES_DIR}/FasterBuild.cmake)
set(CRYPTOPP_INCLUDE_PREFIX "cryptopp")
cpmaddpackage(
NAME
cryptopp-cmake
GIT_REPOSITORY
https://github.com./abdes/cryptopp-cmake
GIT_TAG
master
OPTIONS
"CRYPTOPP_BUILD_TESTING OFF"
"CRYPTOPP_INSTALL ON")
add_executable(rng-test ${TEST_EXAMPLE_SOURCES_DIR}/main.cpp)
target_link_libraries(rng-test PUBLIC cryptopp::cryptopp)
target_compile_features(rng-test PRIVATE cxx_constexpr)
include(${INT_TEST_CMAKE_FILES_DIR}/ProjectInstallTests.cmake)

View File

@@ -0,0 +1,36 @@
# ===-----------------------------------------------------------------------===#
# Distributed under the 3-Clause BSD License. See accompanying file LICENSE or
# copy at https://opensource.org/licenses/BSD-3-Clause).
# SPDX-License-Identifier: BSD-3-Clause
# ===-----------------------------------------------------------------------===#
cmake_minimum_required(VERSION ${CRYPTOPP_MINIMUM_CMAKE_VERSION})
# Test project for cryptopp-cmake installation
project(CryptoppCmakeInstallPrefixTest)
# ---- Add dependencies via CPM ----
# see https://github.com/TheLartians/CPM.cmake for more info
include(${TEST_CMAKE_FILES_DIR}/CPM.cmake)
# ---- Speedup build using ccache (needs CPM) ----
include(${TEST_CMAKE_FILES_DIR}/FasterBuild.cmake)
set(CRYPTOPP_INCLUDE_PREFIX "crypto++")
cpmaddpackage(
NAME
cryptopp-cmake
GIT_REPOSITORY
https://github.com./abdes/cryptopp-cmake
GIT_TAG
master
OPTIONS
"CRYPTOPP_BUILD_TESTING OFF"
"CRYPTOPP_INSTALL ON"
"CRYPTOPP_INCLUDE_PREFIX ${CRYPTOPP_INCLUDE_PREFIX}")
add_executable(rng-test main.cpp)
target_link_libraries(rng-test PUBLIC cryptopp::cryptopp)
target_compile_features(rng-test PRIVATE cxx_constexpr)
include(${INT_TEST_CMAKE_FILES_DIR}/ProjectInstallTests.cmake)

View File

@@ -0,0 +1,17 @@
//===----------------------------------------------------------------------===//
// Distributed under the 3-Clause BSD License. See accompanying file LICENSE or
// copy at https://opensource.org/licenses/BSD-3-Clause).
// SPDX-License-Identifier: BSD-3-Clause
//===----------------------------------------------------------------------===//
#include <array>
#include <cstdint>
#include <crypto++/osrng.h> // for random number generation
int main(int argc, char **argv) {
constexpr size_t c_buffer_size = 16;
std::array<uint8_t, c_buffer_size> output;
CryptoPP::AutoSeededRandomPool rng;
rng.GenerateBlock(output.data(), c_buffer_size);
}

View File

@@ -0,0 +1,49 @@
# ===-----------------------------------------------------------------------===#
# Distributed under the 3-Clause BSD License. See accompanying file LICENSE or
# copy at https://opensource.org/licenses/BSD-3-Clause).
# SPDX-License-Identifier: BSD-3-Clause
# ===-----------------------------------------------------------------------===#
file(GLOB tests "${CMAKE_CURRENT_SOURCE_DIR}/*")
list(REMOVE_ITEM tests "${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt")
foreach(test ${tests})
cmake_path(GET test FILENAME test_name)
message(STATUS "Adding unit test: ${test_name}")
# Configure
add_test(
NAME cryptopp-${test_name}-configure
COMMAND
${CMAKE_COMMAND}
# Always use ninja, never the visual studio generator (bugged)
-G${CMAKE_GENERATOR}
# Pass the locations for common cmake files
-D "TEST_CMAKE_FILES_DIR=${TEST_CMAKE_FILES_DIR}"
# Pass the locations for common test source files
-D "TEST_EXAMPLE_SOURCES_DIR=${TEST_EXAMPLE_SOURCES_DIR}"
# Use ccache
-D "USE_CCACHE=TRUE"
# Override cmake compiler flags for ccache/MSVC
-D
"CMAKE_USER_MAKE_RULES_OVERRIDE=${TEST_CMAKE_FILES_DIR}/ResetInitialCompilerOptions.cmake"
# Setup cmake source/build dirs
-S "${test}" -B "${CMAKE_BINARY_DIR}/test-dirs/${test_name}"
# Use local source code for cryptopp-cmake
-D "CPM_cryptopp-cmake_SOURCE=${cryptopp-cmake_SOURCE_DIR}"
# Enable verbose makefiles so we can see the full compile command line
-D CMAKE_VERBOSE_MAKEFILE=ON
# Set the build-type to what we are building
-D CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE})
set_tests_properties(cryptopp-${test_name}-configure PROPERTIES
FIXTURES_SETUP ${test_name}-config
LABELS "cryptopp;cryptopp-unit-tests;cryptopp-${test_name}")
# Build
add_test(NAME cryptopp-${test_name}-build
COMMAND ${CMAKE_COMMAND} --build
"${CMAKE_BINARY_DIR}/test-dirs/${test_name}"
--config ${CMAKE_BUILD_TYPE})
# Run build test case after the configure test case
set_tests_properties(cryptopp-${test_name}-build PROPERTIES
FIXTURES_REQUIRED ${test_name}-config
LABELS "cryptopp;cryptopp-unit-tests;cryptopp-${test_name}")
endforeach()

View File

@@ -0,0 +1,35 @@
# ===-----------------------------------------------------------------------===#
# Distributed under the 3-Clause BSD License. See accompanying file LICENSE or
# copy at https://opensource.org/licenses/BSD-3-Clause).
# SPDX-License-Identifier: BSD-3-Clause
# ===-----------------------------------------------------------------------===#
include(${CPM_cryptopp-cmake_SOURCE}/cmake/cmake_minimum_required.cmake)
cmake_minimum_required(VERSION ${CRYPTOPP_MINIMUM_CMAKE_VERSION})
# Test project for the standard way of using cryptopp-cmake
project(CryptoppCmakeDisableFeatureTest)
# ---- Add dependencies via CPM ----
# see https://github.com/TheLartians/CPM.cmake for more info
include(${TEST_CMAKE_FILES_DIR}/CPM.cmake)
# ---- Speedup build using ccache (needs CPM) ----
include(${TEST_CMAKE_FILES_DIR}/FasterBuild.cmake)
cpmaddpackage(
NAME
cryptopp-cmake
GITHUB_REPOSITORY
abdes/cryptopp-cmake
VERSION
${cryptopp_GIT_BRANCH}
OPTIONS
"CRYPTOPP_BUILD_TESTING OFF"
"DISABLE_ASM ON"
)
# compile and link a test program using crypto++
add_executable(rng-test ${TEST_EXAMPLE_SOURCES_DIR}/main.cpp)
target_link_libraries(rng-test cryptopp::cryptopp)
target_compile_features(rng-test PRIVATE cxx_constexpr)

View File

@@ -0,0 +1,34 @@
# ===-----------------------------------------------------------------------===#
# Distributed under the 3-Clause BSD License. See accompanying file LICENSE or
# copy at https://opensource.org/licenses/BSD-3-Clause).
# SPDX-License-Identifier: BSD-3-Clause
# ===-----------------------------------------------------------------------===#
include(${CPM_cryptopp-cmake_SOURCE}/cmake/cmake_minimum_required.cmake)
cmake_minimum_required(VERSION ${CRYPTOPP_MINIMUM_CMAKE_VERSION})
# Test project for the standard way of using cryptopp-cmake
project(CryptoppCmakeIncludePrefixTest)
# ---- Add dependencies via CPM ----
# see https://github.com/TheLartians/CPM.cmake for more info
include(${TEST_CMAKE_FILES_DIR}/CPM.cmake)
# ---- Speedup build using ccache (needs CPM) ----
include(${TEST_CMAKE_FILES_DIR}/FasterBuild.cmake)
cpmaddpackage(
NAME
cryptopp-cmake
GITHUB_REPOSITORY
abdes/cryptopp-cmake
VERSION
${cryptopp_GIT_BRANCH}
OPTIONS
"CRYPTOPP_BUILD_TESTING OFF"
"CRYPTOPP_INCLUDE_PREFIX crypto++")
# compile and link a test program using crypto++
add_executable(rng-test main.cpp)
target_link_libraries(rng-test cryptopp::cryptopp)
target_compile_features(rng-test PRIVATE cxx_constexpr)

View File

@@ -0,0 +1,17 @@
//===----------------------------------------------------------------------===//
// Distributed under the 3-Clause BSD License. See accompanying file LICENSE or
// copy at https://opensource.org/licenses/BSD-3-Clause).
// SPDX-License-Identifier: BSD-3-Clause
//===----------------------------------------------------------------------===//
#include <array>
#include <cstdint>
#include <crypto++/osrng.h> // for random number generation
int main(int argc, char **argv) {
constexpr size_t c_buffer_size = 16;
std::array<uint8_t, c_buffer_size> output;
CryptoPP::AutoSeededRandomPool rng;
rng.GenerateBlock(output.data(), c_buffer_size);
}

View File

@@ -0,0 +1,34 @@
# ===-----------------------------------------------------------------------===#
# Distributed under the 3-Clause BSD License. See accompanying file LICENSE or
# copy at https://opensource.org/licenses/BSD-3-Clause).
# SPDX-License-Identifier: BSD-3-Clause
# ===-----------------------------------------------------------------------===#
include(${CPM_cryptopp-cmake_SOURCE}/cmake/cmake_minimum_required.cmake)
cmake_minimum_required(VERSION ${CRYPTOPP_MINIMUM_CMAKE_VERSION})
# Test project for the standard way of using cryptopp-cmake
project(CryptoppCmakeNoInstallTest)
# ---- Add dependencies via CPM ----
# see https://github.com/TheLartians/CPM.cmake for more info
include(${TEST_CMAKE_FILES_DIR}/CPM.cmake)
# ---- Speedup build using ccache (needs CPM) ----
include(${TEST_CMAKE_FILES_DIR}/FasterBuild.cmake)
cpmaddpackage(
NAME
cryptopp-cmake
GIT_REPOSITORY
abdes/cryptopp-cmake
GIT_TAG
${cryptopp_GIT_BRANCH}
OPTIONS
"CRYPTOPP_BUILD_TESTING OFF"
"CRYPTOPP_INSTALL OFF")
# compile and link a test program using crypto++
add_executable(rng-test ${TEST_EXAMPLE_SOURCES_DIR}/main.cpp)
target_link_libraries(rng-test cryptopp::cryptopp)
target_compile_features(rng-test PRIVATE cxx_constexpr)

View File

@@ -0,0 +1,33 @@
# ===-----------------------------------------------------------------------===#
# Distributed under the 3-Clause BSD License. See accompanying file LICENSE or
# copy at https://opensource.org/licenses/BSD-3-Clause).
# SPDX-License-Identifier: BSD-3-Clause
# ===-----------------------------------------------------------------------===#
include(${CPM_cryptopp-cmake_SOURCE}/cmake/cmake_minimum_required.cmake)
cmake_minimum_required(VERSION ${CRYPTOPP_MINIMUM_CMAKE_VERSION})
# Test project for the standard way of using cryptopp-cmake
project(CryptoppCmakeStandardTest)
# ---- Add dependencies via CPM ----
# see https://github.com/TheLartians/CPM.cmake for more info
include(${TEST_CMAKE_FILES_DIR}/CPM.cmake)
# ---- Speedup build using ccache (needs CPM) ----
include(${TEST_CMAKE_FILES_DIR}/FasterBuild.cmake)
cpmaddpackage(
NAME
cryptopp-cmake
GIT_REPOSITORY
abdes/cryptopp-cmake
GIT_TAG
${cryptopp_GIT_BRANCH}
OPTIONS
"CRYPTOPP_BUILD_TESTING OFF")
# compile and link a test program using crypto++
add_executable(rng-test ${TEST_EXAMPLE_SOURCES_DIR}/main.cpp)
target_link_libraries(rng-test cryptopp::cryptopp)
target_compile_features(rng-test PRIVATE cxx_constexpr)