diff options
author | Szczepan Zalega <szczepan@nitrokey.com> | 2017-10-22 09:02:41 +0200 |
---|---|---|
committer | Szczepan Zalega <szczepan@nitrokey.com> | 2017-11-03 15:09:19 +0100 |
commit | 3e5ef9e181084cc88ef59811e6eba1d7d82ba4cf (patch) | |
tree | 1b8e2fbf5965d8f2ee69b839282d2b9f7692e463 /CMakeLists.txt | |
parent | dab6f2bcf292dfd6ee629a4ad9b2216e104d7c1d (diff) | |
download | libnitrokey-3e5ef9e181084cc88ef59811e6eba1d7d82ba4cf.tar.gz libnitrokey-3e5ef9e181084cc88ef59811e6eba1d7d82ba4cf.tar.bz2 |
Use hand-inserted version. Remove one Git pass.pr_62
Full version name should consist of official version and Git one
Git describe should never fail with --always switch
Add more build specific information
Save compilation definitions and flags
Move getting information to the end of CMakeLists.txt
Use configuration over definitions
Proper implementation in C API for getting version
Test case for getting version.
Working configure file
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 56 |
1 files changed, 31 insertions, 25 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 537a54a..f82df8e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,43 +28,19 @@ IF (UNIX) ENDIF() project(libnitrokey) -SET(PROJECT_VERSION "3.1") set(CMAKE_CXX_STANDARD 14) set(LIBNK_VERSION_MAJOR 3) # reminder: incompatible API changes set(LIBNK_VERSION_MINOR 1) # add functionality in a backwards-compatible manner set(LIBNK_VERSION_PATCH 0) # make backwards-compatible bug fixes set(LIBNK_VERSION ${LIBNK_VERSION_MAJOR}.${LIBNK_VERSION_MINOR}.${LIBNK_VERSION_PATCH} ) +SET(PROJECT_VERSION "${LIBNK_VERSION}") include(GNUInstallDirs) OPTION(LIBNITROKEY_STATIC "Build libnitrokey statically" FALSE) -# Getter for the library version -# -# If a git tag is available, we use it. -# Else, we use a git version and we raise a warning. -# -exec_program( - "git" - ${CMAKE_CURRENT_SOURCE_DIR} - ARGS "describe" - OUTPUT_VARIABLE GIT_VERSION) - -IF(${GIT_TAG} MATCHES "fatal:.*") -MESSAGE(WARNING "Unable to find a git tag. Using git version instead.") -exec_program( - "git" - ${CMAKE_CURRENT_SOURCE_DIR} - ARGS "rev-parse HEAD" - OUTPUT_VARIABLE GIT_VERSION) -ENDIF() - -MESSAGE("LIBRARY VERSION: ${GIT_VERSION} ") -ADD_DEFINITIONS(-DVERSION="${GIT_VERSION}") - - IF (NOT CMAKE_BUILD_TYPE) IF(APPLE) # Issues occur when build with enabled optimizations @@ -98,6 +74,8 @@ set(SOURCE_FILES device.cc log.cc misc.cc + version.cc + version.h NitrokeyManager.cc NK_C_API.h NK_C_API.cc @@ -196,6 +174,34 @@ IF (COMPILE_TESTS) ENDIF() +# Getter for the library version +exec_program( + "git" + ${CMAKE_CURRENT_SOURCE_DIR} + ARGS "describe --always --dirty=-modified" + OUTPUT_VARIABLE GIT_VERSION) + +get_target_property(COMPILE_DEFINITIONS ${LIBNAME} COMPILE_DEFINITIONS) +get_target_property(COMPILE_FLAGS ${LIBNAME} COMPILE_FLAGS) +SET(FULL_VERSION "${PROJECT_VERSION}/${GIT_VERSION}") +SET(VERSION_MORE "${CMAKE_BUILD_TYPE}/${COMPILE_FLAGS}") +IF(COMPILE_DEFINITIONS) + SET(VERSION_MORE "${VERSION_MORE}/${COMPILE_DEFINITIONS}") +ENDIF() +IF(ADD_TSAN) + SET(VERSION_MORE "${VERSION_MORE} TSAN") +ENDIF() +IF(ADD_ASAN) + SET(VERSION_MORE "${VERSION_MORE} ASAN") +ENDIF() +IF(LIBNITROKEY_STATIC) + SET(VERSION_MORE "${VERSION_MORE} STATIC") +ENDIF() +MESSAGE("${PROJECT_NAME}: Version set: ${FULL_VERSION}") +MESSAGE("${PROJECT_NAME}: Version additional: ${VERSION_MORE}") + +configure_file(version.cc.in ${CMAKE_SOURCE_DIR}/version.cc) + #SET(CPACK_GENERATOR # "DEB;RPM") |