-
Notifications
You must be signed in to change notification settings - Fork 0
Add CMake configurations for code coverage and analysis tools #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
f6ee280
Add CMake configurations for code coverage and analysis tools
royratcliffe 2c0f83c
Fix spelling of "normalize" to "normalise" in documentation
royratcliffe a2a1fe9
Refactor region handling functions to use 'move' terminology
royratcliffe 880575e
Add notes on 'lcov' target availability in settings
royratcliffe 962a6c3
Append to CMAKE_MODULE_PATH for module inclusion
royratcliffe dc14015
Refactor raster operation functions to return operation count
royratcliffe ef38e3f
Refactor blit_rop2 function parameters for improved readability
royratcliffe b4bf8e3
Refactor function signatures for improved readability
royratcliffe fc49ebe
Fix Doxygen main page reference to use full path for README.md
royratcliffe 81d9116
Refactor cppcheck command for Debug configuration
royratcliffe a79bdd7
Enable code coverage for all configurations with lcov
royratcliffe 80ef0f3
Enable code coverage for Debug configuration
royratcliffe 22b2f32
Add extra_scan_count test to validate scanline behaviour
royratcliffe 6a0cbd5
Add gdb launch configuration to launch.json
royratcliffe 4fd7652
Enable compile_commands.json generation for analysis tools
royratcliffe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| { | ||
| "cmake.coverageInfoFiles": [ | ||
| "${workspaceFolder}/build/coverage_filtered.info" | ||
| ], | ||
| // NOTE: The 'lcov' target is only defined when lcov is installed and the build type is Debug. | ||
| // In other configurations, "Run with coverage" may fail if this target is not available. | ||
| "cmake.postRunCoverageTarget": "lcov", | ||
| "testing.coverageToolbarEnabled": true, | ||
| "testing.defaultGutterClickAction": "runWithCoverage" | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # Add custom commands for code analysis. Enable cppcheck for Debug build type. | ||
| # This will run cppcheck only when building the Debug configuration, using configuration-aware logic. | ||
| find_program(CPPCHECK cppcheck) | ||
| if(CPPCHECK) | ||
| add_custom_target(cppcheck | ||
| COMMAND $<$<CONFIG:Debug>:${CPPCHECK}> | ||
| $<$<CONFIG:Debug>:--project=${CMAKE_BINARY_DIR}/compile_commands.json> | ||
| $<$<CONFIG:Debug>:--output-file=${CMAKE_BINARY_DIR}/cppcheck_report.xml> | ||
| $<$<CONFIG:Debug>:--xml> | ||
| $<$<CONFIG:Debug>:--enable=all> | ||
| $<$<CONFIG:Debug>:--enable=warning,style,performance,portability,information> | ||
| $<$<CONFIG:Debug>:--suppressions-list=${CMAKE_SOURCE_DIR}/cppcheck_suppressions.txt> | ||
| WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} | ||
| COMMENT "Running cppcheck for code analysis (Debug configuration only)" | ||
| # Use VERBATIM to ensure the command is executed as written. | ||
| # This is useful for handling paths with spaces or special characters. | ||
| VERBATIM | ||
| ) | ||
| set_property(TARGET cppcheck PROPERTY FOLDER "Analysis") | ||
|
royratcliffe marked this conversation as resolved.
|
||
| else() | ||
| message(STATUS "Cppcheck not found; code analysis target will not be created") | ||
| endif() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # https://cmake.org/cmake/help/latest/module/FindDoxygen.html | ||
| # https://www.mcternan.me.uk/mscgen/ | ||
| find_package(Doxygen OPTIONAL_COMPONENTS dot mscgen dia) | ||
| if(DOXYGEN_FOUND) | ||
| set(DOXYGEN_USE_MDFILE_AS_MAINPAGE ${CMAKE_SOURCE_DIR}/README.md) | ||
| set(DOXYGEN_USE_MATHJAX YES) | ||
| set(DOXYGEN_OPTIMIZE_OUTPUT_FOR_C YES) | ||
| set(DOXYGEN_SOURCE_BROWSER YES) | ||
| set(DOXYGEN_EXCLUDE ${CMAKE_BINARY_DIR}) | ||
| doxygen_add_docs(doxy ${CMAKE_SOURCE_DIR} | ||
| COMMENT "Generating API documentation with Doxygen" | ||
| ) | ||
| endif() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| # Add custom commands for code coverage analysis. Enable lcov and genhtml if | ||
| # they are found. Only enable code coverage analysis for Debug build type, as it | ||
| # is typically used for development and testing. Code coverage analysis can add | ||
| # overhead to the build and runtime, so it is generally not recommended for | ||
| # Release builds. | ||
| # | ||
| # If lcov is found, add the coverage compiler and linker flags to enable code | ||
| # coverage analysis. | ||
| # | ||
| # Note that find_program will return the path to the executable if found, or | ||
| # NOTFOUND if not found. It will also cache the result, so subsequent calls will | ||
| # return the cached value. This allows us to check if lcov is available and | ||
| # conditionally add code coverage targets. | ||
| find_program(LCOV lcov) | ||
| if(LCOV) | ||
| # Add custom targets for code coverage analysis using lcov and genhtml. | ||
| # These targets will run the tests, capture coverage data, and generate an HTML report. | ||
| add_custom_target(ctest | ||
| WORKING_DIRECTORY ${CMAKE_BINARY_DIR} | ||
| COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure | ||
| DEPENDS test_runner | ||
| ) | ||
| add_custom_target(lcov | ||
| COMMAND ${LCOV} --capture --directory . --output-file coverage.info | ||
| COMMAND ${LCOV} --remove coverage.info '/usr/*' '*/test*' --output-file coverage_filtered.info | ||
|
royratcliffe marked this conversation as resolved.
|
||
| DEPENDS ctest | ||
| ) | ||
| set_property(TARGET lcov PROPERTY FOLDER "Analysis") | ||
|
|
||
| # If genhtml is found, add a custom target to generate an HTML report from the | ||
| # filtered coverage data. This will create a coverage_report directory with an | ||
| # index.html file that can be opened in a web browser to view the coverage report. | ||
| find_program(GENHTML genhtml) | ||
| if(GENHTML) | ||
| message(STATUS "lcov and genhtml found, code coverage targets will be available") | ||
| add_custom_target(genhtml | ||
| WORKING_DIRECTORY ${CMAKE_BINARY_DIR} | ||
| COMMAND ${GENHTML} coverage_filtered.info --output-directory coverage_report | ||
| COMMAND ${CMAKE_COMMAND} -E echo "Coverage report generated in: ${CMAKE_BINARY_DIR}/coverage_report/index.html" | ||
| DEPENDS lcov | ||
| ) | ||
| set_property(TARGET genhtml PROPERTY FOLDER "Analysis") | ||
| else() | ||
| message(STATUS "genhtml not found, HTML code coverage report target will not be available") | ||
| endif() | ||
| endif() | ||
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.