# 自动收集当前目录下的所有 .cpp 文件
file(GLOB COMMON_SOURCES *.cpp)

if (NOT COMMON_SOURCES)
    message(WARNING "No source files found in src/common, generating a dummy source file.")
    file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/dummy.cpp "void dummy_common() {}")
    set(COMMON_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/dummy.cpp)
endif()

# 创建 common 库
add_library(common STATIC ${COMMON_SOURCES})

if(MSVC)
    target_compile_options(common PRIVATE /bigobj)
endif()

# 头文件目录
target_include_directories(common PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

# 如果 common 中需要使用 msgpack 或 boost，也可以链接对应的 INTERFACE 库：
target_link_libraries(common PUBLIC boost msgpack spdlog)