Botan find module

I’d like to add a find module for the Botan cryptographic library to find modules shipped with CMake by default. Botan has been around for many years and is used by open source as well as commercial projects. We consume it from CMake projects and have been writing our own find module for Botan for some time. Other projects on GitHub seem to do the same. A search for FindBotan.cmake yields 81 results, which means a lot of code duplication.

The find module would be based on the one used by the rnp project. I and Ronald Tse (from the rnp project) would be willing to take over maintainership.

Please let me know what you think.

The recommended approach is to directly contribute to the Botan library by providing a CMake config file.

But Botan does not use CMake, but a custom Botan-specific build system. Is this still the recommended way?

Yes. The build system use by the package is irrelevant. The CMake config file is for the consumers of the package using CMake.

For example, Boost delivers a BoostConfig.cmake file but use a proprietary build system (boost.build).

Is there good documentation on how to write a CMake config file from scratch? The docs on cmake-packages only seems to be targeted towards users of CMake that can use the built-in facilities to generate one.

It’s basically the same as a Find module except the locations should be known at its generation time rather than having to actually call find_ commands.

Basically:

  • gather the information required
  • verify what is available matches the request (if COMPONENTS are to be supported)
  • if the targets don’t exist, make imported targets
  • provide variables if needed (but prefer targets if they work)

So with the help of existing config files, e.g., Boost, and with config files created in other CMake projects using the helper functions, I was able to create config files for Botan in Add cmake package config by securitykernel · Pull Request #3722 · randombit/botan · GitHub. Would you be able to do a quick review? This would be really helpful! It currently only supports shared linkage, because static is a bit more work and I wanted to get shared right for the start (maybe you can give some hints on what would be needed to add static support).

1 Like

So this is merged upstream now, thank you for the help and for the code review on GitHub @ben.boeckel!

1 Like