cmake: use generator exp. for passing fmt::fmt's COMPILE_DEFINITIONS

more concise this way, without yet another redirection.

Signed-off-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
Kefu Chai 2021-07-24 15:01:54 +08:00
parent 43d10b9e44
commit 99ba98cef0
4 changed files with 10 additions and 15 deletions

View File

@ -388,15 +388,6 @@ set(CMAKE_EXTRA_INCLUDE_FILES "sys/time.h")
CHECK_TYPE_SIZE(suseconds_t SUSECONDS_T)
unset(CMAKE_EXTRA_INCLUDE_FILES)
function(compile_with_fmt target)
get_target_property(fmt_compile_definitions
fmt::fmt INTERFACE_COMPILE_DEFINITIONS)
if(fmt_compile_definitions)
target_compile_definitions(${target} PUBLIC
${fmt_compile_definitions})
endif()
endfunction()
set(libcommon_files
${CMAKE_BINARY_DIR}/src/include/ceph_ver.h
ceph_ver.c
@ -434,7 +425,8 @@ endif()
set_source_files_properties(ceph_ver.c
APPEND PROPERTY OBJECT_DEPENDS ${CMAKE_BINARY_DIR}/src/include/ceph_ver.h)
add_library(common-objs OBJECT ${libcommon_files})
compile_with_fmt(common-objs)
target_compile_definitions(common-objs PRIVATE
$<TARGET_PROPERTY:fmt::fmt,INTERFACE_COMPILE_DEFINITIONS>)
add_dependencies(common-objs legacy-option-headers)
if(WITH_JAEGER)

View File

@ -188,8 +188,8 @@ target_include_directories(common-common-objs PRIVATE ${OPENSSL_INCLUDE_DIR})
target_compile_definitions(common-common-objs PRIVATE
"CMAKE_INSTALL_LIBDIR=\"${CMAKE_INSTALL_LIBDIR}\""
"CEPH_INSTALL_FULL_PKGLIBDIR=\"${CEPH_INSTALL_FULL_PKGLIBDIR}\""
"CEPH_INSTALL_DATADIR=\"${CEPH_INSTALL_DATADIR}\"")
compile_with_fmt(common-common-objs)
"CEPH_INSTALL_DATADIR=\"${CEPH_INSTALL_DATADIR}\""
$<TARGET_PROPERTY:fmt::fmt,INTERFACE_COMPILE_DEFINITIONS>)
add_dependencies(common-common-objs legacy-option-headers)
set(common_mountcephfs_srcs

View File

@ -38,7 +38,8 @@ if(HAVE_RDMA)
endif()
add_library(common-msg-objs OBJECT ${msg_srcs})
compile_with_fmt(common-msg-objs)
target_compile_definitions(common-msg-objs PRIVATE
$<TARGET_PROPERTY:fmt::fmt,INTERFACE_COMPILE_DEFINITIONS>)
target_include_directories(common-msg-objs PRIVATE ${OPENSSL_INCLUDE_DIR})
if(WITH_DPDK)

View File

@ -1,9 +1,11 @@
add_library(neorados_objs OBJECT
RADOSImpl.cc)
compile_with_fmt(neorados_objs)
target_compile_definitions(neorados_objs PRIVATE
$<TARGET_PROPERTY:fmt::fmt,INTERFACE_COMPILE_DEFINITIONS>)
add_library(neorados_api_obj OBJECT
RADOS.cc)
compile_with_fmt(neorados_api_obj)
target_compile_definitions(neorados_api_obj PRIVATE
$<TARGET_PROPERTY:fmt::fmt,INTERFACE_COMPILE_DEFINITIONS>)
add_library(libneorados STATIC
$<TARGET_OBJECTS:neorados_api_obj>