Skip to content

Commit

Permalink
Compile with coverage on Debug-config.
Browse files Browse the repository at this point in the history
  • Loading branch information
bilke committed Jun 10, 2024
1 parent 7e0cf5e commit 7f41a86
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,28 @@ if(NOT VTK_FOUND)
endif()
# --- CPM end ---

# Coverage (enabled by Debug-config)
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug" AND ${PROJECT_SOURCE_DIR} STREQUAL
${CMAKE_SOURCE_DIR}
)
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
set(CMAKE_CXX_FLAGS_DEBUG "-g -Og --coverage")
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
string(APPEND CMAKE_CXX_FLAGS_DEBUG " -fprofile-abs-path")
endif()
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "--coverage")
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "--coverage")
set(CMAKE_MODULE_LINKER_FLAGS_DEBUG "--coverage")
message(STATUS "Setting coverage flags!")
message(
STATUS
"Run executables and the run:\n gcovr -r ${PROJECT_SOURCE_DIR}"
)
else()
message(FATAL_ERROR "OGS_COVERAGE requires clang or gcc compiler!")
endif()
endif()

add_executable(vtkdiff vtkdiff.cpp)
target_link_libraries(vtkdiff tclap VTK::IOXML)

Expand Down

0 comments on commit 7f41a86

Please sign in to comment.