Enable GCov instrumentation in Debug build mode and upload results to coveralls

This commit is contained in:
Sébastien Rombauts 2015-10-07 22:24:18 +02:00
parent fb42c64bea
commit 65309d5db8
2 changed files with 19 additions and 1 deletions

View File

@ -14,13 +14,20 @@ addons:
packages:
- cppcheck
before_install:
- pip install --user cpp-coveralls
# scripts to run before build
before_script:
- mkdir build
- cd build
- cmake -DSQLITECPP_BUILD_EXAMPLES=ON -DSQLITECPP_BUILD_TESTS=ON -DSQLITECPP_RUN_DOXYGEN=OFF ..
- cmake -DCMAKE_BUILD_TYPE=Debug -DSQLITECPP_USE_GCOV=ON -DSQLITECPP_BUILD_EXAMPLES=ON -DSQLITECPP_BUILD_TESTS=ON -DSQLITECPP_RUN_DOXYGEN=OFF ..
# build examples, and run tests (ie make & make test)
script:
- cmake --build .
- ctest --output-on-failure
# publish GCov coveralls results
after_success:
- coveralls -e build/CMakeFiles -e examples -e googletest -e sqlite3 -e tests

View File

@ -44,6 +44,15 @@ else (MSVC)
# GCC flags
#add_compile_options() is not supported with CMake 2.8.7 of Ubuntu 12.04 on Travis-CI
add_definitions(-rdynamic -fstack-protector-all -Wall -Wextra -pedantic -Wformat-security -Winit-self -Wswitch-default -Wswitch-enum -Wfloat-equal -Wshadow -Wcast-qual -Wconversion -Wlogical-op -Winline)
if (SQLITECPP_USE_GCOV AND CMAKE_COMPILER_IS_GNUCXX)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
message (STATUS "Using GCov instrumentation")
else ()
message (WARNING "GCov instrumentation works best in Debug mode")
endif ()
add_definitions (-fprofile-arcs -ftest-coverage)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
endif ()
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
# Clang flags
add_definitions(-fstack-protector-all -Wall -Wextra -pedantic -Wformat-security -Winit-self -Wswitch-default -Wswitch-enum -Wfloat-equal -Wshadow -Wcast-qual -Wconversion -Winline)
@ -218,6 +227,8 @@ if (SQLITECPP_BUILD_TESTS)
endif (NOT MSVC)
# add the subdirectory containing the CMakeLists.txt for the gtest library
# TODO: under Linux, uses libgtest-dev if found
# TODO: move to the new googletest Github repository
add_subdirectory(googletest)
include_directories("${PROJECT_SOURCE_DIR}/googletest/include")