diff options
Diffstat (limited to '0014-cmake-add-an-option-WITH_FMT_HEADER_ONLY.patch')
| -rw-r--r-- | 0014-cmake-add-an-option-WITH_FMT_HEADER_ONLY.patch | 185 | 
1 files changed, 185 insertions, 0 deletions
| diff --git a/0014-cmake-add-an-option-WITH_FMT_HEADER_ONLY.patch b/0014-cmake-add-an-option-WITH_FMT_HEADER_ONLY.patch new file mode 100644 index 0000000..b789619 --- /dev/null +++ b/0014-cmake-add-an-option-WITH_FMT_HEADER_ONLY.patch @@ -0,0 +1,185 @@ +From d8aa71fe943d379590e5d029357a12f667ad2a73 Mon Sep 17 00:00:00 2001 +From: Kefu Chai <kchai@redhat.com> +Date: Fri, 23 Jul 2021 17:52:12 +0800 +Subject: [PATCH 2/3] cmake: add an option "WITH_FMT_HEADER_ONLY" + +in this change: + +* an interface library named "fmt-header-only" is introduced. it brings +  the support to the header only fmt library. +* fmt::fmt is renamed to fmt +* an option named "WITH_FMT_HEADER_ONLY" is introduced +* fmt::fmt is an alias of "fmt-header-only" if "WITH_FMT_HEADER_ONLY" +  is "ON", and an alias of "fmt" otherwise. + +because fmt is packaged in EPEL, while librados is packaged +in RHEL, so we cannot have fmt as a runtime dependency of librados. +to address this issue an option "WITH_FMT_HEADER_ONLY" is introduced, so +that we can enable it when building Ceph with the header version of fmt. +and the built packages won't have runtime dependency of fmt. + +Signed-off-by: Kefu Chai <kchai@redhat.com> +--- + cmake/modules/Findfmt.cmake | 22 ++++++++++++++++++++-- + src/CMakeLists.txt          | 11 +++++++++++ + src/common/CMakeLists.txt   |  1 + + src/mon/CMakeLists.txt      |  5 ++++- + src/msg/CMakeLists.txt      |  1 + + src/neorados/CMakeLists.txt |  2 ++ + src/osd/CMakeLists.txt      |  2 +- + src/tools/CMakeLists.txt    |  2 +- + 8 files changed, 41 insertions(+), 5 deletions(-) + +diff --git a/cmake/modules/Findfmt.cmake b/cmake/modules/Findfmt.cmake +index 747d924e901..734c2b0571c 100644 +--- a/cmake/modules/Findfmt.cmake ++++ b/cmake/modules/Findfmt.cmake +@@ -35,9 +35,27 @@ mark_as_advanced( +   fmt_VERSION_STRING) +  + if(fmt_FOUND AND NOT (TARGET fmt::fmt)) +-  add_library(fmt::fmt UNKNOWN IMPORTED) +-  set_target_properties(fmt::fmt PROPERTIES ++  add_library(fmt-header-only INTERFACE) ++  set_target_properties(fmt-header-only PROPERTIES +     INTERFACE_INCLUDE_DIRECTORIES "${fmt_INCLUDE_DIR}" ++    INTERFACE_COMPILE_DEFINITIONS FMT_HEADER_ONLY=1 ++    INTERFACE_COMPILE_FEATURES cxx_std_11) ++ ++  add_library(fmt UNKNOWN IMPORTED GLOBAL) ++  set_target_properties(fmt PROPERTIES ++    INTERFACE_INCLUDE_DIRECTORIES "${fmt_INCLUDE_DIR}" ++    INTERFACE_COMPILE_FEATURES cxx_std_11 +     IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" +     IMPORTED_LOCATION "${fmt_LIBRARY}") ++ ++  if(WITH_FMT_HEADER_ONLY) ++    # please note, this is different from how upstream defines fmt::fmt. ++    # in order to force 3rd party libraries to link against fmt-header-only if ++    # WITH_FMT_HEADER_ONLY is ON, we have to point fmt::fmt to fmt-header-only ++    # in this case. ++    add_library(fmt::fmt ALIAS fmt-header-only) ++  else() ++    add_library(fmt::fmt ALIAS fmt) ++  endif() ++ + endif() +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 2a80566150c..c4d73633ed8 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -304,6 +304,7 @@ add_subdirectory(json_spirit) + include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/src/xxHash") + include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/src/rapidjson/include") +  ++option(WITH_FMT_HEADER_ONLY "use header-only version of fmt library" OFF) + find_package(fmt 6.0.0 QUIET) + if(fmt_FOUND) +   include_directories(SYSTEM "${fmt_INCLUDE_DIR}") +@@ -360,6 +361,15 @@ if(WITH_SEASTAR) +   add_subdirectory(crimson) + endif() +  ++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 +@@ -396,6 +406,7 @@ 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) +  + if(WITH_JAEGER) +   find_package(yaml-cpp 0.6.0) +diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt +index 6f29dfef350..7482b3d072a 100644 +--- a/src/common/CMakeLists.txt ++++ b/src/common/CMakeLists.txt +@@ -177,6 +177,7 @@ target_compile_definitions(common-common-objs PRIVATE +   "CEPH_LIBDIR=\"${CMAKE_INSTALL_FULL_LIBDIR}\"" +   "CEPH_PKGLIBDIR=\"${CEPH_INSTALL_FULL_PKGLIBDIR}\"" +   "CEPH_DATADIR=\"${CEPH_INSTALL_DATADIR}\"") ++compile_with_fmt(common-common-objs) +  + set(common_mountcephfs_srcs +   armor.c +diff --git a/src/mon/CMakeLists.txt b/src/mon/CMakeLists.txt +index 088fa6a0cdd..b4056fdb1ec 100644 +--- a/src/mon/CMakeLists.txt ++++ b/src/mon/CMakeLists.txt +@@ -33,7 +33,10 @@ endif() +  + add_library(mon STATIC +   ${lib_mon_srcs}) +-target_link_libraries(mon kv heap_profiler) ++target_link_libraries(mon ++  kv ++  heap_profiler ++  fmt::fmt) + if(WITH_JAEGER) +   target_link_libraries(mon jaeger-base) + endif() +diff --git a/src/msg/CMakeLists.txt b/src/msg/CMakeLists.txt +index e6d0b589b42..9cca15c8155 100644 +--- a/src/msg/CMakeLists.txt ++++ b/src/msg/CMakeLists.txt +@@ -38,6 +38,7 @@ if(HAVE_RDMA) + endif() +  + add_library(common-msg-objs OBJECT ${msg_srcs}) ++compile_with_fmt(common-msg-objs) + target_include_directories(common-msg-objs PRIVATE ${OPENSSL_INCLUDE_DIR}) +  + if(WITH_DPDK) +diff --git a/src/neorados/CMakeLists.txt b/src/neorados/CMakeLists.txt +index 50272374d2b..8695b48f0f9 100644 +--- a/src/neorados/CMakeLists.txt ++++ b/src/neorados/CMakeLists.txt +@@ -1,7 +1,9 @@ + add_library(neorados_objs OBJECT +   RADOSImpl.cc) ++compile_with_fmt(neorados_objs) + add_library(neorados_api_obj OBJECT +   RADOS.cc) ++compile_with_fmt(neorados_api_obj) +  + add_library(libneorados STATIC +   $<TARGET_OBJECTS:neorados_api_obj> +diff --git a/src/osd/CMakeLists.txt b/src/osd/CMakeLists.txt +index 0d0ca63b347..373456fc65d 100644 +--- a/src/osd/CMakeLists.txt ++++ b/src/osd/CMakeLists.txt +@@ -50,7 +50,7 @@ endif() + add_library(osd STATIC ${osd_srcs}) + target_link_libraries(osd +   PUBLIC dmclock::dmclock Boost::MPL +-  PRIVATE os heap_profiler cpu_profiler ${CMAKE_DL_LIBS}) ++  PRIVATE os heap_profiler cpu_profiler fmt::fmt ${CMAKE_DL_LIBS}) + if(WITH_LTTNG) +   add_dependencies(osd osd-tp pg-tp) + endif() +diff --git a/src/tools/CMakeLists.txt b/src/tools/CMakeLists.txt +index 1a92898c571..fdfde4f34ef 100644 +--- a/src/tools/CMakeLists.txt ++++ b/src/tools/CMakeLists.txt +@@ -20,7 +20,7 @@ if(NOT WIN32) +   set(neorados_srcs +       neorados.cc) +   add_executable(neorados ${neorados_srcs}) +-  target_link_libraries(neorados libneorados spawn ${CMAKE_DL_LIBS}) ++  target_link_libraries(neorados libneorados spawn fmt::fmt ${CMAKE_DL_LIBS}) +   #install(TARGETS neorados DESTINATION bin) + endif() +  +--  +2.31.1 + | 
