# Options
option(WITH_TESTS "Build unit tests" OFF)
+option(WITH_TESTS_COVERAGE "Analyze test coverage using gcov (only for gcc)" OFF)
option(WITH_BOOST_ATOMIC "Use boost atomics (only for boost >= 1.54)" OFF)
find_package(Threads REQUIRED)
endif()
endif(WITH_BOOST_ATOMIC)
+if(WITH_TESTS_COVERAGE)
+ if(CMAKE_COMPILER_IS_GNUCXX)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
+ message(STATUS "Test coverage analysis: activated")
+ else()
+ message(WARNING "Compiler is not GNU gcc! Test coverage couldn't be analyzed")
+ endif()
+endif(WITH_TESTS_COVERAGE)
+
set(CDS_SHARED_LIBRARY ${PROJECT_NAME})
set(CDS_STATIC_LIBRARY ${PROJECT_NAME}-s)
if(WITH_TESTS)
enable_testing()
add_subdirectory(${CMAKE_SOURCE_DIR}/tests)
+ message(STATUS "Build tests: activated")
endif(WITH_TESTS)
### FOR PACKAGING in RPM, TGZ, DEB, NSYS...###############################################################################
After using command *cmake -L <path to the project's root directory with CMakeLists.txt>* one can see some additional variables, that can activate additional features:
- *WITH_TESTS:BOOL=OFF*: if you want to build library with unit testing support use *-DWITH_TESTS=ON* on prepare step. Be careful with this flag, because compile time will dramatically increase
+- *WITH_TESTS_COVERAGE:BOOL=OFF*: Analyze test coverage using gcov (only for gcc)
- *WITH_BOOST_ATOMIC:BOOL=OFF*: Use boost atomics (only for boost >= 1.54)
- ...