Skip to content

Commit cc9e47c

Browse files
committed
win32: support upgrading warnings to errors (/WX)
For MSVC, support warnings as errors by providing the /WX compiler flags. (/WX is the moral equivalent of -Werror.) Disable warnings as errors ass part of xdiff, since it contains warnings. But as a component of git itself, we want to avoid skew and keep our implementation as similar as possible to theirs. We'll work with upstream to fix these issues, but in the meantime, simply let those continue to warn.
1 parent f653043 commit cc9e47c

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

cmake/Modules/EnableWarnings.cmake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,9 @@ MACRO(DISABLE_WARNINGS flag)
77
ENDMACRO()
88

99
IF(ENABLE_WERROR)
10-
ADD_C_FLAG_IF_SUPPORTED(-Werror)
10+
IF(MSVC)
11+
ADD_COMPILE_OPTIONS(-WX)
12+
ELSE()
13+
ADD_C_FLAG_IF_SUPPORTED(-Werror)
14+
ENDIF()
1115
ENDIF()

src/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,12 +314,20 @@ ELSE()
314314
ENDIF()
315315
FILE(GLOB SRC_OS unix/*.c unix/*.h)
316316
ENDIF()
317+
317318
FILE(GLOB SRC_GIT2 *.c *.h
318319
allocators/*.c allocators/*.h
319320
streams/*.c streams/*.h
320321
transports/*.c transports/*.h
321322
xdiff/*.c xdiff/*.h)
322323

324+
# the xdiff dependency is not (yet) warning-free, disable warnings as
325+
# errors for the xdiff sources until we've sorted them out
326+
IF(MSVC)
327+
SET_SOURCE_FILES_PROPERTIES(xdiff/xdiffi.c PROPERTIES COMPILE_FLAGS -WX-)
328+
SET_SOURCE_FILES_PROPERTIES(xdiff/xutils.c PROPERTIES COMPILE_FLAGS -WX-)
329+
ENDIF()
330+
323331
# Determine architecture of the machine
324332
IF (CMAKE_SIZEOF_VOID_P EQUAL 8)
325333
SET(GIT_ARCH_64 1)

0 commit comments

Comments
 (0)