Add `IREE_ENABLE_WERROR_FLAG` CMake option. (#16121)
> Agree with @ Jakub Kuderski : it isn't a great default for people
using the project on random systems.
> By Stella.
Simple change to add option to disable `-Werror` flag.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5617704..39d03fd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -439,6 +439,7 @@
option(IREE_ENABLE_SPLIT_DWARF "Enable gsplit-dwarf for debug information if the platform supports it" OFF)
option(IREE_ENABLE_THIN_ARCHIVES "Enables thin ar archives (elf systems only). Disable for released static archives" OFF)
option(IREE_LINK_COMPILER_SHARED_LIBRARY "Links IREE tools using the compiler compiled into a shared library" ON)
+option(IREE_ENABLE_WERROR_FLAG "Enable `-Werror` flag, treat error as warning" ON)
# STREQUAL feels wrong here - we don't care about the exact true-value used,
# ON or TRUE or something else. But we haven't been able to think of a less bad
diff --git a/build_tools/cmake/iree_copts.cmake b/build_tools/cmake/iree_copts.cmake
index 038e9b3..5b36433 100644
--- a/build_tools/cmake/iree_copts.cmake
+++ b/build_tools/cmake/iree_copts.cmake
@@ -151,7 +151,7 @@
# internally is very useful when importing. If you feel that some of these
# should be different (especially more strict), please raise an issue!
CLANG
- "-Werror"
+ "$<$<BOOL:${IREE_ENABLE_WERROR_FLAG}>:-Werror>"
"-Wall"
"-Wno-error=deprecated-declarations" # Want to see them but defaults to error.
@@ -217,7 +217,7 @@
GCC
"-Wall"
- "-Werror"
+ "$<$<BOOL:${IREE_ENABLE_WERROR_FLAG}>:-Werror>"
"-Wno-error=deprecated-declarations" # Want to see them but defaults to error.
"-Wno-address" # https://github.com/openxla/iree/issues/16016