summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2017-02-06 10:54:07 +0100
committerSzczepan Zalega <szczepan@nitrokey.com>2017-03-11 15:41:43 +0100
commit761765b54cb160e4b9f51376aff29a83ff693596 (patch)
tree76815feda160993ab9290d97fa7c0eada16843fa
parentc9867bccc816854f3670309f44c6dfbcb73429c5 (diff)
downloadlibnitrokey-761765b54cb160e4b9f51376aff29a83ff693596.tar.gz
libnitrokey-761765b54cb160e4b9f51376aff29a83ff693596.tar.bz2
Remove GCC specific settings. Make tests compilation optional.
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
-rw-r--r--CMakeLists.txt67
1 files changed, 44 insertions, 23 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index aa6208e..fe1c755 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,14 +1,20 @@
cmake_minimum_required(VERSION 3.5)
-project(libnitrokey)
-set(CMAKE_CXX_COMPILER "/usr/bin/clang++-3.8" CACHE string "clang++ compiler" FORCE)
+IF (UNIX)
+ OPTION(USE_CLANG "Use CLang" TRUE)
+ IF(USE_CLANG)
+ set(CMAKE_CXX_COMPILER "/usr/bin/clang++-3.8" CACHE string "clang++ compiler" FORCE)
+ ENDIF()
+ENDIF()
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wno-gnu-variable-sized-type-not-at-end -g3" )
-SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lhidapi-libusb" )
+project(libnitrokey CXX)
+set(CMAKE_CXX_STANDARD 14)
-include_directories(include unittest/Catch/include)
+#OPTION(COMPILE_TESTS "Compile tests" FALSE)
+OPTION(COMPILE_TESTS "Compile tests" TRUE)
+set(CMAKE_BUILD_TYPE RelWithDebInfo)
+include_directories(include)
set(SOURCE_FILES
include/command.h
include/command_id.h
@@ -22,32 +28,47 @@ set(SOURCE_FILES
include/NitrokeyManager.h
include/stick10_commands.h
include/stick20_commands.h
- NK_C_API.h
+ include/CommandFailedException.h
+ include/LibraryException.h
+ include/LongOperationInProgressException.h
+ include/stick10_commands_0.8.h
command_id.cc
device.cc
log.cc
misc.cc
NitrokeyManager.cc
- NK_C_API.cc include/CommandFailedException.h include/LibraryException.h
- include/LongOperationInProgressException.h
- include/stick10_commands_0.8.h
- )
+ NK_C_API.h
+ NK_C_API.cc
+)
+
-#add_library(libnitrokey STATIC ${SOURCE_FILES})
add_library(nitrokey SHARED ${SOURCE_FILES})
-add_library(catch STATIC unittest/catch_main.cpp )
+target_link_libraries(nitrokey hidapi-libusb)
+
+IF (COMPILE_TESTS)
+ include_directories(unittest/Catch/include)
+
+ add_library(catch SHARED unittest/catch_main.cpp )
+
+ add_executable (test_C_API unittest/test_C_API.cpp)
+ target_link_libraries (test_C_API PUBLIC nitrokey catch)
+
+ add_executable (test2 unittest/test2.cc)
+ target_link_libraries (test2 PUBLIC nitrokey catch)
-add_executable (test_C_API unittest/test_C_API.cpp)
-target_link_libraries (test_C_API PUBLIC nitrokey catch)
+ add_executable (test3 unittest/test3.cc)
+ target_link_libraries (test3 PUBLIC nitrokey catch)
-add_executable (test2 unittest/test2.cc)
-target_link_libraries (test2 PUBLIC nitrokey catch)
+ add_executable (test_HOTP unittest/test_HOTP.cc)
+ target_link_libraries (test_HOTP PUBLIC nitrokey catch)
-add_executable (test3 unittest/test3.cc)
-target_link_libraries (test3 PUBLIC nitrokey catch)
+ add_executable (test1 unittest/test.cc)
+ target_link_libraries (test1 PUBLIC nitrokey catch)
-add_executable (test_HOTP unittest/test_HOTP.cc)
-target_link_libraries (test_HOTP PUBLIC nitrokey 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()
-add_executable (test1 unittest/test.cc)
-target_link_libraries (test1 PUBLIC nitrokey catch)