So far, we have used the default settings stored in
~/.conan/profiles/default and defined custom values for some of them as command line arguments.
However, in large projects, configurations can get complex, settings can be very different, and we need an easy way to switch between different configurations with different settings, options etc. An easy way to switch between configurations is by using profiles.
A profile file contains a predefined set of
environment variables, and
tool_requires specified in the following structure:
Options allow the use of wildcards letting you apply the same option value to many packages. For example:
Here is an example of a configuration that a profile file may contain:
A profile file can be stored in the default profile folder, or anywhere else in your project file structure. To use the configuration specified in a profile file, pass in the file as a command line argument as shown in the example below:
$ conan create . demo/testing -pr=clang_3.5
Continuing with the example of Poco, instead of passing in a long list of command line arguments, we can define a handy profile that defines them all and pass that to the command line when installing the project dependencies.
A profile to install dependencies as shared and in debug mode would look like this:
To install dependencies using the profile file, we would use:
$ conan install .. -pr=debug_shared
We could also create a new profile to use a different compiler version and store that in our project directory. For example:
To install dependencies using this new profile, we would use:
$ conan install .. -pr=../poco_clang_3.5
You can specify multiple profiles in the command line. The applied configuration will be the composition of all the profiles applied in the order they are specified:
$ conan install .. -pr=../poco_clang_3.5 -pr=my_build_tool1 -pr=my_build_tool2