This repository provides FindBotan.cmake
which allows for easily inclusion of Botan into CMake based projects.
Unlike other CMake integrations for Botan, this one does not simply add all the Botan files to a target. Instead, it does the following automagically:
- Download the requested version of Botan.
- Run Botan's python script to generate the amalgamation files
botan_all.h
andbotan_all.cpp
. - Provides a CMake target to compile & link those amalgamation files.
Refer to Botan's The Amalgamation Build documentation for more information on the amalgamation build.
Code provided by this repository is considered to be public domain using the Unlicense license. However, note that Botan ships with its own licensing.
To use this Botan CMake integration:
- Download/copy
cmake/FindBotan.cmake
from this repository to your local CMake project. - Add that CMake script to your CMake module path (
CMAKE_MODULE_PATH
). - Use
find_package()
to "include" that CMake script in your project. Do not specify any components. - Use the
botan_generate()
function to generate a target with specific Botan modules enabled. - Use
target_link_libraries()
to link to the generated CMake target. - Include
botan_all.h
where needed.
An example project is provided under /example
.
Your CMakeLists.txt
:
# Find Botan
find_package(
botan 2.18.2
REQUIRED
)
# Create target "botan_test" with modules "system_rng" and "sha3" enabled
botan_generate(
botan_test
system_rng
sha3
)
# Link to generated target
target_link_libraries(
MyTarget
PRIVATE
botan_test
)