I am trying to write a program in c++ using botan but I don't know how to properly use it. Take for example the following code:
Botan::AutoSeeded_RNG rng;
Botan::UUID uuid = Botan::UUID(rng);
std::cout << uuid.to_string() << std::endl;
If I try to run this it throws an error which seems to be an issue with botan not being linked. But I'm not sure how I can link this using CMake. In CMakeList.txt I have
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
find_package(BOTAN REQUIRED)
based on this, and in modules, I have a file FindBOTAN.cmake.
But this throws the error Could NOT find Botan (missing: BOTAN_LIBRARIES BOTAN_INCLUDE_DIRS), the warning
The package name passed to `find_package_handle_standard_args` (PkgConfig)
does not match the name of the calling package (BOTAN). This can lead to
problems in calling code that expects `find_package` result variables
(e.g., `_FOUND`) to follow a certain pattern.
and fails to find botan.
I have barely any experience using CMake hence I've based it on someone else's but now I've got the problem that I don't know what is going wrong.
That find module is totally wrong. You should point whoever wrote it to this answer. Here's something better (but could still be improved, e.g. by validating the version):
Put this file in
cmake/FindBotan.cmakeand then you can use it from your top-levelCMakeLists.txtlike so:As always, you should endeavor to link to imported targets, like the
Botan::Botantarget that my revised find module defines. For main.cpp, I wrapped your code up like so:And I confirmed that it does indeed build: