Skip to content

Commit

Permalink
Install / Packaging support for build artifacts and source code
Browse files Browse the repository at this point in the history
- added a few missing compiler options
- added support for 'make install' target (equivalent to autotools)
- added packaging support for all build artifacts through 'make package'
target; generates SoftHSM-2.5.0-Linux.tar.gz
- added packaging support for source code through 'make package_source'
target; generates SoftHSM-2.5.0-Source.tar.gz, which is a snapshot of
the source code at time of packaging
  • Loading branch information
conz27 authored and bellgrim committed Apr 30, 2018
1 parent 5d0160b commit 4f787a9
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 9 deletions.
28 changes: 22 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,26 @@ option(WITH_OPENSSL "Compile with support of OpenSSL" ON)
option(WITH_P11_KIT "Build with p11-kit module" OFF)
option(WITH_SQLITE3 "Compiles with support of SQLite3" OFF)

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 "/usr/local/lib/softhsm/libsofthsm2.so"
set(DEFAULT_PKCS11_LIB "${CMAKE_INSTALL_LIBDIR}/softhsm/libsofthsm2.so"
CACHE STRING "The default PKCS#11 library")
set(DEFAULT_SOFTHSM2_CONF "/etc/softhsm2.conf"
set(DEFAULT_SOFTHSM2_CONF "${CMAKE_INSTALL_SYSCONFDIR}/softhsm2.conf"
CACHE STRING "The default location of softhsm.conf")
set(DEFAULT_TOKENDIR "/var/lib/softhsm/tokens/"
set(DEFAULT_TOKENDIR "${CMAKE_INSTALL_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.3.0")
set(VERSION "2.5.0")
set(VERSION_MAJOR 2)
set(VERSION_MINOR 3)
set(VERSION_MINOR 5)
set(VERSION_PATCH 0)

set(PACKAGE "softhsm")
set(PACKAGE_BUGREPORT)
Expand All @@ -58,7 +61,8 @@ project(softhsm2)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
${CMAKE_SOURCE_DIR}/modules
)
# Modules

# Custom Modules
include(CompilerOptions)
include(GenerateExportHeader)

Expand All @@ -69,3 +73,15 @@ enable_testing()
include_directories(${CMAKE_BINARY_DIR})

add_subdirectory(src)

# 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)
4 changes: 4 additions & 0 deletions modules/CompilerOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ endif(ENABLE_SHARED)

# Compiler Options/Macros

add_compile_options(-MD)
add_compile_options(-MP)
add_compile_options(-MF)

# FIXME: [Implement AC_HEADER_STDC]:
# Find a CMake mechanism performs the check as defined in
# AC_HEADER_STDC:
Expand Down
14 changes: 14 additions & 0 deletions src/bin/dump/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,25 @@ set(INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/../../lib
${SQLITE3_INCLUDES}
)

set(INSTALL_TARGETS ${PROJECT_NAME}-file)
set(INSTALL_MAN_FILES ${PROJECT_NAME}-file.1)

include_directories(${INCLUDE_DIRS})

add_executable(${PROJECT_NAME}-file softhsm2-dump-file.cpp)

if(WITH_OBJECTSTORE_BACKEND_DB)
add_executable(${PROJECT_NAME}-db softhsm2-dump-db.cpp)
target_link_libraries(${PROJECT_NAME}-db ${SQLITE3_LIBS} ${YIELD_LIB})
list(APPEND INSTALL_TARGETS ${PROJECT_NAME}-db)
list(APPEND INSTALL_MAN_FILES ${PROJECT_NAME}-db.1)
endif(WITH_OBJECTSTORE_BACKEND_DB)

install(TARGETS ${INSTALL_TARGETS}
DESTINATION ${CMAKE_INSTALL_BINDIR}
)

install(FILES ${INSTALL_MAN_FILES}
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1
)

8 changes: 8 additions & 0 deletions src/bin/keyconv/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,11 @@ endif(WITH_BOTAN)
include_directories(${INCLUDE_DIRS})
add_executable(${PROJECT_NAME} ${SOURCES})
target_link_libraries(${PROJECT_NAME} ${CRYPTO_LIBS})

install(TARGETS ${PROJECT_NAME}
DESTINATION ${CMAKE_INSTALL_BINDIR}
)

install(FILES ${PROJECT_NAME}.1
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1
)
8 changes: 8 additions & 0 deletions src/bin/util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,11 @@ endif(WITH_BOTAN)
include_directories(${INCLUDE_DIRS})
add_executable(${PROJECT_NAME} ${SOURCES})
target_link_libraries(${PROJECT_NAME} softhsm2-static ${CRYPTO_LIBS} ${SQLITE3_LIBS} ${CMAKE_DL_LIBS})

install(TARGETS ${PROJECT_NAME}
DESTINATION ${CMAKE_INSTALL_BINDIR}
)

install(FILES ${PROJECT_NAME}.1
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1
)
7 changes: 6 additions & 1 deletion src/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,10 @@ if(BUILD_TESTS)
endif(BUILD_TESTS)

###############################################################################
# Install / Packaging
# Install
###############################################################################
install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}-static
DESTINATION ${CMAKE_INSTALL_LIBDIR}/softhsm
)

install(DIRECTORY DESTINATION ${CMAKE_INSTALL_LOCALSTATEDIR}/lib/softhsm/tokens)
15 changes: 13 additions & 2 deletions src/lib/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ include_directories(${INCLUDE_DIRS})
add_library(${PROJECT_NAME}-obj OBJECT ${SOURCES})
add_library(${PROJECT_NAME} STATIC $<TARGET_OBJECTS:${PROJECT_NAME}-obj>)

configure_file(softhsm2.conf.in ${PROJECT_BINARY_DIR}/softhsm2.conf)
configure_file(softhsm2.conf.5.in ${PROJECT_BINARY_DIR}/softhsm2.conf.5)
set(softhsmtokendir ${DEFAULT_TOKENDIR})
set(default_softhsm2_conf ${CMAKE_INSTALL_FULL_SYSCONFDIR}/softhsm2.conf)
configure_file(softhsm2.conf.in ${PROJECT_BINARY_DIR}/etc/softhsm2.conf)
configure_file(softhsm2.conf.in ${PROJECT_BINARY_DIR}/etc/softhsm2.conf.sample)
configure_file(softhsm2.conf.5.in ${PROJECT_BINARY_DIR}/man5/softhsm2.conf.5)

install(FILES ${PROJECT_BINARY_DIR}/etc/softhsm2.conf
${PROJECT_BINARY_DIR}/etc/softhsm2.conf.sample
DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}
)

install(FILES ${PROJECT_BINARY_DIR}/man5/softhsm2.conf.5
DESTINATION ${CMAKE_INSTALL_MANDIR}/man5
)

0 comments on commit 4f787a9

Please sign in to comment.