forked from softhsm/SoftHSMv2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request softhsm#362 from conz27/cmake_support
CMake Build System Support for SoftHSM
- Loading branch information
Showing
63 changed files
with
1,949 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Building SoftHSMv2 with CMake | ||
|
||
## Configure | ||
|
||
CMake can be configured using the following command: | ||
|
||
cmake -H. -Bbuild | ||
|
||
Some options (more can be found in CMakeLists.txt): | ||
|
||
-DBUILD_TESTS=ON Compile tests along with libraries | ||
-DDISABLE_NON_PAGED_MEMORY=ON Disable non-paged memory for secure storage | ||
-DENABLE_EDDSA=ON Enable support for EDDSA | ||
-DWITH_MIGRATE=ON Build migration tool | ||
-DWITH_CRYPTO_BACKEND=openssl Select crypto backend (openssl|botan) | ||
|
||
## Compile | ||
|
||
Compile the source code using the following command: | ||
|
||
make -C build | ||
|
||
## Test | ||
|
||
The tests can be run from the build directory: | ||
|
||
cd build | ||
ctest -V | ||
|
||
## Install | ||
|
||
Install the library using the follow command: | ||
|
||
cd .. | ||
sudo make -C build install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
cmake_minimum_required(VERSION 3.5) | ||
|
||
project(softhsm2 C CXX) | ||
|
||
# Build Options | ||
option(BUILD_TESTS "Compile tests along with libraries" OFF) | ||
option(DISABLE_NON_PAGED_MEMORY "Disable non-paged memory for secure storage" OFF) | ||
option(DISABLE_VISIBILITY "Disables and unsets -fvisibility=hidden" OFF) | ||
option(ENABLE_64bit "Enable 64-bit compiling" OFF) | ||
option(ENABLE_ECC "Enable support for ECC" ON) | ||
option(ENABLE_EDDSA "Enable support for EDDSA" OFF) | ||
option(ENABLE_GOST "Enable support for GOST" ON) | ||
option(ENABLE_FIPS "Enable support for FIPS 140-2 mode" OFF) | ||
option(ENABLE_P11_KIT "Enable p11-kit integration" ON) | ||
option(ENABLE_PEDANTIC "Enable pedantic compile mode" OFF) | ||
option(ENABLE_STRICT "Enable strict compile mode" ON) | ||
option(ENABLE_SHARED "Build shared libraries" ON) | ||
option(ENABLE_STATIC "Build static libraries" ON) | ||
option(WITH_OBJECTSTORE_BACKEND_DB "Build with object store backend database (SQLite3)" OFF) | ||
option(WITH_MIGRATE "Build migration tool. Requires SQLite3." OFF) | ||
set(WITH_CRYPTO_BACKEND "openssl" | ||
CACHE STRING "Select crypto backend (openssl|botan)") | ||
set(WITH_P11_KIT "" | ||
CACHE STRING "Specify install path of the p11-kit module, will override path given by pkg-config") | ||
|
||
if(WITH_OBJECTSTORE_BACKEND_DB) | ||
set(HAVE_OBJECTSTORE_BACKEND_DB 1) | ||
set(WITH_MIGRATE ON) | ||
set(WITH_SQLITE3 ON) | ||
message(STATUS "Building with support for object store backend database") | ||
else(WITH_OBJECTSTORE_BACKEND_DB) | ||
message(STATUS "Building with no support for object store backend database") | ||
endif(WITH_OBJECTSTORE_BACKEND_DB) | ||
|
||
if(WITH_MIGRATE) | ||
set(BUILD_MIGRATE ON) | ||
set(WITH_SQLITE3 ON) | ||
message(STATUS "Building with migration tool") | ||
else(WITH_MIGRATE) | ||
message(STATUS "Building with no migration tool") | ||
endif(WITH_MIGRATE) | ||
|
||
if(NOT DEFINED CMAKE_INSTALL_SYSCONFDIR) | ||
set(CMAKE_INSTALL_SYSCONFDIR "/etc") | ||
endif() | ||
if(NOT DEFINED CMAKE_INSTALL_LOCALSTATEDIR) | ||
set(CMAKE_INSTALL_LOCALSTATEDIR "/var") | ||
endif() | ||
include(GNUInstallDirs) | ||
|
||
set(DEFAULT_LOG_LEVEL "INFO" | ||
CACHE STRING "The default log level") | ||
set(DEFAULT_OBJECTSTORE_BACKEND "file" | ||
CACHE STRING "Default storage backend for token objects") | ||
set(DEFAULT_PKCS11_LIB "${CMAKE_INSTALL_FULL_LIBDIR}/softhsm/libsofthsm2.so" | ||
CACHE STRING "The default PKCS#11 library") | ||
set(DEFAULT_SOFTHSM2_CONF "${CMAKE_INSTALL_FULL_SYSCONFDIR}/softhsm2.conf" | ||
CACHE STRING "The default location of softhsm.conf") | ||
set(DEFAULT_TOKENDIR "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/softhsm/tokens/" | ||
CACHE STRING "The default location of the token directory") | ||
|
||
set(MAX_PIN_LEN 255 CACHE STRING "Maximum PIN length") | ||
set(MIN_PIN_LEN 4 CACHE STRING "Minimum PIN length") | ||
|
||
set(VERSION "2.5.0") | ||
set(VERSION_MAJOR 2) | ||
set(VERSION_MINOR 5) | ||
set(VERSION_PATCH 0) | ||
|
||
set(PACKAGE "softhsm") | ||
set(PACKAGE_BUGREPORT) | ||
set(PACKAGE_NAME "SoftHSM") | ||
set(PACKAGE_VERSION "${VERSION}") | ||
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") | ||
set(PACKAGE_TARNAME "${PACKAGE}") | ||
set(PACKAGE_URL) | ||
|
||
if(NOT CMAKE_BUILD_TYPE) | ||
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Default build type for SoftHSMv2 project" FORCE) | ||
endif(NOT CMAKE_BUILD_TYPE) | ||
|
||
message(STATUS "Build Configuration: ${CMAKE_BUILD_TYPE}") | ||
|
||
# Build Modules Path | ||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} | ||
${CMAKE_SOURCE_DIR}/modules | ||
) | ||
|
||
# Custom Modules | ||
include(CompilerOptions) | ||
include(GenerateExportHeader) | ||
|
||
# Enable CTest | ||
enable_testing() | ||
|
||
# config.h include path | ||
include_directories(${CMAKE_BINARY_DIR}) | ||
|
||
add_subdirectory(src) | ||
|
||
# p11-kit | ||
set(default_softhsm2_lib ${DEFAULT_PKCS11_LIB}) | ||
configure_file(softhsm2.module.in softhsm2.module) | ||
if(ENABLE_P11_KIT) | ||
install(FILES ${PROJECT_BINARY_DIR}/softhsm2.module | ||
DESTINATION ${P11KIT_PATH} | ||
) | ||
endif(ENABLE_P11_KIT) | ||
|
||
# Packaging | ||
set(CPACK_PACKAGE_NAME ${PACKAGE_NAME}) | ||
set(CPACK_PACKAGE_VENDOR "OpenDNSSEC") | ||
set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR}) | ||
set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR}) | ||
set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH}) | ||
set(CPACK_GENERATOR "TGZ") | ||
set(CPACK_SOURCE_GENERATOR "TGZ") | ||
set(CPACK_SOURCE_IGNORE_FILES "build/*;\.git/*") | ||
|
||
include(CPack) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
/* DO NOT MODIFY! config.h: autogenerated by CMake from config.h.in.cmake. */ | ||
|
||
/* Define to default visibility of PKCS#11 entry points */ | ||
#cmakedefine CRYPTOKI_VISIBILITY @CRYPTOKI_VISIBILITY@ | ||
|
||
/* The default log level */ | ||
#cmakedefine DEFAULT_LOG_LEVEL "@DEFAULT_LOG_LEVEL@" | ||
|
||
/* Default storage backend for token objects */ | ||
#cmakedefine DEFAULT_OBJECTSTORE_BACKEND "@DEFAULT_OBJECTSTORE_BACKEND@" | ||
|
||
/* The default PKCS#11 library */ | ||
#cmakedefine DEFAULT_PKCS11_LIB "@DEFAULT_PKCS11_LIB@" | ||
|
||
/* The default location of softhsm2.conf */ | ||
#cmakedefine DEFAULT_SOFTHSM2_CONF "@DEFAULT_SOFTHSM2_CONF@" | ||
|
||
/* The default location of the token directory */ | ||
#cmakedefine DEFAULT_TOKENDIR "@DEFAULT_TOKENDIR@" | ||
|
||
/* Define if advanced AES key wrap without pad is supported */ | ||
#cmakedefine HAVE_AES_KEY_WRAP @HAVE_AES_KEY_WRAP@ | ||
|
||
/* Define if advanced AES key wrap with pad is supported */ | ||
#cmakedefine HAVE_AES_KEY_WRAP_PAD @HAVE_AES_KEY_WRAP_PAD@ | ||
|
||
/* define if the compiler supports basic C++11 syntax */ | ||
#cmakedefine HAVE_CXX11 @HAVE_CXX11@ | ||
|
||
/* Define to 1 if you have the <dlfcn.h> header file. */ | ||
#cmakedefine HAVE_DLFCN_H @HAVE_DLFCN_H@ | ||
|
||
/* Define if you have dlopen */ | ||
#cmakedefine HAVE_DLOPEN @HAVE_DLOPEN@ | ||
|
||
/* Define to 1 if you have the `getpwuid_r' function. */ | ||
#cmakedefine HAVE_GETPWUID_R @HAVE_GETPWUID_R@ | ||
|
||
/* Define to 1 if you have the <inttypes.h> header file. */ | ||
#cmakedefine HAVE_INTTYPES_H @HAVE_INTTYPES_H@ | ||
|
||
/* Define to 1 if you have the `crypto' library (-lcrypto). */ | ||
#cmakedefine HAVE_LIBCRYPTO @HAVE_LIBCRYPTO@ | ||
|
||
/* Define to 1 if you have the `sqlite3' library (-lsqlite3). */ | ||
#cmakedefine HAVE_LIBSQLITE3 @HAVE_LIBSQLITE3@ | ||
|
||
/* Whether LoadLibrary is available */ | ||
#cmakedefine HAVE_LOADLIBRARY @HAVE_LOADLIBRARY@ | ||
|
||
/* Define to 1 if you have the <memory.h> header file. */ | ||
#cmakedefine HAVE_MEMORY_H @HAVE_MEMORY_H@ | ||
|
||
/* Build with object store database backend. */ | ||
#cmakedefine HAVE_OBJECTSTORE_BACKEND_DB @HAVE_OBJECTSTORE_BACKEND_DB@ | ||
|
||
/* Define to 1 if you have the <openssl/ssl.h> header file. */ | ||
#cmakedefine HAVE_OPENSSL_SSL_H @HAVE_OPENSSL_SSL_H@ | ||
|
||
/* Define to 1 if you have the <pthread.h> header file. */ | ||
#cmakedefine HAVE_PTHREAD_H @HAVE_PTHREAD_H@ | ||
|
||
/* Define to 1 if you have the <sqlite3.h> header file. */ | ||
#cmakedefine HAVE_SQLITE3_H @HAVE_SQLITE3_H@ | ||
|
||
/* Define to 1 if you have the <stdint.h> header file. */ | ||
#cmakedefine HAVE_STDINT_H @HAVE_STDLIB_H@ | ||
|
||
/* Define to 1 if you have the <stdlib.h> header file. */ | ||
#cmakedefine HAVE_STDLIB_H @HAVE_STDLIB_H@ | ||
|
||
/* Define to 1 if you have the <strings.h> header file. */ | ||
#cmakedefine HAVE_STRINGS_H @HAVE_STRINGS_H@ | ||
|
||
/* Define to 1 if you have the <string.h> header file. */ | ||
#cmakedefine HAVE_STRING_H @HAVE_STRING_H@ | ||
|
||
/* Define to 1 if you have the <sys/mman.h> header file. */ | ||
#cmakedefine HAVE_SYS_MMAN_H @HAVE_SYS_MMAN_H@ | ||
|
||
/* Define to 1 if you have the <sys/stat.h> header file. */ | ||
#cmakedefine HAVE_SYS_STAT_H @HAVE_SYS_STAT_H@ | ||
|
||
/* Define to 1 if you have the <sys/types.h> header file. */ | ||
#cmakedefine HAVE_SYS_TYPES_H @HAVE_SYS_TYPES_H@ | ||
|
||
/* Define to 1 if you have the <unistd.h> header file. */ | ||
#cmakedefine HAVE_UNISTD_H @HAVE_UNISTD_H@ | ||
|
||
/* Define to the sub-directory where libtool stores uninstalled libraries. */ | ||
#cmakedefine LT_OBJDIR "@LT_OBJDIR@" | ||
|
||
/* Maximum PIN length */ | ||
#cmakedefine MAX_PIN_LEN @MAX_PIN_LEN@ | ||
|
||
/* Minimum PIN length */ | ||
#cmakedefine MIN_PIN_LEN @MIN_PIN_LEN@ | ||
|
||
/* Name of package */ | ||
#cmakedefine PACKAGE "@PACKAGE@" | ||
|
||
/* Define to the address where bug reports for this package should be sent. */ | ||
#cmakedefine PACKAGE_BUGREPORT "@PACKAGE_BUGREPORT@" | ||
|
||
/* Define to the full name of this package. */ | ||
#cmakedefine PACKAGE_NAME "@PACKAGE_NAME@" | ||
|
||
/* Define to the full name and version of this package. */ | ||
#cmakedefine PACKAGE_STRING "@PACKAGE_STRING@" | ||
|
||
/* Define to the one symbol short name of this package. */ | ||
#cmakedefine PACKAGE_TARNAME "@PACKAGE_TARNAME@" | ||
|
||
/* Define to the home page for this package. */ | ||
#cmakedefine PACKAGE_URL "@PACKAGE_URL@" | ||
|
||
/* Define to the version of this package. */ | ||
#cmakedefine PACKAGE_VERSION "@PACKAGE_VERSION@" | ||
|
||
/* Non-paged memory for secure storage */ | ||
#cmakedefine SENSITIVE_NON_PAGE @SENSITIVE_NON_PAGE@ | ||
|
||
/* Define to 1 if you have the ANSI C header files. | ||
* | ||
* FIXME: CMake currently does not implement a way to detect STDC_HEADERS like | ||
* autotools, so we're setting it to '1' by default. | ||
*/ | ||
#cmakedefine STDC_HEADERS @STDC_HEADERS@ | ||
|
||
/* Version number of package */ | ||
#cmakedefine VERSION "@VERSION@" | ||
|
||
/* SoftHSM major version number via PKCS#11 */ | ||
#cmakedefine VERSION_MAJOR @VERSION_MAJOR@ | ||
|
||
/* SoftHSM minor version number via PKCS#11 */ | ||
#cmakedefine VERSION_MINOR @VERSION_MINOR@ | ||
|
||
/* Compile with AES GCM */ | ||
#cmakedefine WITH_AES_GCM @WITH_AES_GCM@ | ||
|
||
/* Compile with Botan support */ | ||
#cmakedefine WITH_BOTAN @WITH_BOTAN@ | ||
|
||
/* Compile with ECC support */ | ||
#cmakedefine WITH_ECC @WITH_ECC@ | ||
|
||
/* Compile with EDDSA support */ | ||
#cmakedefine WITH_EDDSA @WITH_EDDSA@ | ||
|
||
/* Compile with FIPS 140-2 mode */ | ||
#cmakedefine WITH_FIPS @WITH_FIPS@ | ||
|
||
/* Compile with GOST support */ | ||
#cmakedefine WITH_GOST @WITH_GOST@ | ||
|
||
/* Compile with OpenSSL support */ | ||
#cmakedefine WITH_OPENSSL @WITH_OPENSSL@ | ||
|
||
/* Compile with raw RSA PKCS PSS */ | ||
#cmakedefine WITH_RAW_PSS @WITH_RAW_PSS@ |
Oops, something went wrong.