conan-io / conan

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

[question] Setting tool configuration values in build/generate/configure method for the package that is being created #16525

Closed CommanderCRM closed 4 months ago

CommanderCRM commented 4 months ago

What is your question?

According to this page, conf_info is used only for consumers and consumers use it in generate(). What if someone wants to set tool configuration to be used during the package build process, for example tools.build:verbosity to verbose? Is there any way to do this?

Have you read the CONTRIBUTING guide?

franramirez688 commented 4 months ago

HI @CommanderCRM

I don't know if I completely understood your question. When you want to set any configuration, you should use your Conan profile or even the CLI:

your_profile

[settings]
arch=x86_64
build_type=Release
compiler=apple-clang
compiler.cppstd=gnu17
compiler.libcxx=libc++
compiler.version=15
os=Macos

[conf]
tools.build:verbosity="verbose"

Or through the CLI:

conan create . -c "tools.build:verbosity='verbose'"

As you said, conf_info is only used by consumers and only set by tool_requires, so it's quite a specific and limited way to do it. I would recommend using the profile or the CLI to set any conf variable

CommanderCRM commented 4 months ago

I think we understood each other. So there's no way to do this inside recipe of the package being created, only inside profiles or through CLI? For example, there was a verbosity flag in Conan 1 for MSBuild, which is now only present in conf

franramirez688 commented 4 months ago

Yeah, those parameters are not available for the new tools, but you can also add the extra verbose parameter to each command which is the easiest way to get it:

For instance:

conan create . -vvv

Copying and pasting from the Conan command docs:

  -v [V]                Level of detail of the output. Valid options from less
                        verbose to more verbose: -vquiet, -verror, -vwarning,
                        -vnotice, -vstatus, -v or -vverbose, -vv or -vdebug,
                        -vvv or -vtrace
CommanderCRM commented 4 months ago

so this flag will affect build tools as well?

memsharded commented 4 months ago

No, the -vvv verbosity is only for Conan messages, not for build tools or any other tool that runs as a subprocess. The correct configuration is to use the tools.build:verbosity='verbose' or tools.compile:verbosity='verbose'.

It is true that extra arguments to MSBuild have been dropped. In general it is recommended that recipes do not define these things and they are controlled externally by configuration. But also CMake contains a cli_args argument that allows to inject extra arguments in the command line, so it might be possible to do the same for MSBuild

CommanderCRM commented 4 months ago

All right, thanks. I'd suggest adding the possibility to use custom command line args with current MSBuild helper