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

Toralf Lund toralf.lund at pgs.com
Tue Apr 2 10:40:13 CEST 2019

On 29/03/2019 15:12, Toralf Lund wrote:
> 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. [ ... ]
>>> 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...

I've built a newer qt-creator, now, and there is definitely a 
difference. I now have 4.8.2, and variables are definitely expanded. 
String substations work, too, which allows me to set up a target 
location based on the source (according to certain conventions) and get 
a clean parent directory string (which are also needed.) :-) I also 
briefly tested 4.7.something, and some or all of the above worked there, 

Next is to see if I can find a way to install the kit in a more 
system-wide fashion...

- Toralf

> 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