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