File: open-cpp-coverage.cmake.example

package info (click to toggle)
lnav 0.13.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 60,084 kB
  • sloc: cpp: 215,599; ansic: 59,220; sh: 4,650; makefile: 3,578; python: 1,197; sql: 315; xml: 264; javascript: 18
file content (31 lines) | stat: -rw-r--r-- 1,170 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Example file to run OpenCppCoverage on Windows

include(ProcessorCount)
ProcessorCount(N)

file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/opencppcoverage")

# Convert delimiters to Windows ones
string(REPLACE "/" "\\" binary_dir "${PROJECT_BINARY_DIR}")
string(REPLACE "/" "\\" source_dir "${PROJECT_SOURCE_DIR}")
string(REPLACE "/" "\\" ctest "${CMAKE_CTEST_COMMAND}")

add_custom_target(
    win-cov
    COMMAND OpenCppCoverage -q
    # We want coverage from the child processes of CTest
    --cover_children
    # Subdirectory where the tests reside in the binary directory
    --modules "${binary_dir}\\test"
    # This command is for the developer, so export as html instead of cobertura
    --export_type "html:${binary_dir}\\opencppcoverage"
    # Source (not header) file locations
    --sources "${source_dir}\\source"
    --sources "${source_dir}\\test\\source"
    # Working directory for CTest, which should be the binary directory
    --working_dir "${binary_dir}"
    # OpenCppCoverage should be run only with the Debug configuration tests
    -- "${ctest}" -C Debug --output-on-failure -j "${N}"
    WORKING_DIRECTORY "${PROJECT_BINARY_DIR}"
    VERBATIM
)