有一些构建系统,如Make,要求开发人员管理不同构建文件夹中的不同配置,并在文件夹之间切换以更改配置。上面描述的文件是conan_gcc.yml文件,它定义了一个Conan工作区,该工作区适用于MinGW/Unix Makefiles gcc环境的基于CMake的项目 (适用于apple-clang或clang会非常相似,如果不完全相同)。
让我们使用它来安装此工作区:
$ mkdir build_release && cd build_release
$ conan workspace install ../conanws_gcc.yml --profile=my_profile
在这里,我们假设您定义了my_profile配置文件,该配置文件将使用单配置构建系统 (如makefile)。该示例在Linux中使用gcc进行了测试,但是使用makefile使用apple-clang是相同的)。您应该看到如下内容:
Configuration:
[settings]
...
build_type=Release
compiler=gcc
compiler.libcxx=libstdc++
compiler.version=4.9
...
Requirements
chat/0.1@user/testing from user folder - Editable
hello/0.1@user/testing from user folder - Editable
say/0.1@user/testing from user folder - Editable
Packages
chat/0.1@user/testing:df2c4f4725219597d44b7eab2ea5c8680abd57f9 - Editable
hello/0.1@user/testing:b0e473ad8697d6069797b921517d628bba8b5901 - Editable
say/0.1@user/testing:80faec7955dcba29246085ff8d64a765db3b414f - Editable
say/0.1@user/testing: Generator cmake created conanbuildinfo.cmake
...
hello/0.1@user/testing: Generator cmake created conanbuildinfo.cmake
...
chat/0.1@user/testing: Generator cmake created conanbuildinfo.cmake
...
这些conanbuildinfo.cmake文件已在每个包构建/发布文件夹中创建,如布局文件所定义:
# This helps to define the location of CMakeLists.txt within package
[source_folder]
src
# This defines where the conanbuildinfo.cmake will be written to
[build_folder]
build/{{settings.build_type}}
现在,我们可以像往常一样配置和构建我们的项目:
$ cmake .. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release
$ cmake --build . # or just $ make
$ ../chat/build/Release/app
Release: Hello World!
Release: Hello World!
Release: Hello World!
现在,去改变一些包,例如 “说” 一个,然后重建。查看它如何进行增量构建 (快速)。
请注意,本地缓存中不会真正安装任何内容,所有依赖项均在本地解析:
$ conan search say
There are no packages matching the 'say' pattern
为调试模式构建在其自己的文件夹中完成:
$ cd .. && mkdir build_debug && cd build_debug
$ conan workspace install ../conanws_gcc.yml --profile=my_gcc_profile -s build_type=Debug
$ cmake .. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug
$ cmake --build . # or just $ make
$ ../chat/build/Debug/app
Debug: Bye World!
Debug: Bye World!
Debug: Bye World!