aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt60
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()