From aaff77327ce3bd523cc767f64536e67435e1ec3c Mon Sep 17 00:00:00 2001 From: Soren Soe <2106410+stsoe@users.noreply.github.com> Date: Mon, 30 May 2022 20:39:02 -0700 Subject: [PATCH] Issue #6640 Option to disable warnings as error (#6737) * WIP * Issue #6640 Option to disable warnings as error Provide build.sh option `-disable-werror` to disable warnings as errors. Not willing to disable `-Werror` by default, since I can't seem to find a good way to have it enabled for all internal builds including all developers. Fixes #6640, maybe not exactly per comments, but close enough. --- build/build.sh | 11 +++++++++++ src/CMakeLists.txt | 4 ++-- src/runtime_src/CMakeLists.txt | 5 ++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/build/build.sh b/build/build.sh index 6afdd763115..23537d1004c 100755 --- a/build/build.sh +++ b/build/build.sh @@ -43,6 +43,7 @@ usage() echo "[-dbg] Build debug library only (default)" echo "[-opt] Build optimized library only (default)" echo "[-edge] Build edge of x64. Turns off opt and dbg" + echo "[-disable-werror] Disable compilation with warnings as error" echo "[-nocmake] Skip CMake call" echo "[-noctest] Skip unit tests" echo "[-with-static-boost Build binaries using static linking of boost from specified boost install" @@ -89,6 +90,7 @@ noctest=0 static_boost="" ertbsp="" ertfw="" +werror=1 cmake_flags="-DCMAKE_EXPORT_COMPILE_COMMANDS=ON" while [ $# -gt 0 ]; do @@ -134,6 +136,10 @@ while [ $# -gt 0 ]; do noctest=1 shift ;; + -disable-werror|--disable-werror) + werror=0 + shift + ;; -j) shift jcore=$1 @@ -196,6 +202,11 @@ debug_dir=${DEBUG_DIR:-Debug} release_dir=${REL_DIR:-Release} edge_dir=${EDGE_DIR:-Edge} +# By default compile with warnings as errors. +# Update every time CMake is generating makefiles. +# Disable with '-disable-werror' option. +cmake_flags+=" -DXRT_ENABLE_WERROR=$werror" + here=$PWD cd $BUILDDIR diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 043d8c36e67..8467aba568c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -31,7 +31,7 @@ endif() if ( ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" ) set(XRT_WARN_OPTS - -Wall -Werror + -Wall -Wno-mismatched-tags -Wno-unused-const-variable -Wno-unused-private-field @@ -45,7 +45,7 @@ if ( ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" ) -Wno-overloaded-virtual ) else() - set(XRT_WARN_OPTS -Wall -Werror ) + set(XRT_WARN_OPTS -Wall) endif() if (DEFINED ENV{XRT_NATIVE_BUILD}) diff --git a/src/runtime_src/CMakeLists.txt b/src/runtime_src/CMakeLists.txt index 607f86fd5e5..6c576d54884 100644 --- a/src/runtime_src/CMakeLists.txt +++ b/src/runtime_src/CMakeLists.txt @@ -23,7 +23,10 @@ endif() add_compile_options("-fPIC") -# TODO CL_TARGET_OPENCL_VERSION is not defined.. +if (XRT_ENABLE_WERROR) + list(APPEND XRT_WARN_OPTS "-Werror") +endif(XRT_ENABLE_WERROR) + if (${XRT_NATIVE_BUILD} STREQUAL "yes") add_compile_options( ${XRT_WARN_OPTS} ) endif()