summaryrefslogtreecommitdiffstats
path: root/cmake/open-cpp-coverage.cmake.example
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 20:01:36 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 20:01:36 +0000
commit62e4c68907d8d33709c2c1f92a161dff00b3d5f2 (patch)
treeadbbaf3acf88ea08f6eeec4b75ee98ad3b07fbdc /cmake/open-cpp-coverage.cmake.example
parentInitial commit. (diff)
downloadlnav-62e4c68907d8d33709c2c1f92a161dff00b3d5f2.tar.xz
lnav-62e4c68907d8d33709c2c1f92a161dff00b3d5f2.zip
Adding upstream version 0.11.2.upstream/0.11.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'cmake/open-cpp-coverage.cmake.example')
-rw-r--r--cmake/open-cpp-coverage.cmake.example31
1 files changed, 31 insertions, 0 deletions
diff --git a/cmake/open-cpp-coverage.cmake.example b/cmake/open-cpp-coverage.cmake.example
new file mode 100644
index 0000000..b00f086
--- /dev/null
+++ b/cmake/open-cpp-coverage.cmake.example
@@ -0,0 +1,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
+)