From 166b2e39f3815216871c0f505e9d879e11ca5080 Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Mon, 6 Feb 2017 15:36:07 +0100 Subject: Allow user to build only one version (static/dynamic) of the lib at once Signed-off-by: Szczepan Zalega --- CMakeLists.txt | 15 ++++++++++----- 1 file 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") -- cgit v1.2.3