From 85a3c63644c67d113d1d3c79d96a98b3ab7db810 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Fri, 27 Jul 2018 16:03:58 +0800 Subject: [PATCH] cmake: extract common,msg out of src/CMakeLists.txt * add arch as a static library. * add crc32 as a static library. its only dependency is libarch. Signed-off-by: Kefu Chai --- src/CMakeLists.txt | 288 +++----------------------------------- src/arch/CMakeLists.txt | 12 ++ src/auth/CMakeLists.txt | 16 +++ src/common/CMakeLists.txt | 182 ++++++++++++++++++++++++ src/crush/CMakeLists.txt | 11 ++ src/msg/CMakeLists.txt | 68 +++++++++ 6 files changed, 308 insertions(+), 269 deletions(-) create mode 100644 src/arch/CMakeLists.txt create mode 100644 src/auth/CMakeLists.txt create mode 100644 src/common/CMakeLists.txt create mode 100644 src/crush/CMakeLists.txt create mode 100644 src/msg/CMakeLists.txt diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e6cbc300c8e14..ef1d8a10712b5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -313,21 +313,6 @@ configure_file( ${CMAKE_BINARY_DIR}/src/include/ceph_ver.h @ONLY) -set(auth_files - auth/AuthAuthorizeHandler.cc - auth/AuthClientHandler.cc - auth/AuthSessionHandler.cc - auth/AuthMethodList.cc - auth/cephx/CephxAuthorizeHandler.cc - auth/cephx/CephxClientHandler.cc - auth/cephx/CephxProtocol.cc - auth/cephx/CephxSessionHandler.cc - auth/none/AuthNoneAuthorizeHandler.cc - auth/unknown/AuthUnknownAuthorizeHandler.cc - auth/Crypto.cc - auth/KeyRing.cc - auth/RotatingKeyRing.cc) - set(mds_files) list(APPEND mds_files mds/MDSMap.cc @@ -337,18 +322,6 @@ list(APPEND mds_files mds/mdstypes.cc mds/flock.cc) -set(crush_srcs - crush/builder.c - crush/mapper.c - crush/crush.c - crush/hash.c - crush/CrushWrapper.cc - crush/CrushCompiler.cc - crush/CrushTester.cc - crush/CrushLocation.cc) - -add_library(crush_objs OBJECT ${crush_srcs}) - add_subdirectory(json_spirit) include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/src/xxHash") @@ -384,238 +357,42 @@ if(WITH_SEASTAR) add_subdirectory(crimson) endif() -set(xio_common_srcs) -if(HAVE_XIO) - list(APPEND xio_common_srcs - msg/xio/XioConnection.cc - msg/xio/XioMsg.cc - msg/xio/XioPool.cc - msg/xio/XioMessenger.cc - msg/xio/XioPortal.cc) -endif(HAVE_XIO) - -set(async_rdma_common_srcs) -if(HAVE_RDMA) - list(APPEND async_rdma_common_srcs - msg/async/rdma/Infiniband.cc - msg/async/rdma/RDMAConnectedSocketImpl.cc - msg/async/rdma/RDMAIWARPConnectedSocketImpl.cc - msg/async/rdma/RDMAServerSocketImpl.cc - msg/async/rdma/RDMAIWARPServerSocketImpl.cc - msg/async/rdma/RDMAStack.cc) -endif() - -add_library(common_buffer_obj OBJECT - common/buffer.cc) - -add_library(common_texttable_obj OBJECT - common/TextTable.cc) - set(libcommon_files ${CMAKE_BINARY_DIR}/src/include/ceph_ver.h ceph_ver.c - common/AsyncOpTracker.cc - common/DecayCounter.cc - common/LogClient.cc - common/LogEntry.cc - common/PrebufferedStreambuf.cc - common/CachedPrebufferedStreambuf.cc - common/BackTrace.cc - common/perf_counters.cc - common/perf_histogram.cc - common/mutex_debug.cc - common/Mutex.cc - common/OutputDataSocket.cc - common/admin_socket.cc - common/admin_socket_client.cc - common/bloom_filter.cc - common/Readahead.cc - common/cmdparse.cc - common/escape.cc - common/url_escape.cc - common/io_priority.cc - common/ceph_time.cc - common/mempool.cc - common/Throttle.cc - common/Timer.cc - common/Finisher.cc - common/environment.cc - common/sctp_crc32.c - common/crc32c.cc - common/crc32c_intel_baseline.c xxHash/xxhash.c - common/assert.cc - common/run_cmd.cc - common/WorkQueue.cc - common/ConfUtils.cc - common/fd.cc - common/xattr.c - common/str_list.cc - common/str_map.cc - common/snap_types.cc - common/errno.cc - common/TrackedOp.cc - common/SloppyCRCMap.cc - common/types.cc - common/iso_8601.cc log/Log.cc mon/MonCap.cc mon/MonClient.cc mon/MonMap.cc mgr/MgrClient.cc - msg/simple/Accepter.cc - msg/DispatchQueue.cc - msg/Message.cc mgr/ServiceMap.cc osd/ECMsgTypes.cc osd/HitSet.cc - common/RefCountedObj.cc - msg/Messenger.cc - msg/simple/Pipe.cc - msg/simple/PipeConnection.cc - msg/simple/SimpleMessenger.cc - msg/async/AsyncConnection.cc - msg/async/AsyncMessenger.cc - msg/async/Event.cc - msg/async/EventSelect.cc - msg/async/Stack.cc - msg/async/PosixStack.cc - msg/async/net_handler.cc - msg/QueueStrategy.cc - ${xio_common_srcs} - ${async_rdma_common_srcs} - msg/msg_types.cc - common/reverse.c - common/hobject.cc osd/OSDMap.cc osd/OSDMapMapping.cc - common/histogram.cc osd/osd_types.cc osd/PGPeeringEvent.cc osd/OpRequest.cc - common/blkdev.cc - common/common_init.cc - common/pipe.c - common/ceph_argparse.cc - common/ceph_context.cc - common/code_environment.cc - common/dout.cc - common/signal.cc - common/Thread.cc - common/Formatter.cc - common/HTMLFormatter.cc - common/HeartbeatMap.cc - common/PluginRegistry.cc - common/ceph_fs.cc - common/ceph_hash.cc - common/ceph_strings.cc - common/ceph_frag.cc - common/options.cc - common/config.cc - common/config_values.cc - common/utf8.c - common/mime.c - common/strtol.cc - common/page.cc - common/lockdep.cc - common/version.cc - common/hex.cc - common/entity_name.cc - common/ceph_crypto.cc - common/ceph_crypto_cms.cc - common/ceph_json.cc - common/ipaddr.cc - common/pick_address.cc - common/address_helper.cc - common/linux_version.c - common/TracepointProvider.cc - common/Cycles.cc - common/scrub_types.cc - common/bit_str.cc osdc/Striper.cc osdc/Objecter.cc - common/compat.cc - common/Graylog.cc - common/fs_types.cc - common/dns_resolve.cc - common/hostname.cc - common/util.cc - common/PriorityCache.cc - common/SubProcess.cc librbd/Features.cc - arch/probe.cc - ${auth_files} ${mds_files}) +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}) CHECK_C_COMPILER_FLAG("-fvar-tracking-assignments" HAS_VTA) -if(HAS_VTA) - set_source_files_properties( - common/config.cc - common/options.cc - PROPERTIES COMPILE_FLAGS -fno-var-tracking-assignments) -endif() - -if(FREEBSD) - list(APPEND libcommon_files common/freebsd_errno.cc) -elseif(APPLE) - list(APPEND libcommon_files common/darwin_errno.cc) -elseif(SUN) - list(APPEND libcommon_files common/solaris_errno.cc) -elseif(AIX) - list(APPEND libcommon_files common/aix_errno.cc) -endif() - -if(HAVE_ARM) - list(APPEND libcommon_files arch/arm.c) -elseif(HAVE_INTEL) - list(APPEND libcommon_files arch/intel.c) -elseif(HAVE_POWER8) - list(APPEND libcommon_files arch/ppc.c) -endif() - -if(HAVE_INTEL) - list(APPEND libcommon_files - common/crc32c_intel_fast.c) - if(HAVE_GOOD_YASM_ELF64) - list(APPEND libcommon_files - common/crc32c_intel_fast_asm.s - common/crc32c_intel_fast_zero_asm.s) - endif(HAVE_GOOD_YASM_ELF64) -elseif(HAVE_POWER8) - list(APPEND libcommon_files - common/crc32c_ppc.c) - if(HAVE_PPC64LE) - list(APPEND libcommon_files - common/crc32c_ppc_asm.S - common/crc32c_ppc_fast_zero_asm.S) - endif(HAVE_PPC64LE) -endif(HAVE_INTEL) - -if(LINUX) - list(APPEND libcommon_files msg/async/EventEpoll.cc) - message(STATUS " Using EventEpoll for events.") -elseif(FREEBSD OR APPLE) - list(APPEND libcommon_files msg/async/EventKqueue.cc) - message(STATUS " Using EventKqueue for events.") -endif(LINUX) - -if(WITH_LTTNG AND WITH_EVENTTRACE) - message(STATUS " Using EventTrace class.") - add_definitions("-DWITH_EVENTTRACE") - list(APPEND libcommon_files common/EventTrace.cc) -endif() - -set(common_mountcephfs_files - common/armor.c - common/safe_io.c - common/module.c - common/addr_parsing.c) -add_library(common_mountcephfs_objs OBJECT - ${common_mountcephfs_files}) - -add_library(common-objs OBJECT ${libcommon_files}) +add_subdirectory(auth) +add_subdirectory(common) +add_subdirectory(crush) +add_subdirectory(msg) +add_subdirectory(arch) set(ceph_common_objs + $ + $ + $ $ $ $ @@ -624,7 +401,8 @@ set(ceph_common_objs $ $) set(ceph_common_deps - json_spirit erasure_code ${LIB_RESOLV} + json_spirit erasure_code arch crc32 + ${LIB_RESOLV} Boost::thread Boost::system Boost::random @@ -640,49 +418,30 @@ set(ceph_common_deps if(HAVE_UDEV) list(APPEND ceph_common_deps ${UDEV_LIBRARIES}) endif() + if(HAVE_VERBS) list(APPEND ceph_common_deps IBVerbs::verbs) endif() + if(HAVE_RDMACM) list(APPEND ceph_common_deps RDMA::RDMAcm) endif() + if(NOT WITH_SYSTEM_BOOST) list(APPEND ceph_common_deps ${ZLIB_LIBRARIES}) endif() + if(HAVE_QATZIP) list(APPEND ceph_common_deps ${QATZIP_LIBRARIES}) endif() -set_source_files_properties(${CMAKE_SOURCE_DIR}/src/ceph_ver.c - ${CMAKE_SOURCE_DIR}/src/common/version.cc - APPEND PROPERTY OBJECT_DEPENDS ${CMAKE_BINARY_DIR}/src/include/ceph_ver.h) - if(HAVE_ARMV8_CRC) - add_library(common_crc_aarch64 STATIC common/crc32c_aarch64.c) - set_target_properties(common_crc_aarch64 PROPERTIES COMPILE_FLAGS "${CMAKE_C_FLAGS} ${ARMV8_CRC_COMPILE_FLAGS}") list(APPEND ceph_common_deps common_crc_aarch64) -endif(HAVE_ARMV8_CRC) +endif() if(WITH_DPDK) - list(APPEND common_async_dpdk_files - msg/async/dpdk/ARP.cc - msg/async/dpdk/DPDK.cc - msg/async/dpdk/dpdk_rte.cc - msg/async/dpdk/DPDKStack.cc - msg/async/dpdk/EventDPDK.cc - msg/async/dpdk/IP.cc - msg/async/dpdk/net.cc - msg/async/dpdk/IPChecksum.cc - msg/async/dpdk/Packet.cc - msg/async/dpdk/TCP.cc - msg/async/dpdk/UserspaceEvent.cc - msg/async/dpdk/ethernet.cc) - add_library(common_async_dpdk STATIC - ${common_async_dpdk_files}) list(APPEND ceph_common_deps common_async_dpdk) - target_link_libraries(common_async_dpdk - ${DPDK_LIBRARIES}) -endif(WITH_DPDK) +endif() add_library(common STATIC ${ceph_common_objs}) target_link_libraries(common @@ -708,8 +467,6 @@ if(WITH_STATIC_LIBSTDCXX) endif() install(TARGETS ceph-common DESTINATION ${CMAKE_INSTALL_PKGLIBDIR}) -add_library(common_utf8 STATIC common/utf8.c) - if(${WITH_LTTNG}) add_subdirectory(tracing) add_dependencies(common-objs oprequest-tp) @@ -912,13 +669,6 @@ install(PROGRAMS DESTINATION sbin) add_subdirectory(bash_completion) - -if(WITH_LIBCEPHFS OR WITH_KRBD) - set(parse_secret_files - common/secret.c) - add_library(parse_secret_objs OBJECT ${parse_secret_files}) -endif() - add_subdirectory(client) if(WITH_LIBCEPHFS) diff --git a/src/arch/CMakeLists.txt b/src/arch/CMakeLists.txt new file mode 100644 index 0000000000000..b238628547a51 --- /dev/null +++ b/src/arch/CMakeLists.txt @@ -0,0 +1,12 @@ +set(arch_srcs + probe.cc) + +if(HAVE_ARM) + list(APPEND arch_srcs arm.c) +elseif(HAVE_INTEL) + list(APPEND arch_srcs intel.c) +elseif(HAVE_POWER8) + list(APPEND arch_srcs ppc.c) +endif() + +add_library(arch STATIC ${arch_srcs}) diff --git a/src/auth/CMakeLists.txt b/src/auth/CMakeLists.txt new file mode 100644 index 0000000000000..113a956193cf6 --- /dev/null +++ b/src/auth/CMakeLists.txt @@ -0,0 +1,16 @@ +set(auth_srcs + AuthAuthorizeHandler.cc + AuthClientHandler.cc + AuthMethodList.cc + AuthSessionHandler.cc + Crypto.cc + KeyRing.cc + RotatingKeyRing.cc + cephx/CephxAuthorizeHandler.cc + cephx/CephxClientHandler.cc + cephx/CephxProtocol.cc + cephx/CephxSessionHandler.cc + none/AuthNoneAuthorizeHandler.cc + unknown/AuthUnknownAuthorizeHandler.cc) + +add_library(common-auth-objs OBJECT ${auth_srcs}) diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt new file mode 100644 index 0000000000000..c8c3567a0ebf9 --- /dev/null +++ b/src/common/CMakeLists.txt @@ -0,0 +1,182 @@ +add_library(common_buffer_obj OBJECT + buffer.cc) + +add_library(common_texttable_obj OBJECT + TextTable.cc) + +set(common_srcs + AsyncOpTracker.cc + BackTrace.cc + CachedPrebufferedStreambuf.cc + ConfUtils.cc + Cycles.cc + DecayCounter.cc + Finisher.cc + Formatter.cc + Graylog.cc + HTMLFormatter.cc + HeartbeatMap.cc + LogClient.cc + LogEntry.cc + Mutex.cc + OutputDataSocket.cc + PluginRegistry.cc + PrebufferedStreambuf.cc + PriorityCache.cc + Readahead.cc + RefCountedObj.cc + SloppyCRCMap.cc + SubProcess.cc + Thread.cc + Throttle.cc + Timer.cc + TracepointProvider.cc + TrackedOp.cc + WorkQueue.cc + address_helper.cc + admin_socket.cc + admin_socket_client.cc + assert.cc + bit_str.cc + blkdev.cc + bloom_filter.cc + ceph_argparse.cc + ceph_context.cc + ceph_crypto.cc + ceph_crypto_cms.cc + ceph_frag.cc + ceph_fs.cc + ceph_hash.cc + ceph_json.cc + ceph_strings.cc + ceph_time.cc + cmdparse.cc + code_environment.cc + common_init.cc + compat.cc + config.cc + config_values.cc + dns_resolve.cc + dout.cc + entity_name.cc + environment.cc + errno.cc + escape.cc + fd.cc + fs_types.cc + hex.cc + histogram.cc + hobject.cc + hostname.cc + io_priority.cc + ipaddr.cc + iso_8601.cc + linux_version.c + lockdep.cc + mempool.cc + mime.c + mutex_debug.cc + options.cc + page.cc + perf_counters.cc + perf_histogram.cc + pick_address.cc + pipe.c + reverse.c + run_cmd.cc + scrub_types.cc + signal.cc + snap_types.cc + str_list.cc + str_map.cc + strtol.cc + types.cc + url_escape.cc + utf8.c + util.cc + version.cc + xattr.c) + +set_source_files_properties(${CMAKE_SOURCE_DIR}/src/common/version.cc + APPEND PROPERTY OBJECT_DEPENDS ${CMAKE_BINARY_DIR}/src/include/ceph_ver.h) + +if(HAS_VTA) + set_source_files_properties( + config.cc + options.cc + PROPERTIES COMPILE_FLAGS -fno-var-tracking-assignments) +endif() + +if(FREEBSD) + list(APPEND common_srcs freebsd_errno.cc) +elseif(APPLE) + list(APPEND common_srcs darwin_errno.cc) +elseif(SUN) + list(APPEND common_srcs solaris_errno.cc) +elseif(AIX) + list(APPEND common_srcs aix_errno.cc) +endif() + +if(WITH_LTTNG AND WITH_EVENTTRACE) + message(STATUS " Using EventTrace class.") + add_definitions("-DWITH_EVENTTRACE") + list(APPEND common_srcs EventTrace.cc) +endif() + +add_library(common-common-objs OBJECT + ${common_srcs}) +# for options.cc +target_compile_definitions(common-common-objs PRIVATE + "-DCEPH_LIBDIR=\"${CMAKE_INSTALL_FULL_LIBDIR}\"" + "-DCEPH_PKGLIBDIR=\"${CMAKE_INSTALL_FULL_PKGLIBDIR}\"") + +set(common_mountcephfs_srcs + armor.c + safe_io.c + module.c + addr_parsing.c) +add_library(common_mountcephfs_objs OBJECT + ${common_mountcephfs_srcs}) + + +set(crc32_srcs + crc32c.cc + crc32c_intel_baseline.c + sctp_crc32.c) + +if(HAVE_INTEL) + list(APPEND crc32_srcs + crc32c_intel_fast.c) + if(HAVE_GOOD_YASM_ELF64) + list(APPEND crc32_srcs + crc32c_intel_fast_asm.s + crc32c_intel_fast_zero_asm.s) + endif(HAVE_GOOD_YASM_ELF64) +elseif(HAVE_POWER8) + list(APPEND crc32_srcs + crc32c_ppc.c) + if(HAVE_PPC64LE) + list(APPEND crc32_srcs + crc32c_ppc_asm.S + crc32c_ppc_fast_zero_asm.S) + endif(HAVE_PPC64LE) +elseif(HAVE_ARMV8_CRC) + list(APPEND crc32_srcs + crc32c_aarch64.c) +endif(HAVE_INTEL) + +add_library(crc32 ${crc32_srcs}) +if(HAVE_ARMV8_CRC) + set_target_properties(crc32 PROPERTIES + COMPILE_FLAGS "${CMAKE_C_FLAGS} ${ARMV8_CRC_COMPILE_FLAGS}") +endif() +target_link_libraries(crc32 + arch) + +add_library(common_utf8 STATIC utf8.c) + +if(WITH_LIBCEPHFS OR WITH_KRBD) + set(parse_secret_srcs + secret.c) + add_library(parse_secret_objs OBJECT ${parse_secret_srcs}) +endif() diff --git a/src/crush/CMakeLists.txt b/src/crush/CMakeLists.txt new file mode 100644 index 0000000000000..1c875d5947473 --- /dev/null +++ b/src/crush/CMakeLists.txt @@ -0,0 +1,11 @@ +set(crush_srcs + builder.c + mapper.c + crush.c + hash.c + CrushWrapper.cc + CrushCompiler.cc + CrushTester.cc + CrushLocation.cc) + +add_library(crush_objs OBJECT ${crush_srcs}) diff --git a/src/msg/CMakeLists.txt b/src/msg/CMakeLists.txt new file mode 100644 index 0000000000000..092d389b22c60 --- /dev/null +++ b/src/msg/CMakeLists.txt @@ -0,0 +1,68 @@ +set(msg_srcs + DispatchQueue.cc + Message.cc + Messenger.cc + QueueStrategy.cc + msg_types.cc + simple/Accepter.cc + simple/Pipe.cc + simple/PipeConnection.cc + simple/SimpleMessenger.cc) + +if(HAVE_XIO) + list(APPEND msg_srcs + xio/XioConnection.cc + xio/XioMsg.cc + xio/XioPool.cc + xio/XioMessenger.cc + xio/XioPortal.cc) +endif(HAVE_XIO) + +list(APPEND msg_srcs + async/AsyncConnection.cc + async/AsyncMessenger.cc + async/Event.cc + async/EventSelect.cc + async/PosixStack.cc + async/Stack.cc + async/net_handler.cc) + +if(LINUX) + list(APPEND msg_srcs + async/EventEpoll.cc) +elseif(FREEBSD OR APPLE) + list(APPEND msg_srcs + async/EventKqueue.cc) +endif(LINUX) + +if(HAVE_RDMA) + list(APPEND msg_srcs + async/rdma/Infiniband.cc + async/rdma/RDMAConnectedSocketImpl.cc + async/rdma/RDMAIWARPConnectedSocketImpl.cc + async/rdma/RDMAServerSocketImpl.cc + async/rdma/RDMAIWARPServerSocketImpl.cc + async/rdma/RDMAStack.cc) +endif() + +add_library(common-msg-objs OBJECT ${msg_srcs}) + +if(WITH_DPDK) + set(async_dpdk_srcs + async/dpdk/ARP.cc + async/dpdk/DPDK.cc + async/dpdk/dpdk_rte.cc + async/dpdk/DPDKStack.cc + async/dpdk/EventDPDK.cc + async/dpdk/IP.cc + async/dpdk/net.cc + async/dpdk/IPChecksum.cc + async/dpdk/Packet.cc + async/dpdk/TCP.cc + async/dpdk/UserspaceEvent.cc + async/dpdk/ethernet.cc) + add_library(common_async_dpdk STATIC + ${async_dpdk_srcs}) + target_link_libraries(common_async_dpdk + ${DPDK_LIBRARIES}) +endif(WITH_DPDK) -- 2.39.5