Omit default /W3 flag on MSVC, then set it for our targets.
This will let us set different warning flags for third party libraries (like /W0 to ignore warnings).
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9e29487..742f551 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -13,6 +13,11 @@
# limitations under the License.
cmake_minimum_required(VERSION 3.13.4)
+# Do not set MSVC warning flags like /W3 by default (since 3.15):
+# https://cmake.org/cmake/help/v3.15/policy/CMP0092.html
+if(POLICY CMP0092)
+ cmake_policy(SET CMP0092 NEW)
+endif()
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
project(iree CXX C)
diff --git a/build_tools/cmake/iree_copts.cmake b/build_tools/cmake/iree_copts.cmake
index f421139..2cf4ec0 100644
--- a/build_tools/cmake/iree_copts.cmake
+++ b/build_tools/cmake/iree_copts.cmake
@@ -172,6 +172,14 @@
"$<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions>"
MSVC_OR_CLANG_CL
+ # Default warning level (severe + significant + production quality).
+ # This does not include level 4, "informational", warnings or those that
+ # are off by default.
+ # https://docs.microsoft.com/en-us/cpp/build/reference/compiler-option-warning-level
+ # Note that we set CMake policy CMP0092 (if found), making this explicit:
+ # https://cmake.org/cmake/help/v3.15/policy/CMP0092.html
+ "/W3"
+
# Exclude a bunch of rarely-used APIs, such as crypto/DDE/shell.
# https://docs.microsoft.com/en-us/windows/win32/winprog/using-the-windows-headers
# NOTE: this is not really required anymore for build performance but does