Skip to content

Commit

Permalink
Merge pull request #31 from andrsd/cmake-update
Browse files Browse the repository at this point in the history
Updating cmake scripts for cmake 3.31+
  • Loading branch information
andrsd authored Jan 2, 2025
2 parents 650a9a4 + 3bed1a3 commit 1c0ea78
Showing 1 changed file with 10 additions and 28 deletions.
38 changes: 10 additions & 28 deletions cmake/CodeCoverage.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,8 @@ if(GMSH2EXO_CODE_COVERAGE)
set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_CLEAN_FILES "${COVERAGE_INFO}")

if(CMAKE_C_COMPILER_ID MATCHES "(Apple)?[Cc]lang" OR CMAKE_CXX_COMPILER_ID MATCHES "(Apple)?[Cc]lang")
find_program(
LLVM_COV_PATH
NAMES
llvm-cov
)
find_program(
LLVM_PROFDATA_PATH
NAMES
llvm-profdata
)
find_program(LLVM_COV_PATH NAMES llvm-cov)
find_program(LLVM_PROFDATA_PATH NAMES llvm-profdata )
mark_as_advanced(FORCE
LLVM_COV_PATH
LLVM_PROFDATA_PATH
Expand Down Expand Up @@ -76,7 +68,10 @@ if(GMSH2EXO_CODE_COVERAGE)
${CODE_COVERAGE_PROFRAWS}
)

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 @@ -93,14 +88,6 @@ if(GMSH2EXO_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 @@ -142,7 +129,10 @@ if(GMSH2EXO_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 @@ -154,14 +144,6 @@ if(GMSH2EXO_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 1c0ea78

Please sign in to comment.