From bb590b172f0d90fddd6187d78b4ffea5601b0561 Mon Sep 17 00:00:00 2001
From: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
Date: Sat, 7 Oct 2017 09:44:51 +0200
Subject: build: use GNUInstallDirs

This simplifies package maintainers life a lot so they don't
have to patch buildsystem at all. It just works.

Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
---
 CMakeLists.txt | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 11882f9..cd18827 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -31,6 +31,8 @@ project(libnitrokey)
 SET(PROJECT_VERSION "3.0-alpha")
 set(CMAKE_CXX_STANDARD 14)
 
+include(GNUInstallDirs)
+
 OPTION(LIBNITROKEY_STATIC "Build libnitrokey statically" TRUE)
 
 
@@ -84,7 +86,7 @@ ENDIF()
 IF (NOT LIBNITROKEY_STATIC)
     add_library(nitrokey SHARED ${SOURCE_FILES})
     add_library(nitrokey-log SHARED ${SOURCE_FILES})
-    install (TARGETS nitrokey DESTINATION "lib")
+    install (TARGETS nitrokey DESTINATION ${CMAKE_INSTALL_LIBDIR})
 	SET(LIBNAME nitrokey)
 ELSE()
     add_library(nitrokey-static STATIC ${SOURCE_FILES})    
@@ -111,7 +113,7 @@ SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES COMPILE_DEFINITIONS "NO_LOG")
 
 
 file(GLOB LIB_INCLUDES "include/libnitrokey/*.h")
-install (FILES ${LIB_INCLUDES} DESTINATION "include")
+install (FILES ${LIB_INCLUDES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
 
 IF (COMPILE_TESTS)
     include_directories(unittest/Catch/include)
-- 
cgit v1.2.3


From fd52487688c819919eb37d83d90dc96e11ab26ab Mon Sep 17 00:00:00 2001
From: Szczepan Zalega <szczepan@nitrokey.com>
Date: Sat, 7 Oct 2017 11:48:04 +0200
Subject: Set SONAME and use semantic versioning

Closes #69

Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
---
 CMakeLists.txt | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index cd18827..f35ba3b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -31,6 +31,12 @@ project(libnitrokey)
 SET(PROJECT_VERSION "3.0-alpha")
 set(CMAKE_CXX_STANDARD 14)
 
+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" TRUE)
@@ -98,6 +104,11 @@ ENDIF()
 target_link_libraries(${LIBNAME} hidapi-libusb)
 target_link_libraries(${LIBNAME}-log 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")
-- 
cgit v1.2.3


From a633e72064f48c062c684652cc70b6cb23d708b4 Mon Sep 17 00:00:00 2001
From: Szczepan Zalega <szczepan@nitrokey.com>
Date: Sat, 7 Oct 2017 11:48:49 +0200
Subject: Build shared library by default

Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
---
 CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index f35ba3b..da453cf 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -39,7 +39,7 @@ set(LIBNK_VERSION ${LIBNK_VERSION_MAJOR}.${LIBNK_VERSION_MINOR}.${LIBNK_VERSION_
 
 include(GNUInstallDirs)
 
-OPTION(LIBNITROKEY_STATIC "Build libnitrokey statically" TRUE)
+OPTION(LIBNITROKEY_STATIC "Build libnitrokey statically" FALSE)
 
 
 OPTION(COMPILE_TESTS "Compile tests" FALSE)
-- 
cgit v1.2.3


From ae7dd58eb381f3e95954705766dc5138e10a03f4 Mon Sep 17 00:00:00 2001
From: Szczepan Zalega <szczepan@nitrokey.com>
Date: Sat, 7 Oct 2017 11:50:26 +0200
Subject: Fix install command

Install binaries
Copy all headers to own directory

Closes #70

Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
---
 CMakeLists.txt | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index da453cf..d28425a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -92,8 +92,7 @@ ENDIF()
 IF (NOT LIBNITROKEY_STATIC)
     add_library(nitrokey SHARED ${SOURCE_FILES})
     add_library(nitrokey-log SHARED ${SOURCE_FILES})
-    install (TARGETS nitrokey DESTINATION ${CMAKE_INSTALL_LIBDIR})
-	SET(LIBNAME nitrokey)
+    SET(LIBNAME nitrokey)
 ELSE()
     add_library(nitrokey-static STATIC ${SOURCE_FILES})    
     add_library(nitrokey-static-log STATIC ${SOURCE_FILES})
@@ -123,8 +122,10 @@ endif()
 SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES COMPILE_DEFINITIONS "NO_LOG")
 
 
-file(GLOB LIB_INCLUDES "include/libnitrokey/*.h")
-install (FILES ${LIB_INCLUDES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
+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)
-- 
cgit v1.2.3