CTest/Coverage/Example: Difference between revisions
From KitwarePublic
Jump to navigationJump to search
Daviddoria (talk | contribs) No edit summary |
Daviddoria (talk | contribs) |
||
Line 21: | Line 21: | ||
ENABLE_TESTING() | ENABLE_TESTING() | ||
SET(CMAKE_CXX_FLAGS " | SET(CMAKE_CXX_FLAGS="-g -O0 -Wall -W -Wshadow -Wunused-variable -Wunused-parameter -Wunused-function -Wunused -Wno-system-headers -Wno-deprecated -Woverloaded-virtual -Wwrite-strings -fprofile-arcs -ftest-coverage") | ||
SET( | SET(CMAKE_C_FLAGS="-g -O0 -Wall -W -fprofile-arcs -ftest-coverage") | ||
SET( | |||
SET( | #SET(CMAKE_SHARED_LINKER_FLAGS="-fprofile-arcs -ftest-coverage") | ||
SET(CMAKE_EXE_LINKER_FLAGS="-fprofile-arcs -ftest-coverage") | |||
add_executable(Coverage coverage.cpp) | add_executable(Coverage coverage.cpp) | ||
target_link_libraries(Coverage gcov) | |||
add_test(NAME Coverage COMMAND Coverage) | |||
</source> | </source> |
Revision as of 15:12, 3 January 2012
coverage.cpp
<source lang="cpp">
- include <iostream>
int main (int, char *[]) {
std::cout << "Sample text." << std::endl;
return 0;
}
</source>
CMakeLists.txt
<source lang="cmake"> cmake_minimum_required(VERSION 2.6)
project(Coverage) ENABLE_TESTING()
SET(CMAKE_CXX_FLAGS="-g -O0 -Wall -W -Wshadow -Wunused-variable -Wunused-parameter -Wunused-function -Wunused -Wno-system-headers -Wno-deprecated -Woverloaded-virtual -Wwrite-strings -fprofile-arcs -ftest-coverage")
SET(CMAKE_C_FLAGS="-g -O0 -Wall -W -fprofile-arcs -ftest-coverage")
- SET(CMAKE_SHARED_LINKER_FLAGS="-fprofile-arcs -ftest-coverage")
SET(CMAKE_EXE_LINKER_FLAGS="-fprofile-arcs -ftest-coverage")
add_executable(Coverage coverage.cpp) target_link_libraries(Coverage gcov)
add_test(NAME Coverage COMMAND Coverage) </source>