aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorRobin Krahl <me@robin-krahl.de>2018-05-25 09:51:34 +0200
committerRobin Krahl <me@robin-krahl.de>2018-05-25 10:07:10 +0200
commit6e3ae3175b34679cf1e84fc6dc5b9ebe6a9c0478 (patch)
tree639d4586c6909e79391853a4ebd1908f5ff2eca2 /CMakeLists.txt
parentaee920b21d3951d2166ff73a533461e1bdd16e7f (diff)
downloadlibnitrokey-6e3ae3175b34679cf1e84fc6dc5b9ebe6a9c0478.tar.gz
libnitrokey-6e3ae3175b34679cf1e84fc6dc5b9ebe6a9c0478.tar.bz2
Add getters for the library version
CMake generates version.h from version.h.in and sets the major and minor version as specified in CMakeLists.txt and the current git version as returned by `git describe --always`. These values are also added to the C API as NK_get{_major,_minor,}_library_version.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt8
1 files changed, 7 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3dacb48..11e3f3c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -41,6 +41,7 @@ IF (NOT CMAKE_BUILD_TYPE)
ENDIF()
MESSAGE("${PROJECT_NAME}: Build type: ${CMAKE_BUILD_TYPE}")
+include_directories(${CMAKE_CURRENT_BINARY_DIR}/libnitrokey)
include_directories(hidapi)
include_directories(libnitrokey)
set(SOURCE_FILES
@@ -115,7 +116,12 @@ IF (LOG_VOLATILE_DATA)
ENDIF()
-file(GLOB LIB_INCLUDES "libnitrokey/*.h" "NK_C_API.h")
+# generate version.h
+exec_program("git" ${CMAKE_CURRENT_SOURCE_DIR} ARGS "describe --always" OUTPUT_VARIABLE PROJECT_VERSION_GIT)
+configure_file("libnitrokey/version.h.in" "libnitrokey/version.h" @ONLY)
+
+
+file(GLOB LIB_INCLUDES "libnitrokey/*.h" "NK_C_API.h" "${CMAKE_CURRENT_BINARY_DIR}/libnitrokey/version.h")
install (FILES ${LIB_INCLUDES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME})
install (TARGETS nitrokey DESTINATION ${CMAKE_INSTALL_LIBDIR})