summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2019-06-15 18:51:40 +0100
committerEdward Thomson <ethomson@edwardthomson.com>2019-06-24 17:27:22 +0100
commitcc9e47c995fc9bb5526f8e83a27c5f2af6a6f6d9 (patch)
treef7685dcc4bb9b0fee4bbda614ffb4de5dccc6e8b
parentf6530438f476220547ad46fcc1bfcc0f796f7733 (diff)
downloadlibgit2-cc9e47c995fc9bb5526f8e83a27c5f2af6a6f6d9.tar.gz
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.
-rw-r--r--cmake/Modules/EnableWarnings.cmake6
-rw-r--r--src/CMakeLists.txt8
2 files changed, 13 insertions, 1 deletions
diff --git a/cmake/Modules/EnableWarnings.cmake b/cmake/Modules/EnableWarnings.cmake
index 72e1523c4..b61ed7e90 100644
--- a/cmake/Modules/EnableWarnings.cmake
+++ b/cmake/Modules/EnableWarnings.cmake
@@ -7,5 +7,9 @@ MACRO(DISABLE_WARNINGS flag)
ENDMACRO()
IF(ENABLE_WERROR)
- ADD_C_FLAG_IF_SUPPORTED(-Werror)
+ IF(MSVC)
+ ADD_COMPILE_OPTIONS(-WX)
+ ELSE()
+ ADD_C_FLAG_IF_SUPPORTED(-Werror)
+ ENDIF()
ENDIF()
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 7ab183210..750085b5e 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -314,12 +314,20 @@ ELSE()
ENDIF()
FILE(GLOB SRC_OS unix/*.c unix/*.h)
ENDIF()
+
FILE(GLOB SRC_GIT2 *.c *.h
allocators/*.c allocators/*.h
streams/*.c streams/*.h
transports/*.c transports/*.h
xdiff/*.c xdiff/*.h)
+# the xdiff dependency is not (yet) warning-free, disable warnings as
+# errors for the xdiff sources until we've sorted them out
+IF(MSVC)
+ SET_SOURCE_FILES_PROPERTIES(xdiff/xdiffi.c PROPERTIES COMPILE_FLAGS -WX-)
+ SET_SOURCE_FILES_PROPERTIES(xdiff/xutils.c PROPERTIES COMPILE_FLAGS -WX-)
+ENDIF()
+
# Determine architecture of the machine
IF (CMAKE_SIZEOF_VOID_P EQUAL 8)
SET(GIT_ARCH_64 1)