Skip to content

Commit 1efbba3

Browse files
MDEV-37791: gcov doesn't work on macOS
Clang is the default compiler on macOS and it requires the --coverage flag to enable gcov compatible output. gcov.h is not available on macOS, so don't set the -DHAVE_gcov variable.
1 parent 9f8716a commit 1efbba3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,13 @@ IF(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION
297297
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_GLIBCXX_DEBUG -D_GLIBCXX_ASSERTIONS")
298298
ENDIF()
299299

300-
OPTION(ENABLE_GCOV "Enable gcov (debug, Linux builds only)" OFF)
300+
OPTION(ENABLE_GCOV "Enable gcov (debug, macOS and Linux builds only)" OFF)
301301
IF (ENABLE_GCOV)
302-
MY_CHECK_AND_SET_COMPILER_FLAG("-DHAVE_gcov -fprofile-arcs -ftest-coverage -lgcov" DEBUG)
302+
IF (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
303+
MY_CHECK_AND_SET_COMPILER_FLAG("--coverage" DEBUG)
304+
ELSE()
305+
MY_CHECK_AND_SET_COMPILER_FLAG("-DHAVE_gcov -fprofile-arcs -ftest-coverage -lgcov" DEBUG)
306+
ENDIF()
303307
ENDIF()
304308

305309
OPTION(WITHOUT_PACKED_SORT_KEYS "disable packed sort keys" OFF)

0 commit comments

Comments
 (0)