我正在尝试将仅包含 header 的库转换为 block 。该库已经使用 CMake 并包含测试和示例程序。我已经阅读了 biicode 文档,但不清楚如何为现有项目创建 block 。我很困惑是否应该执行 bii init -L
或 bii cpp:configure
。我尝试在 biicode.conf 中将 Boost 指定为要求,但得到 WARN: Removing unused reference to "biicode/boost: 0"
请告诉我为现有项目创建区 block 的步骤,谢谢。
最佳答案
您应该开始使用库文件夹中的 bii init -L
。然后,following this steps on the docs , 使用 bii deps
命令检查未解析的依赖项,调整 biicode.conf 文件(如果需要),并添加外部依赖项。
同时调整您当前的 CMakeLists.txt :
IF(BIICODE)
INCLUDE("biicode.cmake")
RETURN()
ENDIF()
biicode.cmake 文件中至少应包含 ADD_BII_TARGETS()
,因为您依赖于 Boost,您的应该类似于下面的代码,here's a guide explaining how depend on Boost .
#Include the biicode Boost setup script
include(biicode/boost/setup)
ADD_BII_TARGETS()
#Setup Boost and build (if needed) the required Boost components
#Since lambda is header-only, there are no components to build and find
bii_find_boost()
#Add Boost headers to the block include directories
target_include_directories(${BII_BLOCK_TARGET} INTERFACE ${Boost_INCLUDE_DIRS})
运行 bii find
检索依赖关系,运行 bii configure
将其配置为您当前的配置并使用 bii build
构建。检查common issues building in the docs here .
对于使用 boost 的问题 - biicode has a boost repository in github .
关于c++ - 为仅包含标题的库创建 block ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29988398/