]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
cmake: use -Wno-unused-but-set-variable when compiling SPDK if supported
authorKefu Chai <kchai@redhat.com>
Mon, 16 Aug 2021 09:32:33 +0000 (17:32 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 16 Aug 2021 09:32:34 +0000 (17:32 +0800)
to silence warnings like:

In file included from nvme_tcp.c:52:
/home/jenkins-build/build/workspace/ceph-pull-requests/src/spdk/include/spdk_internal/nvme_tcp.h:369:17: warning: variable 'plen' set but not used [-Wunused-but-set-variable]
        uint32_t hlen, plen;
                       ^

Signed-off-by: Kefu Chai <kchai@redhat.com>
cmake/modules/BuildSPDK.cmake

index 73ead20c8035ddf17d047d6b8775a1e8ea43c4df..676ec7fcd9f379e61fbc179ddd1621ca54b5a0cc 100644 (file)
@@ -14,10 +14,16 @@ macro(build_spdk)
 
   set(spdk_CFLAGS "-fPIC")
   include(CheckCCompilerFlag)
-  check_c_compiler_flag("-Wno-address-of-packed-member" HAS_WARNING_ADDRESS_OF_PACKED_MEMBER)
-  if(HAS_WARNING_ADDRESS_OF_PACKED_MEMBER)
+  check_c_compiler_flag("-Wno-address-of-packed-member" HAVE_WARNING_ADDRESS_OF_PACKED_MEMBER)
+  if(HAVE_WARNING_ADDRESS_OF_PACKED_MEMBER)
     string(APPEND spdk_CFLAGS " -Wno-address-of-packed-member")
   endif()
+  check_c_compiler_flag("-Wno-unused-but-set-variable"
+    HAVE_UNUSED_BUT_SET_VARIABLE)
+  if(HAVE_UNUSED_BUT_SET_VARIABLE)
+    string(APPEND spdk_CFLAGS " -Wno-unused-but-set-variable")
+  endif()
+
   include(ExternalProject)
   if(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64|x86_64|AMD64")
     # a safer option than relying on the build host's arch