# Botan find module

**URL:** https://discourse.cmake.org/t/botan-find-module/9101
**Category:** Development
**Created:** [September 27, 2023, 9:23am UTC](https://discourse.cmake.org/t/botan-find-module/9101 "2023-09-27T09:23:17Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![securitykernel](https://discourse.cmake.org/user_avatar/discourse.cmake.org/securitykernel/32/3879_2.png) [@securitykernel](https://discourse.cmake.org/u/securitykernel)
#### Post date: [September 27, 2023, 9:23am UTC](https://discourse.cmake.org/t/botan-find-module/9101/1 "2023-09-27T09:23:17Z")

</div>

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](https://github.com/randombit/botan/wiki/Users) 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](https://github.com/rnpgp/rnp/issues/2121). I and Ronald Tse (from the rnp project) would be willing to take over maintainership.

Please let me know what you think.

---

<div class="post-metadata">

### Author: ![marc.chevrier](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/ecb155/32.png) [@marc.chevrier](https://discourse.cmake.org/u/marc.chevrier)
#### Post date: [September 27, 2023, 9:41am UTC](https://discourse.cmake.org/t/botan-find-module/9101/2 "2023-09-27T09:41:09Z")

</div>

The recommended approach is to directly contribute to the `Botan` library by providing a `CMake` [config file](https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html#config-file-packages).

---

<div class="post-metadata">

### Author: ![securitykernel](https://discourse.cmake.org/user_avatar/discourse.cmake.org/securitykernel/32/3879_2.png) [@securitykernel](https://discourse.cmake.org/u/securitykernel)
#### Post date: [September 27, 2023, 10:36am UTC](https://discourse.cmake.org/t/botan-find-module/9101/3 "2023-09-27T10:36:20Z")

</div>

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

---

<div class="post-metadata">

### Author: ![marc.chevrier](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/ecb155/32.png) [@marc.chevrier](https://discourse.cmake.org/u/marc.chevrier)
#### Post date: [September 27, 2023, 10:45am UTC](https://discourse.cmake.org/t/botan-find-module/9101/4 "2023-09-27T10:45:58Z")

</div>

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`).

---

<div class="post-metadata">

### Author: ![securitykernel](https://discourse.cmake.org/user_avatar/discourse.cmake.org/securitykernel/32/3879_2.png) [@securitykernel](https://discourse.cmake.org/u/securitykernel)
#### Post date: [September 27, 2023, 11:18am UTC](https://discourse.cmake.org/t/botan-find-module/9101/5 "2023-09-27T11:18:52Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [September 27, 2023, 12:40pm UTC](https://discourse.cmake.org/t/botan-find-module/9101/6 "2023-09-27T12:40:07Z")

</div>

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)

---

<div class="post-metadata">

### Author: ![securitykernel](https://discourse.cmake.org/user_avatar/discourse.cmake.org/securitykernel/32/3879_2.png) [@securitykernel](https://discourse.cmake.org/u/securitykernel)
#### Post date: [October 21, 2023, 6:43am UTC](https://discourse.cmake.org/t/botan-find-module/9101/7 "2023-10-21T06:43:12Z")

</div>

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](https://github.com/randombit/botan/pull/3722). 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).

---

<div class="post-metadata">

### Author: ![securitykernel](https://discourse.cmake.org/user_avatar/discourse.cmake.org/securitykernel/32/3879_2.png) [@securitykernel](https://discourse.cmake.org/u/securitykernel)
#### Post date: [November 8, 2023, 5:41pm UTC](https://discourse.cmake.org/t/botan-find-module/9101/8 "2023-11-08T17:41:07Z")

</div>

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