Skip useless macros from Windows.h (#25444)
Summary:
Applying https://github.com/pytorch/pytorch/issues/25398 to the whole project.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/25444
Differential Revision: D17131251
Pulled By: ezyang
fbshipit-source-id: 7a8817f3444aebd6028bf1056514355e2c4cc748
diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake
index 21e27c8..56c400f 100644
--- a/cmake/Dependencies.cmake
+++ b/cmake/Dependencies.cmake
@@ -1117,6 +1117,8 @@
IF (MSVC)
# we want to respect the standard, and we are bored of those **** .
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE=1)
+ # skip unwanted includes from windows.h
+ ADD_DEFINITIONS(-DWIN32_LEAN_AND_MEAN)
LIST(APPEND CUDA_NVCC_FLAGS "-Xcompiler /wd4819 -Xcompiler /wd4503 -Xcompiler /wd4190 -Xcompiler /wd4244 -Xcompiler /wd4251 -Xcompiler /wd4275 -Xcompiler /wd4522")
ENDIF()
diff --git a/cmake/MiscCheck.cmake b/cmake/MiscCheck.cmake
index 2b52f9d..1abdfed 100644
--- a/cmake/MiscCheck.cmake
+++ b/cmake/MiscCheck.cmake
@@ -306,6 +306,9 @@
# dllexport in cc file. The strategy is copied from gflags.
)
+ # Make sure windows.h does not include additional headers.
+ add_definitions("/DWIN32_LEAN_AND_MEAN")
+
# Make sure windef.h does not define max/min macros.
# Required by ATen among others.
add_definitions("/DNOMINMAX")