Reputation: 210
Some QMake projects use system()
commands which are only meant to be executed during the build, and usually only for a specific OS, for example:
win32:system(cmd.exe /E myscript.bat)
Historically, Qt Creator has ignored such commands when parsing .pro/.pri files. But starting with Qt Creator 4.13.0, it now runs them during project loading, which can result in unexpected actions or failures.
How can we tell Qt Creator not to parse specific statements or blocks from a .pro/.pri file, so that they only get executed by QMake itself?
Upvotes: 0
Views: 342
Reputation: 210
You can disable such commands, or any other QMake statement that you don't want parsed by Qt Creator, by enclosing the command in a !qtc_run {}
block or inline condition:
!qtc_run {
win32:system(copy myfile.txt dest\\folder)
else:system(cp myfile.txt dest/folder)
}
!qtc_run:win32:system(cmd.exe /E myscript.bat)
The qtc_run
token is added to the CONFIG
variable by Qt Creator when it parses the QMake project, so it's not set when running qmake directly, and since CONFIG
variables can be used for conditional blocks you can then test for the Qt Creator environment as done above.
You can also use this technique to only run some QMake commands when inside Qt Creator, simply by using qtc_run {}
without the negation operator.
Upvotes: 0