| 1 |
############################################################################### |
| 2 |
# Dependencies |
| 3 |
############################################################################### |
| 4 |
add_subdirectory(common) |
| 5 |
add_subdirectory(crypto) |
| 6 |
add_subdirectory(data_mgr) |
| 7 |
add_subdirectory(handle_mgr) |
| 8 |
add_subdirectory(object_store) |
| 9 |
add_subdirectory(session_mgr) |
| 10 |
add_subdirectory(slot_mgr) |
| 11 |
|
| 12 |
############################################################################### |
| 13 |
# SoftHSMv2 Config |
| 14 |
############################################################################### |
| 15 |
set(INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/common |
| 16 |
${CMAKE_CURRENT_SOURCE_DIR}/crypto |
| 17 |
${CMAKE_CURRENT_SOURCE_DIR}/data_mgr |
| 18 |
${CMAKE_CURRENT_SOURCE_DIR}/handle_mgr |
| 19 |
${CMAKE_CURRENT_SOURCE_DIR}/object_store |
| 20 |
${CMAKE_CURRENT_SOURCE_DIR}/pkcs11 |
| 21 |
${CMAKE_CURRENT_SOURCE_DIR}/session_mgr |
| 22 |
${CMAKE_CURRENT_SOURCE_DIR}/slot_mgr |
| 23 |
${CRYPTO_INCLUDES} |
| 24 |
) |
| 25 |
|
| 26 |
include_directories(${INCLUDE_DIRS}) |
| 27 |
|
| 28 |
set(SOURCES access.cpp |
| 29 |
main.cpp |
| 30 |
P11Attributes.cpp |
| 31 |
P11Objects.cpp |
| 32 |
SoftHSM.cpp |
| 33 |
) |
| 34 |
|
| 35 |
set(STATIC_FILES softhsm_common |
| 36 |
softhsm_crypto |
| 37 |
softhsm_datamgr |
| 38 |
softhsm_handlemgr |
| 39 |
softhsm_objectstore |
| 40 |
softhsm_sessionmgr |
| 41 |
softhsm_slotmgr |
| 42 |
) |
| 43 |
|
| 44 |
if(CMAKE_VERSION VERSION_LESS "3.12") |
| 45 |
# Older CMake versions cannot link object libraries to a target, so pass |
| 46 |
# the associated object files as source. Similarly, softhsm_crypto and |
| 47 |
# softhsm_objectstore object library dependencies cannot be propagated |
| 48 |
# so as a workaround explicitly specify it here. |
| 49 |
foreach(libname IN LISTS STATIC_FILES) |
| 50 |
list(APPEND SOURCES $<TARGET_OBJECTS:${libname}>) |
| 51 |
endforeach() |
| 52 |
# Older CMake versions forbid library dependencies on object libraries, |
| 53 |
# therefore repeat softhsm_crypto and softhsm_objectstore dependencies. |
| 54 |
set(STATIC_FILES ${CRYPTO_LIBS} ${SQLITE3_LIBS}) |
| 55 |
endif() |
| 56 |
|
| 57 |
|
| 58 |
############################################################################### |
| 59 |
# Static Library Config |
| 60 |
############################################################################### |
| 61 |
add_library(${PROJECT_NAME}-static STATIC ${SOURCES}) |
| 62 |
target_link_libraries(${PROJECT_NAME}-static ${STATIC_FILES}) |
| 63 |
set_target_properties(${PROJECT_NAME}-static |
| 64 |
PROPERTIES OUTPUT_NAME ${PROJECT_NAME} |
| 65 |
) |
| 66 |
generate_export_header(${PROJECT_NAME}-static) |
| 67 |
|
| 68 |
############################################################################### |
| 69 |
# Shared Library Config |
| 70 |
############################################################################### |
| 71 |
add_library(${PROJECT_NAME} SHARED ${SOURCES}) |
| 72 |
target_link_libraries(${PROJECT_NAME} ${STATIC_FILES}) |
| 73 |
generate_export_header(${PROJECT_NAME}) |
| 74 |
|
| 75 |
############################################################################### |
| 76 |
# Tests |
| 77 |
############################################################################### |
| 78 |
if(BUILD_TESTS) |
| 79 |
add_subdirectory(test) |
| 80 |
endif(BUILD_TESTS) |
| 81 |
|
| 82 |
############################################################################### |
| 83 |
# Install |
| 84 |
############################################################################### |
| 85 |
install(TARGETS ${PROJECT_NAME} |
| 86 |
DESTINATION ${CMAKE_INSTALL_LIBDIR}/softhsm |
| 87 |
) |
| 88 |
if(ENABLE_STATIC) |
| 89 |
install(TARGETS ${PROJECT_NAME}-static |
| 90 |
DESTINATION ${CMAKE_INSTALL_LIBDIR}/softhsm |
| 91 |
) |
| 92 |
endif() |