[Qt-creator] [External] Re: Export source location etc. to environment

Toralf Lund toralf.lund at pgs.com
Fri Mar 29 15:12:48 CET 2019


On 29/03/2019 13:21, Eike Ziller wrote:
>
>> On 29. Mar 2019, at 12:32, Toralf Lund <toralf.lund at pgs.com> wrote:
>>
>> Hi,
>>
>>
>> I'm trying to use Qt Creator with a CMake project managed by someone else, which relies on environment variables to specify a source location, install target on the source tree etc. I'm wondering how I might set up the relevant data in the Qt Creator build environment. I know how to add extra variables, but what do I specify as values? I can just type in the locations, obviously, but it would be nicer if I could reference the current project location or source directory or whatever as stored in Qt Creator. I've tried using Qt Creator variables as documented in https://urldefense.proofpoint.com/v2/url?u=https-3A__doc.qt.io_qtcreator_creator-2Dbuild-2Dsettings.html-23using-2Dqt-2Dcreator-2Dvariables&d=DwIGaQ&c=KV_I7O14pmwRcmAVyJ1eg4Jwb8Y2JAxuL5YgMGHpjcQ&r=Q0oqxzgUp3xCCIiJDwS-RbNDndQ-KZDhj8wwveNoqU4&m=eIat5wgzJOrmWaHHpH3GyO-4NNQwVhic-bboWr4iZsw&s=pNy0uv96Ty6PHUePBD5M-2KambQeU1WgKKK-huK-fcI&e=, but it looks like these aren't actually expanded in this context - if I set a variable to, say, %{sourceDir} I get that exact value in the environment, as opposed to the current source directory. Is that the expected behaviour? Any other ideas?
>>
>> Actually, for the build steps, perhaps it would be possible to set up the environment on the command like rather than as part of the Qt Creator settings, but the variables are also needed by the initial cmake step, where you can't really specify "complex" commands.
>>
>> Another slight issue is that I need to set up the same variables for multiple build configurations related to the project, and the only way I can find to do that i Qt Creator, is to duplicate the set-up on the "Build Setup" page for each and every configuration. Is there a way a shared environment can be set up instead? When I say "shared" I mean shared within the project or possibly the kit, not system-wide.
> Kits have an “Environment” settings,

OMG. There it is, right between "Compiler" and "Debugger". I have 
completely overlooked that before. Several times. Even when I was 
searching specifically for it. So that solves part of the problem in a way.


>   and that should support Qt Creator variables (like %{CurrentProject:NativePath}), maybe that solves your issue?

Unfortunately, it does not look like variables are supported; I get the 
literal text entered in the environment, and not the contents of the 
variable. Is that actually different on your system? I don't have an 
entirely new Qt Creator as I'm using a pre-built version from the "EPEL" 
repository on a CentOS 7 system...

Note that to test, I have just added the command "env" as a build step. 
It prints the expected list of variables, including ones set up in the 
kit, but like I said, I see variable references rather than variable 
contents. Is there a chance that they are somehow magically replaced later?

- Toralf

> (They also have a similar “CMake Configuration” setting for sharing that between projects with the same Kit.)
>
> Br, Eike
>




More information about the Qt-creator mailing list