aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt43
1 files changed, 30 insertions, 13 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6e5ed53..8cb0fdc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -31,7 +31,15 @@ project(libnitrokey)
SET(PROJECT_VERSION "3.0-alpha")
set(CMAKE_CXX_STANDARD 14)
-OPTION(LIBNITROKEY_STATIC "Build libnitrokey statically" TRUE)
+set(LIBNK_VERSION_MAJOR 3) # reminder: incompatible API changes
+set(LIBNK_VERSION_MINOR 0) # 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} )
+
+
+include(GNUInstallDirs)
+
+OPTION(LIBNITROKEY_STATIC "Build libnitrokey statically" FALSE)
OPTION(COMPILE_TESTS "Compile tests" FALSE)
@@ -83,8 +91,8 @@ ENDIF()
IF (NOT LIBNITROKEY_STATIC)
add_library(nitrokey SHARED ${SOURCE_FILES})
- install (TARGETS nitrokey DESTINATION "lib")
- SET(LIBNAME nitrokey)
+ add_library(nitrokey-log SHARED ${SOURCE_FILES})
+ SET(LIBNAME nitrokey)
ELSE()
add_library(nitrokey-static STATIC ${SOURCE_FILES})
SET(LIBNAME nitrokey-static)
@@ -93,6 +101,11 @@ ENDIF()
target_link_libraries(${LIBNAME} hidapi-libusb)
+set_target_properties(${LIBNAME} PROPERTIES VERSION ${LIBNK_VERSION}
+ SOVERSION ${LIBNK_VERSION_MAJOR} )
+set_target_properties(${LIBNAME}-log PROPERTIES VERSION ${LIBNK_VERSION}
+ SOVERSION ${LIBNK_VERSION_MAJOR} )
+
OPTION(ERROR_ON_WARNING "Stop compilation on warning found (not supported for MSVC)" ON)
if (NOT MSVC)
set(COMPILE_FLAGS "-Wall -Wno-unused-function -Wcast-qual -Woverloaded-virtual")
@@ -110,14 +123,23 @@ IF (NO_LOG)
ENDIF()
-file(GLOB LIB_INCLUDES "include/libnitrokey/*.h")
-install (FILES ${LIB_INCLUDES} DESTINATION "include")
+file(GLOB LIB_INCLUDES "include/*.h")
+install (FILES ${LIB_INCLUDES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libnitrokey)
+install (TARGETS ${LIBNAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
+install (TARGETS ${LIBNAME}-log DESTINATION ${CMAKE_INSTALL_LIBDIR})
-IF (COMPILE_TESTS)
- include_directories(unittest/Catch/include)
- add_library(catch STATIC unittest/catch_main.cpp )
+include_directories(unittest/Catch/include)
+add_library(catch STATIC unittest/catch_main.cpp )
+add_executable (test_offline unittest/test_offline.cc)
+target_link_libraries (test_offline ${EXTRA_LIBS} ${LIBNAME}-log catch)
+#run with 'make test' or 'ctest'
+include (CTest)
+add_test (runs test_offline)
+IF (COMPILE_TESTS)
+ #needs connected PRO device for success
+ #warning: it may delete data on the device
add_executable (test_C_API unittest/test_C_API.cpp)
target_link_libraries (test_C_API ${EXTRA_LIBS} ${LIBNAME} catch)
@@ -136,11 +158,6 @@ IF (COMPILE_TESTS)
add_executable (test_issues unittest/test_issues.cc)
target_link_libraries (test_issues ${EXTRA_LIBS} ${LIBNAME} catch)
- #run with 'make test' or 'ctest'
- #needs connected PRO device for success
- #warning: it may delete data on the device
- include (CTest)
- add_test (runs test_C_API)
ENDIF()