aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2017-02-06 15:36:07 +0100
committerSzczepan Zalega <szczepan@nitrokey.com>2017-03-11 15:41:44 +0100
commit166b2e39f3815216871c0f505e9d879e11ca5080 (patch)
tree9c01c5a042121a598be4ac33de18610108c3dd14
parent1792b8d6a843a79f5b333163bd74b99ac2cfdb30 (diff)
downloadlibnitrokey-166b2e39f3815216871c0f505e9d879e11ca5080.tar.gz
libnitrokey-166b2e39f3815216871c0f505e9d879e11ca5080.tar.bz2
Allow user to build only one version (static/dynamic) of the lib at once
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
-rw-r--r--CMakeLists.txt15
1 files changed, 10 insertions, 5 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7f183ef..715c61d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -18,6 +18,8 @@ project(libnitrokey CXX)
SET(PROJECT_VERSION "3.0-alpha")
set(CMAKE_CXX_STANDARD 14)
+OPTION(LIBNITROKEY_STATIC "Build libnitrokey statically" TRUE)
+
OPTION(COMPILE_TESTS "Compile tests" FALSE)
IF (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RelWithDebInfo)
@@ -52,12 +54,15 @@ set(SOURCE_FILES
)
-add_library(nitrokey SHARED ${SOURCE_FILES})
-add_library(nitrokey-static STATIC ${SOURCE_FILES})
-target_link_libraries(nitrokey hidapi-libusb)
-target_link_libraries(nitrokey-static hidapi-libusb)
+IF (NOT LIBNITROKEY_STATIC)
+ add_library(nitrokey SHARED ${SOURCE_FILES})
+ target_link_libraries(nitrokey hidapi-libusb)
+ install (TARGETS nitrokey DESTINATION "lib")
+ELSE()
+ add_library(nitrokey-static STATIC ${SOURCE_FILES})
+ target_link_libraries(nitrokey-static hidapi-libusb)
+ENDIF()
-install (TARGETS nitrokey DESTINATION "lib")
file(GLOB LIB_INCLUDES "include/libnitrokey/*.h")
install (FILES ${LIB_INCLUDES} DESTINATION "include")