oasis-tcs/pkcs11

Add CMake build script for PKCS#11

gl-mc opened this issue · 0 comments

gl-mc commented

Many IDEs support CMake (CLion has it as a default, and integration in Visual Studio Code is also very good). It would be great if the PKCS11 consortium published a CMake module that helps developers getting started with PKCS#11 development in their IDE.

I have attached such a module for reference FindPKCS11.cmake.zip. I had to zip it because GitHub did not accept files ending in .cmake.

To use it, you would check out the oasis-tcs/pkcs11 project as a git submodule into your projects source folder.

The attached module FindPKCS11.cmake.zip can then be used by adding the following two lines to your CMakeLists.txt (assuming it resides in your ${PROJECT_SOURCE_DIR}/cmake folder):

list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
find_package(PKCS11 2.40.0)

Then add it to your targets that need linking against PKCS#11 as follows:

target_link_libraries(<target_name> PRIVATE PKCS11::PKCS11)