diff --git a/CMakeLists.txt b/CMakeLists.txt index 2091f73f85a..aadd71e481d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,6 +63,7 @@ if (LEGACY_BUILD) option(DISABLE_INTERNAL_IMDSV1_CALLS "Disables IMDSv1 internal client calls" OFF) option(BUILD_BENCHMARKS "Enables building the benchmark executable" OFF) option(BUILD_OPTEL "Enables building the open telemetry implementation of tracing" OFF) + option(AWS_SDK_WARNINGS_ARE_ERRORS "Compiler warning is treated as an error. Try turning this off when observing errors on a new or uncommon compiler" ON) set(AWS_USER_AGENT_CUSTOMIZATION "" CACHE STRING "User agent extension") set(AWS_TEST_REGION "US_EAST_1" CACHE STRING "Region to target integration tests against") diff --git a/cmake/compiler_settings.cmake b/cmake/compiler_settings.cmake index a7689dc5955..c0c19e5b8da 100644 --- a/cmake/compiler_settings.cmake +++ b/cmake/compiler_settings.cmake @@ -53,7 +53,10 @@ macro(set_gcc_flags) endmacro() macro(set_gcc_warnings) - list(APPEND AWS_COMPILER_WARNINGS "-Wall" "-Werror" "-pedantic" "-Wextra") + list(APPEND AWS_COMPILER_WARNINGS "-Wall" "-pedantic" "-Wextra") + if(AWS_SDK_WARNINGS_ARE_ERRORS) + list(APPEND AWS_COMPILER_WARNINGS "-Werror") + endif () if(COMPILER_CLANG) if(PLATFORM_ANDROID) # when using clang with libc and API lower than 21 we need to include Android support headers and ignore the gnu-include-next warning. @@ -153,7 +156,7 @@ macro(set_msvc_warnings) endif() # warnings as errors, max warning level (4) - if(NOT CMAKE_CXX_FLAGS MATCHES "/WX") + if(NOT CMAKE_CXX_FLAGS MATCHES "/WX" AND AWS_SDK_WARNINGS_ARE_ERRORS) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX") endif()