From aa57b9c309208fa6b32005e7be5adf1b31455052 Mon Sep 17 00:00:00 2001 From: Adam Emerson Date: Thu, 26 Oct 2023 19:11:12 -0400 Subject: [PATCH] build: Fix `WITH_FMT_HEADER_ONLY` Previously it was still linking in the submodule's static libraries and ldd showed it linking to the system fmt's shared libraries. Signed-off-by: Adam Emerson --- src/CMakeLists.txt | 18 +++++++++--------- src/common/CMakeLists.txt | 2 +- src/crimson/os/alienstore/CMakeLists.txt | 2 +- src/crimson/osd/CMakeLists.txt | 2 +- src/mon/CMakeLists.txt | 2 +- src/msg/CMakeLists.txt | 2 +- src/neorados/CMakeLists.txt | 6 +++--- src/osd/CMakeLists.txt | 2 +- src/rgw/CMakeLists.txt | 2 +- src/test/neorados/CMakeLists.txt | 6 +++--- src/tools/CMakeLists.txt | 2 +- 11 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index dca5e6e6d4ab..5b1300bb84a3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -330,20 +330,20 @@ option(WITH_SYSTEM_FMT "build against system fmt" OFF) if(WITH_SYSTEM_FMT) find_package(fmt 8.1.1...<10.0.0 REQUIRED) endif() +if (WITH_FMT_HEADER_ONLY) + message(STATUS "Using fmt header-only.") + set(FMT_LIB fmt::fmt-header-only) +else() + message(STATUS "Linking to fmt library.") + set(FMT_LIB fmt::fmt) +endif() if(fmt_FOUND) message(STATUS "Building with system fmt.") - if (WITH_FMT_HEADER_ONLY) - message(STATUS "Using fmt header-only.") - add_library(fmt::fmt ALIAS fmt::fmt-header-only) - endif() else() message(STATUS "Building fmt as submodule") set(old_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS}) set(BUILD_SHARED_LIBS FALSE) add_subdirectory(fmt) - if (WITH_FMT_HEADER_ONLY) - add_library(fmt::fmt ALIAS fmt-header-only) - endif() set(BUILD_SHARED_LIBS ${old_BUILD_SHARED_LIBS}) unset(old_BUILD_SHARED_LIBS) include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/src/fmt/include") @@ -439,7 +439,7 @@ 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}) target_compile_definitions(common-objs PRIVATE - $) + $) add_dependencies(common-objs legacy-option-headers) if(WITH_JAEGER) @@ -482,7 +482,7 @@ set(ceph_common_deps Boost::date_time Boost::iostreams StdFilesystem::filesystem - fmt::fmt + ${FMT_LIB} ${BLKID_LIBRARIES} ${Backtrace_LIBRARIES} ${BLKIN_LIBRARIES} diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 5f07f7e8483c..3deecc3f3d6b 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -192,7 +192,7 @@ 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}\"" - $) + $) add_dependencies(common-common-objs legacy-option-headers) set(common_mountcephfs_srcs diff --git a/src/crimson/os/alienstore/CMakeLists.txt b/src/crimson/os/alienstore/CMakeLists.txt index c881f4fbccbc..20e03d3305ff 100644 --- a/src/crimson/os/alienstore/CMakeLists.txt +++ b/src/crimson/os/alienstore/CMakeLists.txt @@ -76,7 +76,7 @@ endif() target_link_libraries(crimson-alienstore PRIVATE alien::cflags - fmt::fmt + ${FMT_LIB} kv heap_profiler crimson-alien-common diff --git a/src/crimson/osd/CMakeLists.txt b/src/crimson/osd/CMakeLists.txt index f521e0244d7a..817027c18ffc 100644 --- a/src/crimson/osd/CMakeLists.txt +++ b/src/crimson/osd/CMakeLists.txt @@ -61,7 +61,7 @@ target_link_libraries(crimson-osd crimson-common crimson-os crimson - fmt::fmt + ${FMT_LIB} Boost::MPL dmclock::dmclock) set_target_properties(crimson-osd PROPERTIES diff --git a/src/mon/CMakeLists.txt b/src/mon/CMakeLists.txt index 784b4c3ee0b3..3f2b8605344b 100644 --- a/src/mon/CMakeLists.txt +++ b/src/mon/CMakeLists.txt @@ -40,7 +40,7 @@ add_library(mon STATIC target_link_libraries(mon kv heap_profiler - fmt::fmt) + ${FMT_LIB}) if(WITH_JAEGER) target_link_libraries(mon jaeger_base) endif() diff --git a/src/msg/CMakeLists.txt b/src/msg/CMakeLists.txt index e8cc3fdabdf6..ff2d47276f25 100644 --- a/src/msg/CMakeLists.txt +++ b/src/msg/CMakeLists.txt @@ -46,7 +46,7 @@ endif() add_library(common-msg-objs OBJECT ${msg_srcs}) target_compile_definitions(common-msg-objs PRIVATE - $) + $) 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 c66043ac9f94..119554f67d10 100644 --- a/src/neorados/CMakeLists.txt +++ b/src/neorados/CMakeLists.txt @@ -1,17 +1,17 @@ add_library(neorados_objs OBJECT RADOSImpl.cc) target_compile_definitions(neorados_objs PRIVATE - $) + $) add_library(neorados_api_obj OBJECT RADOS.cc) target_compile_definitions(neorados_api_obj PRIVATE - $) + $) add_library(libneorados STATIC $ $) target_link_libraries(libneorados PRIVATE - osdc ceph-common cls_lock_client fmt::fmt + osdc ceph-common cls_lock_client ${FMT_LIB} ${BLKID_LIBRARIES} ${CRYPTO_LIBS} ${EXTRALIBS}) # if(ENABLE_SHARED) diff --git a/src/osd/CMakeLists.txt b/src/osd/CMakeLists.txt index 7d19424b404a..85f65f7f0e19 100644 --- a/src/osd/CMakeLists.txt +++ b/src/osd/CMakeLists.txt @@ -56,7 +56,7 @@ endif() add_library(osd STATIC ${osd_srcs}) target_link_libraries(osd PUBLIC dmclock::dmclock Boost::MPL - PRIVATE os heap_profiler cpu_profiler fmt::fmt ${CMAKE_DL_LIBS}) + PRIVATE os heap_profiler cpu_profiler ${FMT_LIB} ${CMAKE_DL_LIBS}) if(WITH_LTTNG) add_dependencies(osd osd-tp pg-tp) endif() diff --git a/src/rgw/CMakeLists.txt b/src/rgw/CMakeLists.txt index c90a553abee0..9b55081dbaaa 100644 --- a/src/rgw/CMakeLists.txt +++ b/src/rgw/CMakeLists.txt @@ -284,7 +284,7 @@ target_link_libraries(rgw_common ${LUA_LIBRARIES} RapidJSON::RapidJSON spawn - fmt::fmt) + ${FMT_LIB}) target_include_directories(rgw_common PUBLIC "${CMAKE_SOURCE_DIR}/src/rgw/services" PUBLIC "${CMAKE_SOURCE_DIR}/src/rgw/driver/rados" diff --git a/src/test/neorados/CMakeLists.txt b/src/test/neorados/CMakeLists.txt index 31e79a6615c4..ba96fb479d29 100644 --- a/src/test/neorados/CMakeLists.txt +++ b/src/test/neorados/CMakeLists.txt @@ -17,12 +17,12 @@ target_link_libraries(ceph_test_neorados_completions Boost::system pthread add_executable(ceph_test_neorados_op_speed op_speed.cc) target_link_libraries(ceph_test_neorados_op_speed - libneorados fmt::fmt ${unittest_libs}) + libneorados ${FMT_LIB} ${unittest_libs}) add_library(neoradostest-support STATIC common_tests.cc) target_link_libraries(neoradostest-support - libneorados fmt::fmt) + libneorados ${FMT_LIB}) add_executable(ceph_test_neorados_list_pool list_pool.cc) target_link_libraries(ceph_test_neorados_list_pool - libneorados neoradostest-support global fmt::fmt ${unittest_libs}) + libneorados neoradostest-support global ${FMT_LIB} ${unittest_libs}) diff --git a/src/tools/CMakeLists.txt b/src/tools/CMakeLists.txt index aeb9d0248ea6..d1133798c5c9 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 fmt::fmt ${CMAKE_DL_LIBS}) + target_link_libraries(neorados libneorados spawn ${FMT_LIB} ${CMAKE_DL_LIBS}) #install(TARGETS neorados DESTINATION bin) endif() -- 2.47.3