conan-io / conan

Conan - The open-source C and C++ package manager
https://conan.io
MIT License
7.96k stars 952 forks source link

[question] Is it possible to check arguments passed in the CLI in the profiles? #16579

Open Todiq opened 3 days ago

Todiq commented 3 days ago

What is your question?

Hello,

I was wondering if it would be possible to access some variables that have been passed in the CLI in the profiles.

Let's say I run conan install . --profile:all myprofile --settings:host "build_type=Debug".

Is it possible to do the following?

{% if settings.build_type == "Debug" %}
myvar={{settings.build_type}}
{% endif %}

Or something similar? Thanks in advance!

Have you read the CONTRIBUTING guide?

memsharded commented 3 days ago

Hi @Todiq

Thanks for your question.

It is not possible, because the priority is the opposite. The command line arguments like -s setting=value have higher precedence than the profiles values, so you can overwrite profile values with your cli arguments. This works by composition, the cli arguments define a profile that is composed to the previous profiles, that must be evaluated earlier than the cli arguments one. So --profile:all myprofile is loaded and evaluated even before -s arguments are processed.