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

Toralf Lund toralf.lund at pgs.com
Fri Mar 29 12:32:42 CET 2019


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://doc.qt.io/qtcreator/creator-build-settings.html#using-qt-creator-variables, 
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.

- Toralf



More information about the Qt-creator mailing list