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

Eike Ziller Eike.Ziller at qt.io
Fri Mar 29 13:21:58 CET 2019



> 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://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.

Kits have an “Environment” settings, and that should support Qt Creator variables (like %{CurrentProject:NativePath}), maybe that solves your issue?
(They also have a similar “CMake Configuration” setting for sharing that between projects with the same Kit.)

Br, Eike

-- 
Eike Ziller
Principal Software Engineer

The Qt Company GmbH
Rudower Chaussee 13
D-12489 Berlin
eike.ziller at qt.io
http://qt.io
Geschäftsführer: Mika Pälsi,
Juha Varelius, Mika Harjuaho
Sitz der Gesellschaft: Berlin, Registergericht: Amtsgericht Charlottenburg, HRB 144331 B



More information about the Qt-creator mailing list