diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2015-04-01 12:17:06 +0200 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2015-04-01 12:17:06 +0200 |
commit | 45aec80e05130cb76fce94290e6a3d4091049114 (patch) | |
tree | 9e337e1d7dea19089b227d939dae813d5af429a7 | |
parent | 2d3b060abd28c08895a5fa0ea21d3547133e28f3 (diff) | |
download | usdx-45aec80e05130cb76fce94290e6a3d4091049114.tar.gz usdx-45aec80e05130cb76fce94290e6a3d4091049114.tar.xz usdx-45aec80e05130cb76fce94290e6a3d4091049114.zip |
CMakeList: Add usdx-coverage.
The new usdx-coverage target builds the usdx binary with coverage
information. The object files are reused when building the tests with
coverage infromation. This way we could build the binary and speed up
the build on the build server.
-rw-r--r-- | CMakeLists.txt | 60 |
1 files changed, 36 insertions, 24 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 14cd5646..b59daa5b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,7 @@ project (usdx-cpp) set(cflags "-Wall -Werror -pedantic") set(cxxflags "${cflags} -std=c++1y") set(debug "-g -O0") +set(coverage "-coverage") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${cflags}") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${debug}") @@ -69,31 +70,42 @@ if(BUILD_TESTING) endif() # -# tests with coverage +# usdx binary with coverage information # -set(coverage-dir "${PROJECT_BINARY_DIR}/coverage") - -add_executable(usdx-test-coverage EXCLUDE_FROM_ALL - ${testing_sources} ${sources}) -target_link_libraries(usdx-test-coverage ${LIBS} ${TEST_LIBS} "-coverage") -set_target_properties(usdx-test-coverage +add_library(objects-coverage EXCLUDE_FROM_ALL + OBJECT ${sources}) +set_target_properties(objects-coverage PROPERTIES COMPILE_FLAGS "${debug} -fprofile-arcs -ftest-coverage") -add_custom_target(test-coverage WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/test/" - # prepare coverage checks - COMMAND rm -f .error - COMMAND mkdir -p "${coverage-dir}" - COMMAND lcov --directory "${PROJECT_SOURCE_DIR}" --zerocounters - - # running checks and save result for later use - COMMAND sh -c \"$<TARGET_FILE:usdx-test-coverage> || touch .error\" +add_executable(usdx-coverage EXCLUDE_FROM_ALL + "src/main.cpp" $<TARGET_OBJECTS:objects-coverage>) +target_link_libraries(usdx-coverage ${LIBS} ${coverage}) - # building coverage pages - COMMAND lcov --directory "${PROJECT_SOURCE_DIR}" --capture --output-file "${coverage-dir}/coverage.info.tmp" - COMMAND lcov --extract "${coverage-dir}/coverage.info.tmp" "'${PROJECT_SOURCE_DIR}/src/*'" -o "${coverage-dir}/coverage.info" - COMMAND genhtml "${coverage-dir}/coverage.info" -o "${coverage-dir}/html/" -p "${PROJECT_SOURCE_DIR}/src" - - # returing check status - COMMAND test ! -e .error -) -add_dependencies(test-coverage test/usdx-test-coverage) +# +# tests with coverage +# +if(BUILD_TESTING) + add_executable(usdx-test-coverage EXCLUDE_FROM_ALL + ${testing_sources} $<TARGET_OBJECTS:objects-coverage>) + target_link_libraries(usdx-test-coverage ${LIBS} ${TEST_LIBS} ${coverage}) + + set(coverage-dir "${PROJECT_BINARY_DIR}/coverage") + add_custom_target(test-coverage WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/test/" + # prepare coverage checks + COMMAND rm -f .error + COMMAND mkdir -p "${coverage-dir}" + COMMAND lcov --directory "${PROJECT_SOURCE_DIR}" --zerocounters + + # running checks and save result for later use + COMMAND sh -c \"$<TARGET_FILE:usdx-test-coverage> || touch .error\" + + # building coverage pages + COMMAND lcov --directory "${PROJECT_SOURCE_DIR}" --capture --output-file "${coverage-dir}/coverage.info.tmp" + COMMAND lcov --extract "${coverage-dir}/coverage.info.tmp" "'${PROJECT_SOURCE_DIR}/src/*'" -o "${coverage-dir}/coverage.info" + COMMAND genhtml "${coverage-dir}/coverage.info" -o "${coverage-dir}/html/" -p "${PROJECT_SOURCE_DIR}/src" + + # returing check status + COMMAND test ! -e .error + ) + add_dependencies(test-coverage usdx-test-coverage) +endif() |