diff --git a/lldb/cmake/caches/Apple-lldb-macOS.cmake b/lldb/cmake/caches/Apple-lldb-macOS.cmake --- a/lldb/cmake/caches/Apple-lldb-macOS.cmake +++ b/lldb/cmake/caches/Apple-lldb-macOS.cmake @@ -2,6 +2,7 @@ set(LLDB_BUILD_FRAMEWORK ON CACHE BOOL "") set(LLDB_NO_INSTALL_DEFAULT_RPATH ON CACHE BOOL "") +set(LLDB_ENABLE_WERROR ON CACHE BOOL "") set(CMAKE_OSX_DEPLOYMENT_TARGET 10.11 CACHE STRING "") # Default install location on the enduser machine. On the build machine, use the diff --git a/lldb/cmake/modules/LLDBConfig.cmake b/lldb/cmake/modules/LLDBConfig.cmake --- a/lldb/cmake/modules/LLDBConfig.cmake +++ b/lldb/cmake/modules/LLDBConfig.cmake @@ -51,6 +51,7 @@ option(LLDB_BUILD_FRAMEWORK "Build LLDB.framework (Darwin only)" OFF) option(LLDB_NO_INSTALL_DEFAULT_RPATH "Disable default RPATH settings in binaries" OFF) option(LLDB_USE_SYSTEM_DEBUGSERVER "Use the system's debugserver for testing (Darwin only)." OFF) +option(LLDB_ENABLE_WERROR "Fail and stop if a warning is triggered." ${LLVM_ENABLE_WERROR}) if(LLDB_BUILD_FRAMEWORK) if(NOT APPLE) @@ -311,6 +312,16 @@ ) endif() +if(LLDB_ENABLE_WERROR) + set(flag_werror "-Werror") + if(MSVC) + set(flag_werror "/WX") + endif() + + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag_werror}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag_werror}") +endif() + # Use the Unicode (UTF-16) APIs by default on Win32 if (CMAKE_SYSTEM_NAME MATCHES "Windows") add_definitions( -D_UNICODE -DUNICODE )