One more fix for #18790
authorpeter <peterghost86@gmail.com>
Fri, 12 Apr 2019 16:25:55 +0000 (09:25 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Fri, 12 Apr 2019 16:29:15 +0000 (09:29 -0700)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/19187

Differential Revision: D14913100

Pulled By: ezyang

fbshipit-source-id: bf147747f933a2c9a35f3ff00bf6b83a4f29286c

cmake/ProtoBuf.cmake

index e3870ac..dbf101e 100644 (file)
@@ -39,13 +39,15 @@ macro(custom_protobuf_find)
   set(CMAKE_POSITION_INDEPENDENT_CODE ON)
 
   if (MSVC)
-    foreach(flag_var
-        CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
-        CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
-      if(${flag_var} MATCHES "/Z[iI]")
-        string(REGEX REPLACE "/Z[iI]" "/Z7" ${flag_var} "${${flag_var}}")
-      endif(${flag_var} MATCHES "/Z[iI]")
-    endforeach(flag_var)
+    if(MSVC_Z7_OVERRIDE)
+      foreach(flag_var
+          CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
+          CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
+        if(${flag_var} MATCHES "/Z[iI]")
+          string(REGEX REPLACE "/Z[iI]" "/Z7" ${flag_var} "${${flag_var}}")
+        endif(${flag_var} MATCHES "/Z[iI]")
+      endforeach(flag_var)
+    endif(MSVC_Z7_OVERRIDE)
   endif(MSVC)
 
   add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../third_party/protobuf/cmake)