From 46e8303872d7bff61b519eee43a9a026529acfac Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Fri, 31 Mar 2017 15:48:12 +0200 Subject: Do not fail compilation on tests Signed-off-by: Szczepan Zalega --- CMakeLists.txt | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index e07a5fd..7c379da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,13 +75,6 @@ ELSEIF(WIN32) target_link_libraries(hidapi-libusb setupapi) ENDIF() -OPTION(ERROR_ON_WARNING "Stop compilation on warning found (not supported for MSVC)" ON) -if (NOT MSVC) - add_compile_options(-Wall -Wno-unused-function -Wcast-qual -Woverloaded-virtual) - if (ERROR_ON_WARNING) - add_compile_options(-Werror) - endif() -endif() IF (NOT LIBNITROKEY_STATIC) add_library(nitrokey SHARED ${SOURCE_FILES}) @@ -98,6 +91,15 @@ ENDIF() target_link_libraries(${LIBNAME} hidapi-libusb) target_link_libraries(${LIBNAME}-log hidapi-libusb) +OPTION(ERROR_ON_WARNING "Stop compilation on warning found (not supported for MSVC)" ON) +if (NOT MSVC) + set(COMPILE_FLAGS "-Wall -Wno-unused-function -Wcast-qual -Woverloaded-virtual") + if (ERROR_ON_WARNING) + set(COMPILE_FLAGS "${COMPILE_FLAGS} -Werror") + endif() + SET_TARGET_PROPERTIES(${LIBNAME} ${LIBNAME}-log PROPERTIES COMPILE_FLAGS ${COMPILE_FLAGS} ) +endif() + SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES COMPILE_DEFINITIONS "NO_LOG") @@ -108,7 +110,7 @@ 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 ${EXTRA_LIBS} ${LIBNAME} catch) -- cgit v1.2.1