Skip to content

Commit 559a57b

Browse files
committed
Disable gcov for MSVC
1 parent 9302507 commit 559a57b

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

test/CMakeLists.txt

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
# Do not edit lines below
33

44
# GCOV settings
5-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
6-
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
5+
if(NOT MSVC)
6+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
7+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
8+
endif()
79

810
# List up all source files including main.cpp
911
set(MAIN_FILE_PATTERN ".*/main.cpp$")
@@ -19,13 +21,15 @@ set(TEST_EXECUTABLE_NAME test_${PROJECT_NAME})
1921
# Add the executable for the testcase which is using googletest
2022
add_executable(${TEST_EXECUTABLE_NAME} ${TEST_SRC} ${LIB_SRC})
2123

22-
# Delete the gcov data file before linking. Otherwise, we will get many errors.
23-
add_custom_command(
24-
TARGET ${TEST_EXECUTABLE_NAME} PRE_LINK
25-
COMMAND find . -name "*.gcda" -delete
26-
COMMENT "Deleting *.gcda files under ${CMAKE_BINARY_DIR}"
27-
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
28-
VERBATIM)
24+
if(NOT MSVC)
25+
# Delete the gcov data file before linking. Otherwise, we will get many errors.
26+
add_custom_command(
27+
TARGET ${TEST_EXECUTABLE_NAME} PRE_LINK
28+
COMMAND find . -name "*.gcda" -delete
29+
COMMENT "Deleting *.gcda files under ${CMAKE_BINARY_DIR}"
30+
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
31+
VERBATIM)
32+
endif()
2933

3034
# Add the library under test.
3135
target_link_libraries(${TEST_EXECUTABLE_NAME}

0 commit comments

Comments
 (0)