From: Kefu Chai Date: Mon, 16 Aug 2021 09:32:33 +0000 (+0800) Subject: cmake: use -Wno-unused-but-set-variable when compiling SPDK if supported X-Git-Tag: v17.1.0~1111^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=33545a7b1c92460c1ac7ce319848701e835548b0;p=ceph-ci.git cmake: use -Wno-unused-but-set-variable when compiling SPDK if supported 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 --- diff --git a/cmake/modules/BuildSPDK.cmake b/cmake/modules/BuildSPDK.cmake index 73ead20c803..676ec7fcd9f 100644 --- a/cmake/modules/BuildSPDK.cmake +++ b/cmake/modules/BuildSPDK.cmake @@ -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