From 8c44876be478e9d6f317da14d7ab1f79403a9788 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Thu, 8 Apr 2021 16:43:33 +0800 Subject: [PATCH] cmake: s/HAVE_MSGHDR/WITH_SYSTEMD/ as FreeBSD also has msghdr but it does not have systemd, or flags like MFD_ALLOW_SEALING, O_TMPFILE or F_SEAL_GROW. so use WITH_SYSTEMD for enabling journald backend of logging system. also move the option of "WITH_SYSTEMD" up so that the src/CMakeLists.txt is able to see the variable of WITH_SYSTEMD defined by it. Signed-off-by: Kefu Chai --- CMakeLists.txt | 3 ++- cmake/modules/CephChecks.cmake | 2 -- src/common/CMakeLists.txt | 2 +- src/common/Journald.h | 6 +++--- src/include/config-h.in.cmake | 6 +++--- src/test/CMakeLists.txt | 2 +- src/test/common/CMakeLists.txt | 2 +- 7 files changed, 11 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a913cbe6c93..f623c5e1b79 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -682,6 +682,8 @@ add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} DEPENDS tests) +option(WITH_SYSTEMD "build with systemd support" ON) + add_subdirectory(src) add_subdirectory(qa) @@ -691,7 +693,6 @@ if(WITH_MANPAGE) add_subdirectory(man) endif(WITH_MANPAGE) -option(WITH_SYSTEMD "install systemd target and service files" ON) if(WITH_SYSTEMD) add_subdirectory(systemd) endif() diff --git a/cmake/modules/CephChecks.cmake b/cmake/modules/CephChecks.cmake index ed1d2c827af..46b50b387c7 100644 --- a/cmake/modules/CephChecks.cmake +++ b/cmake/modules/CephChecks.cmake @@ -65,8 +65,6 @@ CHECK_TYPE_SIZE(__s8 __S8) CHECK_TYPE_SIZE(__s16 __S16) CHECK_TYPE_SIZE(__s32 __S32) CHECK_TYPE_SIZE(__s64 __S64) -set(CMAKE_EXTRA_INCLUDE_FILES "sys/types.h" "sys/socket.h") -CHECK_TYPE_SIZE("struct msghdr" MSGHDR) unset(CMAKE_EXTRA_INCLUDE_FILES) include(CheckSymbolExists) diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 807f8a23b44..ea9d46cfe77 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -100,7 +100,7 @@ set(common_srcs util.cc version.cc) -if(HAVE_MSGHDR) +if(WITH_SYSTEMD) list(APPEND common_srcs Journald.cc) endif() diff --git a/src/common/Journald.h b/src/common/Journald.h index deb41573128..8653b0461b5 100644 --- a/src/common/Journald.h +++ b/src/common/Journald.h @@ -13,7 +13,7 @@ struct LogEntry; namespace ceph::logging { -#ifdef HAVE_MSGHDR +#ifdef WITH_SYSTEMD namespace detail { @@ -86,7 +86,7 @@ class JournaldClusterLogger { std::unique_ptr m_log_entry_encoder; }; -#else // HAVE_MSGHDR +#else // WITH_SYSTEMD class JournaldLogger { public: @@ -103,7 +103,7 @@ public: } }; -#endif // HAVE_MSGHDR +#endif // WITH_SYSTEMD } // ceph::logging diff --git a/src/include/config-h.in.cmake b/src/include/config-h.in.cmake index 4425ae97bec..338f7a48390 100644 --- a/src/include/config-h.in.cmake +++ b/src/include/config-h.in.cmake @@ -63,9 +63,6 @@ /* Define to 1 if the system has the type `__u8'. */ #cmakedefine HAVE___U8 1 -/* Define to 1 if the system has the type `msghdr` */ -#cmakedefine HAVE_MSGHDR 1 - /* Define if you have res_nquery */ #cmakedefine HAVE_RES_NQUERY @@ -133,6 +130,9 @@ /* define if cephfs enabled */ #cmakedefine WITH_CEPHFS +/* define if systemed is enabled */ +#cmakedefine WITH_SYSTEMD + /*define if GSSAPI/KRB5 enabled */ #cmakedefine HAVE_GSSAPI diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index 5ead7484213..b30ed6955b2 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -153,7 +153,7 @@ if(NOT WIN32) target_link_libraries(ceph_bench_log rt) endif() -if(HAVE_MSGHDR) +if(WITH_SYSTEMD) add_executable(ceph_bench_journald_logger bench_journald_logger.cc) target_link_libraries(ceph_bench_journald_logger ceph-common) diff --git a/src/test/common/CMakeLists.txt b/src/test/common/CMakeLists.txt index 28b226addc3..679acd24c82 100644 --- a/src/test/common/CMakeLists.txt +++ b/src/test/common/CMakeLists.txt @@ -361,7 +361,7 @@ target_link_libraries(unittest_blocked_completion Boost::system GTest::GTest) add_executable(unittest_allocate_unique test_allocate_unique.cc) add_ceph_unittest(unittest_allocate_unique) -if(HAVE_MSGHDR) +if(WITH_SYSTEMD) add_executable(unittest_journald_logger test_journald_logger.cc) target_link_libraries(unittest_journald_logger ceph-common) add_ceph_unittest(unittest_journald_logger) -- 2.39.5