Skip to content

Commit

Permalink
Issue #6640 Option to disable warnings as error (#6737)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
stsoe committed May 31, 2022
1 parent 922a610 commit aaff773
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
11 changes: 11 additions & 0 deletions build/build.sh
Expand Up @@ -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 <boost> Build binaries using static linking of boost from specified boost install"
Expand Down Expand Up @@ -89,6 +90,7 @@ noctest=0
static_boost=""
ertbsp=""
ertfw=""
werror=1
cmake_flags="-DCMAKE_EXPORT_COMPILE_COMMANDS=ON"

while [ $# -gt 0 ]; do
Expand Down Expand Up @@ -134,6 +136,10 @@ while [ $# -gt 0 ]; do
noctest=1
shift
;;
-disable-werror|--disable-werror)
werror=0
shift
;;
-j)
shift
jcore=$1
Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/CMakeLists.txt
Expand Up @@ -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
Expand All @@ -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})
Expand Down
5 changes: 4 additions & 1 deletion src/runtime_src/CMakeLists.txt
Expand Up @@ -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()
Expand Down

0 comments on commit aaff773

Please sign in to comment.