有一些构建系统,如Make,要求开发人员管理不同构建文件夹中的不同配置,并在文件夹之间切换以更改配置。上面描述的文件是conan_gcc.yml文件,它定义了一个Conan工作区,该工作区适用于MinGW/Unix Makefiles gcc环境的基于CMake的项目 (适用于apple-clang或clang会非常相似,如果不完全相同)。
    让我们使用它来安装此工作区:

    1. $ mkdir build_release && cd build_release
    2. $ conan workspace install ../conanws_gcc.yml --profile=my_profile

    在这里,我们假设您定义了my_profile配置文件,该配置文件将使用单配置构建系统 (如makefile)。该示例在Linux中使用gcc进行了测试,但是使用makefile使用apple-clang是相同的)。您应该看到如下内容:

    1. Configuration:
    2. [settings]
    3. ...
    4. build_type=Release
    5. compiler=gcc
    6. compiler.libcxx=libstdc++
    7. compiler.version=4.9
    8. ...
    9. Requirements
    10. chat/0.1@user/testing from user folder - Editable
    11. hello/0.1@user/testing from user folder - Editable
    12. say/0.1@user/testing from user folder - Editable
    13. Packages
    14. chat/0.1@user/testing:df2c4f4725219597d44b7eab2ea5c8680abd57f9 - Editable
    15. hello/0.1@user/testing:b0e473ad8697d6069797b921517d628bba8b5901 - Editable
    16. say/0.1@user/testing:80faec7955dcba29246085ff8d64a765db3b414f - Editable
    17. say/0.1@user/testing: Generator cmake created conanbuildinfo.cmake
    18. ...
    19. hello/0.1@user/testing: Generator cmake created conanbuildinfo.cmake
    20. ...
    21. chat/0.1@user/testing: Generator cmake created conanbuildinfo.cmake
    22. ...

    这些conanbuildinfo.cmake文件已在每个包构建/发布文件夹中创建,如布局文件所定义:

    1. # This helps to define the location of CMakeLists.txt within package
    2. [source_folder]
    3. src
    4. # This defines where the conanbuildinfo.cmake will be written to
    5. [build_folder]
    6. build/{{settings.build_type}}

    现在,我们可以像往常一样配置和构建我们的项目:

    1. $ cmake .. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release
    2. $ cmake --build . # or just $ make
    3. $ ../chat/build/Release/app
    4. Release: Hello World!
    5. Release: Hello World!
    6. Release: Hello World!

    现在,去改变一些包,例如 “说” 一个,然后重建。查看它如何进行增量构建 (快速)。
    请注意,本地缓存中不会真正安装任何内容,所有依赖项均在本地解析:

    1. $ conan search say
    2. There are no packages matching the 'say' pattern

    为调试模式构建在其自己的文件夹中完成:

    1. $ cd .. && mkdir build_debug && cd build_debug
    2. $ conan workspace install ../conanws_gcc.yml --profile=my_gcc_profile -s build_type=Debug
    3. $ cmake .. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug
    4. $ cmake --build . # or just $ make
    5. $ ../chat/build/Debug/app
    6. Debug: Bye World!
    7. Debug: Bye World!
    8. Debug: Bye World!