]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake: modularize os/CMakeLists.txt
authorKefu Chai <tchaikov@gmail.com>
Tue, 17 Jun 2025 07:33:56 +0000 (15:33 +0800)
committerKefu Chai <tchaikov@gmail.com>
Wed, 18 Jun 2025 03:26:32 +0000 (11:26 +0800)
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 <tchaikov@gmail.com>
src/os/CMakeLists.txt
src/os/bluestore/CMakeLists.txt [new file with mode: 0644]
src/os/fs/CMakeLists.txt [new file with mode: 0644]
src/os/kstore/CMakeLists.txt [new file with mode: 0644]
src/os/memstore/CMakeLists.txt [new file with mode: 0644]

index af65d6a7f711e0f1c5645905721563e94ba127cc..9510797401319c8af47efc427fb66c3cdeb159ad 100644 (file)
@@ -1,91 +1,53 @@
-set(libos_srcs
+add_library(os STATIC
   ObjectStore.cc
-  Transaction.cc
-  memstore/MemStore.cc
-  kstore/KStore.cc
-  kstore/kstore_types.cc
-  fs/FS.cc)
+  Transaction.cc)
 
-if(WITH_BLUESTORE)
-  list(APPEND libos_srcs
-    bluestore/Allocator.cc
-    bluestore/AllocatorBase.cc
-    bluestore/BitmapFreelistManager.cc
-    bluestore/BlueFS.cc
-    bluestore/bluefs_types.cc
-    bluestore/BlueRocksEnv.cc
-    bluestore/BlueStore.cc
-    bluestore/BlueStore_debug.cc
-    bluestore/simple_bitmap.cc
-    bluestore/bluestore_types.cc
-    bluestore/fastbmap_allocator_impl.cc
-    bluestore/FreelistManager.cc
-    bluestore/StupidAllocator.cc
-    bluestore/BitmapAllocator.cc
-    bluestore/AvlAllocator.cc
-    bluestore/BtreeAllocator.cc
-    bluestore/Btree2Allocator.cc
-    bluestore/HybridAllocator.cc
-    bluestore/Writer.cc
-    bluestore/Compression.cc
-    bluestore/BlueAdmin.cc
-    bluestore/BlueEnv.cc
-  )
-endif(WITH_BLUESTORE)
-
-if(WITH_FUSE)
-  list(APPEND libos_srcs
-    FuseStore.cc)
-endif(WITH_FUSE)
-
-if(HAVE_LIBXFS)
-  list(APPEND libos_srcs
-    fs/XFS.cc)
-endif()
+target_link_libraries(os
+  PRIVATE
+    legacy-option-headers
+    ${FMT_LIB})
 
-add_library(os STATIC ${libos_srcs})
+add_subdirectory(memstore)
 target_link_libraries(os
-  legacy-option-headers
-  blk
-  ${FMT_LIB})
+  PRIVATE memstore)
 
-target_compile_definitions(os PRIVATE -DWITH_KSTORE)
-target_link_libraries(os heap_profiler kv)
+add_subdirectory(kstore)
+target_link_libraries(os
+  PRIVATE
+    kstore)
 
-if(WITH_BLUEFS)
-  add_library(bluefs SHARED 
-    bluestore/BlueRocksEnv.cc)
-  target_include_directories(bluefs SYSTEM PUBLIC
-    $<TARGET_PROPERTY:RocksDB::RocksDB,INTERFACE_INCLUDE_DIRECTORIES>)
-  target_link_libraries(bluefs global)
-  install(TARGETS bluefs DESTINATION lib)
-endif(WITH_BLUEFS)
+if(WITH_BLUESTORE)
+  add_subdirectory(bluestore)
+  target_link_libraries(os
+    PRIVATE bluestore)
+endif()
 
 if(WITH_FUSE)
-  target_link_libraries(os FUSE::FUSE)
+  add_library(fusestore
+    FuseStore.cc)
+  target_link_libraries(fusestore
+    PRIVATE FUSE::FUSE)
+  target_link_libraries(os
+    PRIVATE fusestore)
 endif()
 
 if(WITH_LTTNG)
   add_dependencies(os objectstore-tp)
-  add_dependencies(os bluestore-tp)
 endif()
 
 if(WITH_JAEGER)
   add_dependencies(os jaeger_base)
-  target_link_libraries(os jaeger_base)
+  target_link_libraries(os
+    PRIVATE jaeger_base)
 endif()
 
-target_link_libraries(os kv)
-
-add_dependencies(os compressor_plugins)
 add_dependencies(os crypto_plugins)
 
-
 if(WITH_BLUESTORE)
   add_executable(ceph-bluestore-tool
     bluestore/bluestore_tool.cc)
   target_link_libraries(ceph-bluestore-tool
-    os global)
+    global kv os)
   install(TARGETS ceph-bluestore-tool
     DESTINATION bin)
 endif()
diff --git a/src/os/bluestore/CMakeLists.txt b/src/os/bluestore/CMakeLists.txt
new file mode 100644 (file)
index 0000000..3ae5cd9
--- /dev/null
@@ -0,0 +1,41 @@
+add_library(bluestore OBJECT
+  Allocator.cc
+  AllocatorBase.cc
+  BitmapFreelistManager.cc
+  BlueFS.cc
+  bluefs_types.cc
+  BlueRocksEnv.cc
+  BlueStore.cc
+  BlueStore_debug.cc
+  simple_bitmap.cc
+  bluestore_types.cc
+  fastbmap_allocator_impl.cc
+  FreelistManager.cc
+  StupidAllocator.cc
+  BitmapAllocator.cc
+  AvlAllocator.cc
+  BtreeAllocator.cc
+  Btree2Allocator.cc
+  HybridAllocator.cc
+  Writer.cc
+  Compression.cc
+  BlueAdmin.cc
+  BlueEnv.cc)
+
+target_link_libraries(bluestore
+  PRIVATE
+    blk heap_profiler kv ${FMT_LIB})
+
+add_dependencies(bluestore compressor_plugins)
+if(WITH_LTTNG)
+  add_dependencies(bluestore bluestore-tp)
+endif()
+
+if(WITH_BLUEFS)
+  add_library(bluefs SHARED
+    BlueRocksEnv.cc)
+  target_include_directories(bluefs SYSTEM PUBLIC
+    $<TARGET_PROPERTY:RocksDB::RocksDB,INTERFACE_INCLUDE_DIRECTORIES>)
+  target_link_libraries(bluefs global)
+  install(TARGETS bluefs DESTINATION lib)
+endif()
diff --git a/src/os/fs/CMakeLists.txt b/src/os/fs/CMakeLists.txt
new file mode 100644 (file)
index 0000000..b35de7d
--- /dev/null
@@ -0,0 +1,7 @@
+set(fs_srcs
+  FS.cc)
+
+if(HAVE_LIBXFS)
+  list_(APPEND fs_srcs
+    XFS.cc)
+endif()
diff --git a/src/os/kstore/CMakeLists.txt b/src/os/kstore/CMakeLists.txt
new file mode 100644 (file)
index 0000000..e817d80
--- /dev/null
@@ -0,0 +1,7 @@
+add_library(kstore STATIC
+  KStore.cc
+  kstore_types.cc)
+target_compile_definitions(kstore
+  PUBLIC WITH_KSTORE)
+target_link_libraries(kstore
+  PUBLIC kv)
diff --git a/src/os/memstore/CMakeLists.txt b/src/os/memstore/CMakeLists.txt
new file mode 100644 (file)
index 0000000..1f7db6b
--- /dev/null
@@ -0,0 +1,2 @@
+add_library(memstore
+  MemStore.cc)