工作区在yaml文件中定义,并使用任何用户定义的名称。其结构为:

    1. editables:
    2. say/0.1@user/testing:
    3. path: say
    4. hello/0.1@user/testing:
    5. path: hello
    6. chat/0.1@user/testing:
    7. path: chat
    8. layout: layout_gcc
    9. workspace_generator: cmake
    10. root: chat/0.1@user/testing

    第一部分 “可编辑” 定义了包引用和相对路径之间的映射。每一个都相当于一个柯南可编辑的add命令 (不要这样做 — 这不是必须的。稍后会自动完成。只是为了了解行为):

    1. $ conan editable add say say/0.1@user/testing --layout=layout_gcc
    2. $ conan editable add hello hello/0.1@user/testing --layout=layout_gcc
    3. $ conan editable add chat chat/0.1@user/testing --layout=layout_gcc

    主要区别在于,此可编辑状态仅是此工作区的临时状态。它不会影响其他项目或包,这些项目或包仍然可以使用本地缓存中的这些聊天包。
    请注意,工作区中的布局: 布局 _ gcc声明会影响所有包。还可以为每个包定义不同的布局,如下所示:

    1. editables:
    2. say/0.1@user/testing:
    3. path: say
    4. layout: custom_say_layout

    布局文件在可编辑布局文件和 “可编辑模式” 部分中的包中进行了说明。
    Workspace_生成器定义将为top项目生成的文件。到目前为止,唯一支持的值是cmake,它将生成一个conanworkspace.cmake文件,如下所示:

    1. set(PACKAGE_say_SRC "<path>/examples/workspace/cmake/say/src")
    2. set(PACKAGE_say_BUILD "<path>/examples/workspace/cmake/say/build/Debug")
    3. set(PACKAGE_hello_SRC "<path>/examples/workspace/cmake/hello/src")
    4. set(PACKAGE_hello_BUILD "<path>/examples/workspace/cmake/hello/build/Debug")
    5. set(PACKAGE_chat_SRC "<path>/examples/workspace/cmake/chat/src")
    6. set(PACKAGE_chat_BUILD "<path>/examples/workspace/cmake/chat/build/Debug")
    7. macro(conan_workspace_subdirectories)
    8. add_subdirectory(${PACKAGE_say_SRC} ${PACKAGE_say_BUILD})
    9. add_subdirectory(${PACKAGE_hello_SRC} ${PACKAGE_hello_BUILD})
    10. add_subdirectory(${PACKAGE_chat_SRC} ${PACKAGE_chat_BUILD})
    11. endmacro()

    此文件可以包含在用户定义的CMakeLists.txt中 (此文件不会生成)。在此,您可以看到此项目中使用的CMakeLists.txt:

    1. cmake_minimum_required(VERSION 3.0)
    2. project(WorkspaceProject)
    3. include(${CMAKE_BINARY_DIR}/conanworkspace.cmake)
    4. conan_workspace_subdirectories()


    根: chat/0.1 @ user/test定义图形的使用者节点,通常是某种可执行文件。您可以提供以逗号分隔的引用列表 (以字符串形式) 或yaml列表 (以yaml项缩写或完整)。所有根节点都在同一个依赖关系图中,如果它们依赖于同一个库的不同版本,就会导致冲突,就像在任何其他Conan命令中一样。

    1. editables:
    2. say/0.1@user/testing:
    3. path: say
    4. hello/0.1@user/testing:
    5. path: hello
    6. chat/0.1@user/testing:
    7. path: chat
    8. root: chat/0.1@user/testing, say/0.1@user/testing
    9. # or
    10. root: ["helloa/0.1@lasote/stable", "hellob/0.1@lasote/stable"]
    11. # or
    12. root:
    13. - helloa/0.1@lasote/stable
    14. - hellob/0.1@lasote/stable