Skip to content

Commit c011d15

Browse files
committed
Add gcov support
This commit introduces the option to enable gcov support in the build system. The USE_GCOV option has been added to allow gcov instrumentation.
1 parent 0660c56 commit c011d15

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ option(USE_UBSAN "Enable UndefinedBehaviorSanitizer checks" OFF)
5151
option(USE_TSAN "Enable ThreadSanitizer checks" OFF)
5252
option(USE_MSAN "Enable MemorySanitizer checks" OFF)
5353
option(USE_VALGRIND "Enable Valgrind instrumentation" OFF)
54+
option(USE_GCOV "Enable gcov support" OFF)
5455

5556
# set UMF_PROXY_LIB_BASED_ON_POOL to one of: SCALABLE or JEMALLOC
5657
set(KNOWN_PROXY_LIB_POOLS SCALABLE JEMALLOC)

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ List of options provided by CMake:
123123
| USE_TSAN | Enable ThreadSanitizer checks | ON/OFF | OFF |
124124
| USE_MSAN | Enable MemorySanitizer checks | ON/OFF | OFF |
125125
| USE_VALGRIND | Enable Valgrind instrumentation | ON/OFF | OFF |
126+
| USE_GCOV | Enable gcov support (Linux only) | ON/OFF | OFF |
126127

127128
## Architecture: memory pools and providers
128129

cmake/helpers.cmake

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ function(add_umf_target_compile_options name)
104104
${name} PRIVATE -Werror -fno-omit-frame-pointer
105105
-fstack-protector-strong)
106106
endif()
107+
if(USE_GCOV)
108+
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
109+
message(FATAL_ERROR "To use gcov, the build type must be Debug")
110+
endif()
111+
target_compile_options(${name} PRIVATE --coverage)
112+
endif()
107113
elseif(MSVC)
108114
target_compile_options(
109115
${name}
@@ -121,6 +127,13 @@ function(add_umf_target_link_options name)
121127
if(NOT MSVC)
122128
if(NOT APPLE)
123129
target_link_options(${name} PRIVATE "LINKER:-z,relro,-z,now")
130+
if(USE_GCOV)
131+
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
132+
message(
133+
FATAL_ERROR "To use gcov, the build type must be Debug")
134+
endif()
135+
target_link_libraries(${name} PRIVATE --coverage)
136+
endif()
124137
endif()
125138
elseif(MSVC)
126139
target_link_options(

0 commit comments

Comments
 (0)