Skip to content

Commit

Permalink
cmake: add crimson static library
Browse files Browse the repository at this point in the history
libcrimson consolidates the object library of crimson_{net,thread} and
seastar_{buffer,net,thread}_objs. by offering a static library glueing
seastar,  we can link against these libraries and its dependencies in a
simpler way.

Signed-off-by: Kefu Chai <[email protected]>
  • Loading branch information
tchaikov committed Jun 28, 2018
1 parent 28f079e commit eea41d4
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 54 deletions.
10 changes: 0 additions & 10 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -424,16 +424,6 @@ endif()
add_library(common_buffer_obj OBJECT
common/buffer.cc)

if(WITH_SEASTAR)
add_library(seastar_buffer_obj OBJECT common/buffer_seastar.cc)
# target_link_libraries() doesn't work for object libraries, so the
# Seastar properties are applied manually (and link is unnecessary)
target_compile_definitions(seastar_buffer_obj
PUBLIC $<TARGET_PROPERTY:Seastar::seastar,INTERFACE_COMPILE_DEFINITIONS>)
target_include_directories(seastar_buffer_obj
PUBLIC $<TARGET_PROPERTY:Seastar::seastar,INTERFACE_INCLUDE_DIRECTORIES>)
endif()

add_library(common_texttable_obj OBJECT
common/TextTable.cc)

Expand Down
15 changes: 13 additions & 2 deletions src/crimson/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
add_subdirectory(net)
add_subdirectory(thread)
set(crimson_net_srcs
net/Dispatcher.cc
net/Errors.cc
net/SocketConnection.cc
net/SocketMessenger.cc)
set(crimson_thread_srcs
thread/ThreadPool.cc
thread/Throttle.cc)
add_library(crimson STATIC
${crimson_net_srcs}
${crimson_thread_srcs}
${CMAKE_SOURCE_DIR}/src/common/buffer_seastar.cc)
target_link_libraries(crimson Seastar::seastar)
10 changes: 0 additions & 10 deletions src/crimson/net/CMakeLists.txt

This file was deleted.

8 changes: 0 additions & 8 deletions src/crimson/thread/CMakeLists.txt

This file was deleted.

35 changes: 11 additions & 24 deletions src/test/crimson/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,37 +1,24 @@
set(test_buffer_srcs
test_buffer.cc
$<TARGET_OBJECTS:seastar_buffer_obj>)
add_executable(unittest_seastar_buffer ${test_buffer_srcs})
add_executable(unittest_seastar_buffer
test_buffer.cc)
add_ceph_unittest(unittest_seastar_buffer)
target_link_libraries(unittest_seastar_buffer ceph-common Seastar::seastar)
target_link_libraries(unittest_seastar_buffer ceph-common crimson)

add_executable(unittest_seastar_denc
test_denc.cc
$<TARGET_OBJECTS:seastar_buffer_obj>
$<TARGET_OBJECTS:unit-main>)
add_ceph_unittest(unittest_seastar_denc)
target_link_libraries(unittest_seastar_denc ceph-common global Seastar::seastar)
target_link_libraries(unittest_seastar_denc ceph-common global crimson)

set(test_messenger_srcs
test_messenger.cc
$<TARGET_OBJECTS:seastar_buffer_obj>
$<TARGET_OBJECTS:crimson_net_objs>
$<TARGET_OBJECTS:crimson_thread_objs>)
add_executable(unittest_seastar_messenger ${test_messenger_srcs})
add_executable(unittest_seastar_messenger test_messenger.cc)
add_ceph_unittest(unittest_seastar_messenger)
target_link_libraries(unittest_seastar_messenger ceph-common Seastar::seastar)
target_link_libraries(unittest_seastar_messenger ceph-common crimson)

set(test_alien_echo_srcs
test_alien_echo.cc
$<TARGET_OBJECTS:seastar_buffer_obj>
$<TARGET_OBJECTS:crimson_net_objs>
$<TARGET_OBJECTS:crimson_thread_objs>)
add_executable(unittest_seastar_echo ${test_alien_echo_srcs})
add_executable(unittest_seastar_echo
test_alien_echo.cc)
add_ceph_unittest(unittest_seastar_echo)
target_link_libraries(unittest_seastar_echo ceph-common global Seastar::seastar)
target_link_libraries(unittest_seastar_echo ceph-common global crimson)

add_executable(unittest_seastar_thread_pool
test_thread_pool.cc
$<TARGET_OBJECTS:crimson_thread_objs>)
test_thread_pool.cc)
add_ceph_unittest(unittest_seastar_thread_pool)
target_link_libraries(unittest_seastar_thread_pool Seastar::seastar)
target_link_libraries(unittest_seastar_thread_pool crimson)

0 comments on commit eea41d4

Please sign in to comment.