cpp-toolbox  0.0.1
A toolbox library for C++
Loading...
Searching...
No Matches
Building cpp-toolbox

主构建入口为 CMake 3.16+;xmake 2.7.0 为同步旁路。

CMake

默认构建全部模块。显式模块会自动补齐依赖闭包;未选模块不创建 target,也不编译其源码。

cmake -S . -B build/io \
-DCPP_TOOLBOX_BUILD_MODULES=io_formats \
-DBUILD_SHARED_LIBS=OFF
cmake --build build/io

BUILD_SHARED_LIBS=ON 与 OFF 必须使用不同 build tree。模块 target 为: cpp-toolbox::<module>,例如 cpp-toolbox::io_formats。

cmake -S . -B build/dev -Dcpp-toolbox_DEVELOPER_MODE=ON
cmake --build build/dev
ctest --test-dir build/dev --output-on-failure

xmake

xmake f --modules=io_formats --kind=static
xmake build cpp-toolbox-io_formats
xmake f --modules=io_formats --kind=shared
xmake build cpp-toolbox-io_formats

CMake 与 xmake 共读 modules/modules.manifest。modules 支持逗号列表或 all;kind 为 static 或 shared。

安装与 package

安装内容来自当前 configure 的模块闭包:

cmake --install build/io --prefix /opt/cpp-toolbox

消费端按模块请求:

find_package(cpp-toolbox CONFIG REQUIRED COMPONENTS io_formats)
target_link_libraries(app PRIVATE cpp-toolbox::io_formats)

安装组件仅用于 artifact 分类:cpp-toolbox-runtime、cpp-toolbox-static、cpp-toolbox-development。

公共头路径统一为 <cpp-toolbox/<module>/...>;旧 src/include、旧聚合库与旧 include 路径已删除。