|
| 1 | +# Building SoftHSMv2 for Windows |
| 2 | + |
| 3 | +This document describes process of building both 32-bit and 64-bit versions of SoftHSMv2. |
| 4 | + |
| 5 | +## Required software |
| 6 | + |
| 7 | +- [Visual Studio](https://visualstudio.microsoft.com/vs/community/) (Community) |
| 8 | +- [C/C++ dependency manager from Microsoft](https://vcpkg.io/) |
| 9 | +- [CMake](https://cmake.org/) |
| 10 | + |
| 11 | +## Prepare working directories |
| 12 | + |
| 13 | + set VCPKG_HOME=C:\Projects\vcpkg |
| 14 | + set SOFTHSM_HOME=C:\Projects\SoftHSMv2 |
| 15 | + git clone https://github.com/opendnssec/SoftHSMv2.git %SOFTHSM_HOME% |
| 16 | + git clone https://github.com/Microsoft/vcpkg.git %VCPKG_HOME% |
| 17 | + |
| 18 | +## Build dependencies |
| 19 | + |
| 20 | + cd %VCPKG_HOME% |
| 21 | + bootstrap-vcpkg.bat |
| 22 | + git fetch |
| 23 | + git checkout 2021.05.12 |
| 24 | + |
| 25 | + vcpkg install cppunit:x86-windows |
| 26 | + vcpkg install cppunit:x86-windows-static |
| 27 | + vcpkg install openssl-windows:x86-windows |
| 28 | + vcpkg install botan:x86-windows |
| 29 | + vcpkg install sqlite3:x86-windows |
| 30 | + |
| 31 | + vcpkg install cppunit:x64-windows |
| 32 | + vcpkg install cppunit:x64-windows-static |
| 33 | + vcpkg install openssl-windows:x64-windows |
| 34 | + vcpkg install botan:x64-windows |
| 35 | + vcpkg install sqlite3:x64-windows |
| 36 | + |
| 37 | + vcpkg integrate install |
| 38 | + |
| 39 | +## Configure SoftHSMv2 |
| 40 | + |
| 41 | +Build can be configured using the following commands: |
| 42 | + |
| 43 | + mkdir %SOFTHSM_HOME%\tmp32 |
| 44 | + cd %SOFTHSM_HOME%\tmp32 |
| 45 | + cmake .. -G "Visual Studio 15 2017" -A Win32 -DCMAKE_TOOLCHAIN_FILE=%VCPKG_HOME%\scripts\buildsystems\vcpkg.cmake -DCMAKE_INSTALL_PREFIX=%SOFTHSM_HOME%\out32 -DBUILD_TESTS=ON -DWITH_CRYPTO_BACKEND=openssl -DWITH_OBJECTSTORE_BACKEND_DB=OFF |
| 46 | + |
| 47 | + mkdir %SOFTHSM_HOME%\tmp64 |
| 48 | + cd %SOFTHSM_HOME%\tmp64 |
| 49 | + cmake .. -G "Visual Studio 15 2017" -A x64 -DCMAKE_TOOLCHAIN_FILE=%VCPKG_HOME%\scripts\buildsystems\vcpkg.cmake -DCMAKE_INSTALL_PREFIX=%SOFTHSM_HOME%\out64 -DBUILD_TESTS=ON -DWITH_CRYPTO_BACKEND=botan -DWITH_OBJECTSTORE_BACKEND_DB=ON |
| 50 | + |
| 51 | +Some options (more can be found in CMakeLists.txt): |
| 52 | + |
| 53 | + -DBUILD_TESTS=ON Compile tests along with libraries |
| 54 | + -DENABLE_EDDSA=ON Enable support for EDDSA |
| 55 | + -DWITH_MIGRATE=ON Build migration tool |
| 56 | + -DWITH_CRYPTO_BACKEND= Select crypto backend (openssl|botan) |
| 57 | + -DDISABLE_NON_PAGED_MEMORY=ON Disable non-paged memory for secure storage |
| 58 | + -DWITH_OBJECTSTORE_BACKEND_DB=ON Enable sqlite3 data storage |
| 59 | + |
| 60 | +## Compile |
| 61 | + |
| 62 | +Compile the source code using the following command: |
| 63 | + |
| 64 | + cmake --build . --config RelWithDebInfo |
| 65 | + |
| 66 | +## Test |
| 67 | + |
| 68 | + ctest -C RelWithDebInfo --output-on-failure --progress --verbose |
| 69 | + |
| 70 | +## Install |
| 71 | + |
| 72 | +Install the library using the follow command: |
| 73 | + |
| 74 | + cmake -DCMAKE_INSTALL_CONFIG_NAME=RelWithDebInfo -P cmake_install.cmake |
0 commit comments