[PATCH rdma-core 18/19] build: Use the CMake variable -DENABLE_WERROR to turn on WERROR mode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Jason Gunthorpe <jgg@xxxxxxxxxxxx>

This way the flag can be passed through EXTRA_CMAKE_FLAGS to rpmbuild and
debian/rules instead of hacking it in via sed/etc.

Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxxxx>
---
 CMakeLists.txt               |  5 +++++
 buildlib/azure-pipelines.yml | 24 ++++++++++--------------
 2 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index f9353ddbc86d1e..9bb58a9b803667 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -538,6 +538,11 @@ RDMA_DoFixup("${HAVE_STATIC_ASSERT}" "assert.h")
 RDMA_AddOptCFlag(CMAKE_C_FLAGS HAVE_C_WSTRICT_PROTOTYPES "-Wstrict-prototypes")
 RDMA_AddOptCFlag(CMAKE_C_FLAGS HAVE_C_WOLD_STYLE_DEFINITION "-Wold-style-definition")
 
+if (ENABLE_WERROR)
+  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
+  message(STATUS "Enabled -Werror")
+endif()
+
 # Old versions of libnl have a duplicated rtnl_route_put, disbale the warning on those
 # systems
 if (NOT NL_KIND EQUAL 0)
diff --git a/buildlib/azure-pipelines.yml b/buildlib/azure-pipelines.yml
index 153d437d8e81e9..4eef7408af027c 100644
--- a/buildlib/azure-pipelines.yml
+++ b/buildlib/azure-pipelines.yml
@@ -43,7 +43,7 @@ stages:
               set -e
               mkdir build-gcc9
               cd build-gcc9
-              CC=gcc-9 CFLAGS="-Werror" cmake -GNinja .. -DIOCTL_MODE=both -DENABLE_STATIC=1
+              CC=gcc-9 cmake -GNinja .. -DIOCTL_MODE=both -DENABLE_STATIC=1 -DENABLE_WERROR=1
               ninja
             displayName: gcc 9.1 Compile
 
@@ -62,7 +62,7 @@ stages:
               mv CMakeLists.txt CMakeLists-orig.txt
               grep -v "# NO SPARSE" CMakeLists-orig.txt > CMakeLists.txt
               cd build-sparse
-              CC=cgcc CFLAGS="-Werror" cmake -GNinja .. -DIOCTL_MODE=both -DNO_PYVERBS=1
+              CC=cgcc cmake -GNinja .. -DIOCTL_MODE=both -DNO_PYVERBS=1 -DENABLE_WERROR=1
               ninja | grep -v '^\[' | tee out
               # sparse does not fail gcc on messages
               if [ -s out ]; then
@@ -75,7 +75,7 @@ stages:
               set -e
               mkdir build-clang
               cd build-clang
-              CC=clang-8 CFLAGS="-Werror -m32 -msse3" cmake -GNinja .. -DIOCTL_MODE=both -DNO_PYVERBS=1
+              CC=clang-8 CFLAGS="-m32" cmake -GNinja .. -DIOCTL_MODE=both -DNO_PYVERBS=1 -DENABLE_WERROR=1
               ninja
             displayName: clang 8.0 32-bit Compile
 
@@ -85,7 +85,7 @@ stages:
               echo "#error Fail" >> util/udma_barrier.h
               cd build-gcc9
               rm CMakeCache.txt
-              CC=gcc-9 CFLAGS="-Werror" cmake -GNinja .. -DIOCTL_MODE=both
+              CC=gcc-9 cmake -GNinja .. -DIOCTL_MODE=both -DENABLE_WERROR=1
               ninja
               mv ../util/udma_barrier.h.old ../util/udma_barrier.h
             displayName: Simulate non-coherent DMA Platform Compile
@@ -94,7 +94,7 @@ stages:
               set -e
               mkdir build-arm64
               cd build-arm64
-              CC=aarch64-linux-gnu-gcc-8 CFLAGS="-Werror" cmake -GNinja .. -DIOCTL_MODE=both -DNO_PYVERBS=1
+              CC=aarch64-linux-gnu-gcc-8 cmake -GNinja .. -DIOCTL_MODE=both -DNO_PYVERBS=1 -DENABLE_WERROR=1
               ninja
             displayName: gcc 8.3 ARM64 Compile
 
@@ -102,18 +102,14 @@ stages:
               set -e
               mkdir build-ppc64el
               cd build-ppc64el
-              CC=powerpc64le-linux-gnu-gcc-8 CFLAGS="-Werror" cmake -GNinja .. -DIOCTL_MODE=both -DNO_PYVERBS=1
+              CC=powerpc64le-linux-gnu-gcc-8 cmake -GNinja .. -DIOCTL_MODE=both -DNO_PYVERBS=1 -DENABLE_WERROR=1
               ninja
             displayName: gcc 8.3 PPC64EL Compile
 
-          # When running cmake through debian/rules it is hard to set -Werror,
-          # instead force it on by changing the CMakeLists.txt
           - bash: |
               set -e
-              echo 'set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")' >> buildlib/RDMA_EnableCStd.cmake
-              sed -i -e 's/-DCMAKE_BUILD_TYPE=Release/-DCMAKE_BUILD_TYPE=Debug/g' debian/rules
               sed -i -e 's/ninja \(.*\)-v/ninja \1/g' debian/rules
-              debian/rules CC=clang-8 build
+              debian/rules CC=clang-8 EXTRA_CMAKE_FLAGS="-DCMAKE_BUILD_TYPE=Debug -DENABLE_WERROR=1" build
             displayName: clang 8.0 Bionic Build
           - bash: |
               set -e
@@ -164,15 +160,15 @@ stages:
             centos7:
               CONTAINER: centos7
               SPEC: redhat/rdma-core.spec
-              RPMBUILD_OPTS:
+              RPMBUILD_OPTS:  --define 'EXTRA_CMAKE_FLAGS -DCMAKE_BUILD_TYPE=Debug -DENABLE_WERROR=1'
             fedora30:
               CONTAINER: fedora
               SPEC: redhat/rdma-core.spec
-              RPMBUILD_OPTS:
+              RPMBUILD_OPTS:  --define 'EXTRA_CMAKE_FLAGS -DCMAKE_BUILD_TYPE=Debug -DENABLE_WERROR=1'
             leap:
               CONTAINER: leap
               SPEC: suse/rdma-core.spec
-              RPMBUILD_OPTS: --without=curlmini
+              RPMBUILD_OPTS:  --define 'EXTRA_CMAKE_FLAGS -DCMAKE_BUILD_TYPE=Debug -DENABLE_WERROR=1' --without=curlmini
         container: $[ variables['CONTAINER'] ]
         steps:
           - checkout: none
-- 
2.22.0




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux