aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2017-02-06 11:29:02 +0100
committerSzczepan Zalega <szczepan@nitrokey.com>2017-03-11 15:41:43 +0100
commit473f1bf1854305c6ab5e926f369d07a37e081f3c (patch)
treef66759b36b9dd95a207a43d57d42d762f33a4e0e /CMakeLists.txt
parent2d518b08787575914160ea0b1057c26d1d05b764 (diff)
downloadlibnitrokey-473f1bf1854305c6ab5e926f369d07a37e081f3c.tar.gz
libnitrokey-473f1bf1854305c6ab5e926f369d07a37e081f3c.tar.bz2
Support ASAN and Clang optionally
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt25
1 files changed, 17 insertions, 8 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fe1c755..21fe7ab 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,19 +1,28 @@
cmake_minimum_required(VERSION 3.5)
IF (UNIX)
- OPTION(USE_CLANG "Use CLang" TRUE)
+ OPTION(ADD_ASAN "Use ASAN to show memory issues" FALSE)
+ OPTION(USE_CLANG "Use CLang" FALSE)
IF(USE_CLANG)
set(CMAKE_CXX_COMPILER "/usr/bin/clang++-3.8" CACHE string "clang++ compiler" FORCE)
+ ELSE()
+ set(CMAKE_CXX_COMPILER)
+ ENDIF()
+ IF(ADD_ASAN)
+ SET(EXTRA_LIBS ${EXTRA_LIBS} asan )
+ ADD_DEFINITIONS(-fsanitize=address -fno-omit-frame-pointer)
+ # ADD_DEFINITIONS(-fsanitize=thread -fno-omit-frame-pointer -fPIE -pie -g)
ENDIF()
ENDIF()
project(libnitrokey CXX)
set(CMAKE_CXX_STANDARD 14)
-#OPTION(COMPILE_TESTS "Compile tests" FALSE)
-OPTION(COMPILE_TESTS "Compile tests" TRUE)
+OPTION(COMPILE_TESTS "Compile tests" FALSE)
set(CMAKE_BUILD_TYPE RelWithDebInfo)
+MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
+
include_directories(include)
set(SOURCE_FILES
include/command.h
@@ -51,19 +60,19 @@ IF (COMPILE_TESTS)
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)
+ target_link_libraries (test_C_API ${EXTRA_LIBS} nitrokey catch)
add_executable (test2 unittest/test2.cc)
- target_link_libraries (test2 PUBLIC nitrokey catch)
+ target_link_libraries (test2 ${EXTRA_LIBS} nitrokey catch)
add_executable (test3 unittest/test3.cc)
- target_link_libraries (test3 PUBLIC nitrokey catch)
+ target_link_libraries (test3 ${EXTRA_LIBS} nitrokey catch)
add_executable (test_HOTP unittest/test_HOTP.cc)
- target_link_libraries (test_HOTP PUBLIC nitrokey catch)
+ target_link_libraries (test_HOTP ${EXTRA_LIBS} nitrokey catch)
add_executable (test1 unittest/test.cc)
- target_link_libraries (test1 PUBLIC nitrokey catch)
+ target_link_libraries (test1 ${EXTRA_LIBS} nitrokey catch)
#run with 'make test' or 'ctest'
#needs connected PRO device for success