abdes / cryptopp-cmake

A modern CMake build project for Crypto++ (https://github.com/weidai11/cryptopp).
BSD 3-Clause "New" or "Revised" License
112 stars 42 forks source link
build cmake cryptopp modern package

Crypto++ CMake

-+- 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]

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 projects.

See this announcement 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

Before you ask

Versioning principles

This project releases track the crypto++ 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

An example is located in the test/standard-cpm 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 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

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 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: