Important: Please read the Qt Code of Conduct -

Qt Creator: Export source location etc. to environment (CMake project)

  • 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, 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.

Log in to reply