Skip to content

Commit 5ab2e9f

Browse files
committed
cmake: modularize os/CMakeLists.txt
Split monolithic os target into per-store modules to improve build system organization and dependency management. Previously, the "os" target compiled all sources in the os/ directory as a single unit and linked against all dependencies collectively. Changes: - Break os/CMakeLists.txt into smaller, store-specific modules - Enable per-store compile options and dependency definitions - Make dependency relationships more explicit and granular This modularization improves build system maintainability and makes the codebase structure clearer for future development. Signed-off-by: Kefu Chai <[email protected]>
1 parent fb5294a commit 5ab2e9f

File tree

5 files changed

+83
-64
lines changed

5 files changed

+83
-64
lines changed

src/os/CMakeLists.txt

Lines changed: 26 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,53 @@
1-
set(libos_srcs
1+
add_library(os STATIC
22
ObjectStore.cc
3-
Transaction.cc
4-
memstore/MemStore.cc
5-
kstore/KStore.cc
6-
kstore/kstore_types.cc
7-
fs/FS.cc)
3+
Transaction.cc)
84

9-
if(WITH_BLUESTORE)
10-
list(APPEND libos_srcs
11-
bluestore/Allocator.cc
12-
bluestore/AllocatorBase.cc
13-
bluestore/BitmapFreelistManager.cc
14-
bluestore/BlueFS.cc
15-
bluestore/bluefs_types.cc
16-
bluestore/BlueRocksEnv.cc
17-
bluestore/BlueStore.cc
18-
bluestore/BlueStore_debug.cc
19-
bluestore/simple_bitmap.cc
20-
bluestore/bluestore_types.cc
21-
bluestore/fastbmap_allocator_impl.cc
22-
bluestore/FreelistManager.cc
23-
bluestore/StupidAllocator.cc
24-
bluestore/BitmapAllocator.cc
25-
bluestore/AvlAllocator.cc
26-
bluestore/BtreeAllocator.cc
27-
bluestore/Btree2Allocator.cc
28-
bluestore/HybridAllocator.cc
29-
bluestore/Writer.cc
30-
bluestore/Compression.cc
31-
bluestore/BlueAdmin.cc
32-
bluestore/BlueEnv.cc
33-
)
34-
endif(WITH_BLUESTORE)
35-
36-
if(WITH_FUSE)
37-
list(APPEND libos_srcs
38-
FuseStore.cc)
39-
endif(WITH_FUSE)
40-
41-
if(HAVE_LIBXFS)
42-
list(APPEND libos_srcs
43-
fs/XFS.cc)
44-
endif()
5+
target_link_libraries(os
6+
PRIVATE
7+
legacy-option-headers
8+
${FMT_LIB})
459

46-
add_library(os STATIC ${libos_srcs})
10+
add_subdirectory(memstore)
4711
target_link_libraries(os
48-
legacy-option-headers
49-
blk
50-
${FMT_LIB})
12+
PRIVATE memstore)
5113

52-
target_compile_definitions(os PRIVATE -DWITH_KSTORE)
53-
target_link_libraries(os heap_profiler kv)
14+
add_subdirectory(kstore)
15+
target_link_libraries(os
16+
PRIVATE
17+
kstore)
5418

55-
if(WITH_BLUEFS)
56-
add_library(bluefs SHARED
57-
bluestore/BlueRocksEnv.cc)
58-
target_include_directories(bluefs SYSTEM PUBLIC
59-
$<TARGET_PROPERTY:RocksDB::RocksDB,INTERFACE_INCLUDE_DIRECTORIES>)
60-
target_link_libraries(bluefs global)
61-
install(TARGETS bluefs DESTINATION lib)
62-
endif(WITH_BLUEFS)
19+
if(WITH_BLUESTORE)
20+
add_subdirectory(bluestore)
21+
target_link_libraries(os
22+
PRIVATE bluestore)
23+
endif()
6324

6425
if(WITH_FUSE)
65-
target_link_libraries(os FUSE::FUSE)
26+
add_library(fusestore
27+
FuseStore.cc)
28+
target_link_libraries(fusestore
29+
PRIVATE FUSE::FUSE)
30+
target_link_libraries(os
31+
PRIVATE fusestore)
6632
endif()
6733

6834
if(WITH_LTTNG)
6935
add_dependencies(os objectstore-tp)
70-
add_dependencies(os bluestore-tp)
7136
endif()
7237

7338
if(WITH_JAEGER)
7439
add_dependencies(os jaeger_base)
75-
target_link_libraries(os jaeger_base)
40+
target_link_libraries(os
41+
PRIVATE jaeger_base)
7642
endif()
7743

78-
target_link_libraries(os kv)
79-
80-
add_dependencies(os compressor_plugins)
8144
add_dependencies(os crypto_plugins)
8245

83-
8446
if(WITH_BLUESTORE)
8547
add_executable(ceph-bluestore-tool
8648
bluestore/bluestore_tool.cc)
8749
target_link_libraries(ceph-bluestore-tool
88-
os global)
50+
global kv os)
8951
install(TARGETS ceph-bluestore-tool
9052
DESTINATION bin)
9153
endif()

src/os/bluestore/CMakeLists.txt

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
add_library(bluestore OBJECT
2+
Allocator.cc
3+
AllocatorBase.cc
4+
BitmapFreelistManager.cc
5+
BlueFS.cc
6+
bluefs_types.cc
7+
BlueRocksEnv.cc
8+
BlueStore.cc
9+
BlueStore_debug.cc
10+
simple_bitmap.cc
11+
bluestore_types.cc
12+
fastbmap_allocator_impl.cc
13+
FreelistManager.cc
14+
StupidAllocator.cc
15+
BitmapAllocator.cc
16+
AvlAllocator.cc
17+
BtreeAllocator.cc
18+
Btree2Allocator.cc
19+
HybridAllocator.cc
20+
Writer.cc
21+
Compression.cc
22+
BlueAdmin.cc
23+
BlueEnv.cc)
24+
25+
target_link_libraries(bluestore
26+
PRIVATE
27+
blk heap_profiler kv ${FMT_LIB})
28+
29+
add_dependencies(bluestore compressor_plugins)
30+
if(WITH_LTTNG)
31+
add_dependencies(bluestore bluestore-tp)
32+
endif()
33+
34+
if(WITH_BLUEFS)
35+
add_library(bluefs SHARED
36+
BlueRocksEnv.cc)
37+
target_include_directories(bluefs SYSTEM PUBLIC
38+
$<TARGET_PROPERTY:RocksDB::RocksDB,INTERFACE_INCLUDE_DIRECTORIES>)
39+
target_link_libraries(bluefs global)
40+
install(TARGETS bluefs DESTINATION lib)
41+
endif()

src/os/fs/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
set(fs_srcs
2+
FS.cc)
3+
4+
if(HAVE_LIBXFS)
5+
list_(APPEND fs_srcs
6+
XFS.cc)
7+
endif()

src/os/kstore/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
add_library(kstore STATIC
2+
KStore.cc
3+
kstore_types.cc)
4+
target_compile_definitions(kstore
5+
PUBLIC WITH_KSTORE)
6+
target_link_libraries(kstore
7+
PUBLIC kv)

src/os/memstore/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
add_library(memstore
2+
MemStore.cc)

0 commit comments

Comments
 (0)