diff --git a/cmake/modules/BuildSPDK.cmake b/cmake/modules/BuildSPDK.cmake index 4b8306a3881..2522ccffa47 100644 --- a/cmake/modules/BuildSPDK.cmake +++ b/cmake/modules/BuildSPDK.cmake @@ -18,6 +18,12 @@ macro(build_spdk) set(make_cmd "${MAKE_EXECUTABLE}") endif() + 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) + set(spdk_CFLAGS "${spdk_CFLAGS} -Wno-address-of-packed-member") + endif() include(ExternalProject) ExternalProject_Add(spdk-ext DEPENDS dpdk-ext @@ -26,7 +32,7 @@ macro(build_spdk) # unset $CFLAGS, otherwise it will interfere with how SPDK sets # its include directory. # unset $LDFLAGS, otherwise SPDK will fail to mock some functions. - BUILD_COMMAND env -i PATH=$ENV{PATH} CC=${CMAKE_C_COMPILER} ${make_cmd} EXTRA_CFLAGS="-fPIC" + BUILD_COMMAND env -i PATH=$ENV{PATH} CC=${CMAKE_C_COMPILER} ${make_cmd} EXTRA_CFLAGS="${spdk_CFLAGS}" BUILD_IN_SOURCE 1 INSTALL_COMMAND "true") unset(make_cmd)