From 473f1bf1854305c6ab5e926f369d07a37e081f3c Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Mon, 6 Feb 2017 11:29:02 +0100 Subject: Support ASAN and Clang optionally Signed-off-by: Szczepan Zalega --- CMakeLists.txt | 25 +++++++++++++++++-------- 1 file 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 -- cgit v1.2.3