Skip to content

Commit

Permalink
Merge pull request #72 from andrsd/cmake-code-cov
Browse files Browse the repository at this point in the history
maint: updating code coverage cmake script to work with cmake 3.31+
  • Loading branch information
andrsd authored Jan 3, 2025
2 parents b4172a0 + 6659337 commit 2276005
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions cmake/CodeCoverage.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ if(EXODUSIICPP_CODE_COVERAGE)
-o ${MERGED_PROFDATA}
)

add_custom_target(htmlcov DEPENDS ${PROJECT_BINARY_DIR}/htmlcov/index.html)
add_custom_target(htmlcov
DEPENDS ${PROJECT_BINARY_DIR}/htmlcov/index.html
COMMENT "Open ${PROJECT_BINARY_DIR}/htmlcov/index.html in your browser to view the coverage report."
)
add_custom_command(
OUTPUT
${PROJECT_BINARY_DIR}/htmlcov/index.html
Expand All @@ -94,14 +97,6 @@ if(EXODUSIICPP_CODE_COVERAGE)
${COVERAGE_INFO}
)

add_custom_command(
TARGET htmlcov
POST_BUILD
COMMAND ;
COMMENT
"Open ${PROJECT_BINARY_DIR}/htmlcov/index.html in your browser to view the coverage report."
)

function(target_code_coverage TARGET_NAME)
target_compile_options(${TARGET_NAME} PUBLIC -fprofile-instr-generate -fcoverage-mapping)
target_link_options(${TARGET_NAME} PUBLIC -fprofile-instr-generate -fcoverage-mapping)
Expand Down Expand Up @@ -139,7 +134,10 @@ if(EXODUSIICPP_CODE_COVERAGE)
${EXCLUDE_REGEX}
)

add_custom_target(htmlcov DEPENDS ${PROJECT_BINARY_DIR}/htmlcov/index.html)
add_custom_target(htmlcov
DEPENDS ${PROJECT_BINARY_DIR}/htmlcov/index.html
COMMENT "Open ${PROJECT_BINARY_DIR}/htmlcov/index.html in your browser to view the coverage report."
)
add_custom_command(
OUTPUT
${PROJECT_BINARY_DIR}/htmlcov/index.html
Expand All @@ -151,14 +149,6 @@ if(EXODUSIICPP_CODE_COVERAGE)
${COVERAGE_INFO}
)

add_custom_command(
TARGET htmlcov
POST_BUILD
COMMAND ;
COMMENT
"Open ${PROJECT_BINARY_DIR}/htmlcov/index.html in your browser to view the coverage report."
)

function(target_code_coverage TARGET_NAME)
target_compile_options(${TARGET_NAME} PUBLIC -fprofile-arcs -ftest-coverage)
target_link_options(${TARGET_NAME} PUBLIC -fprofile-arcs -ftest-coverage)
Expand Down

0 comments on commit 2276005

Please sign in to comment.