]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake: pass -Wunused-but-set-variable when building dpdk
authorKefu Chai <kchai@redhat.com>
Sun, 15 Aug 2021 08:31:02 +0000 (16:31 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 16 Aug 2021 06:23:17 +0000 (14:23 +0800)
otherwise we have:

src/spdk/dpdk/lib/librte_eal/linux/eal.c:591:11: error: variable 'total_mem' set but not used [-Werror,-Wunused-but-set-variable]
        uint64_t total_mem = 0;
                 ^
1 error generated.

when building dpdk with Clang. dpdk passes -Werror to compiler, so
we have to disable this option.

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

index 69aa471c3744183a9a2a528e25ce2ed343b290e5..63bd56df20cd279278760e76c8d5f77b6ca49a3d 100644 (file)
@@ -82,11 +82,19 @@ function(do_build_dpdk dpdk_dir)
     set(dpdk_source_dir ${CMAKE_SOURCE_DIR}/src/spdk/dpdk)
   endif()
 
+  set(extra_cflags "-fPIC")
+  include(CheckCCompilerFlag)
+  check_c_compiler_flag("-Wno-unused-but-set-variable"
+    HAVE_UNUSED_BUT_SET_VARIABLE)
+  if(HAVE_UNUSED_BUT_SET_VARIABLE)
+    string(APPEND extra_cflags " -Wno-unused-but-set-variable")
+  endif()
+
   include(ExternalProject)
   ExternalProject_Add(dpdk-ext
     SOURCE_DIR ${dpdk_source_dir}
     CONFIGURE_COMMAND ${make_cmd} config O=${dpdk_dir} T=${target}
-    BUILD_COMMAND ${make_cmd} O=${dpdk_dir} CC=${CMAKE_C_COMPILER} EXTRA_CFLAGS=-fPIC
+    BUILD_COMMAND ${make_cmd} O=${dpdk_dir} CC=${CMAKE_C_COMPILER} EXTRA_CFLAGS=${extra_cflags}
     BUILD_IN_SOURCE 1
     INSTALL_COMMAND "")
   if(NUMA_FOUND)