I'm in the process of writing a build script to automate build and release tasks. I have a Qt Creator project which has three configurations, two of which I want to completely rebuild from scratch without any precompiled headers and existing .o files to skip (release and release_production). The latter is the same except it has the PRODUCTION symbol #defined.
I'm using windows. How can I build these configurations from the command line?
Edit: Some clarification: The Qt Creator custom build steps are not stored in the qmake makefile but in the Qt Creator-specific .pro.user XML file. I would like to perform these from the command line without repeating them in the script.
There are two steps involved here:
Running
qmaketo generate Makefiles. The usual command isc:\qt\4.7.2\bin\qmake.exe" path\to\some\project.pro -r -spec win32-g++ CONFIG+=...The
-specswitch is important. Make sure you supply a valid makespec file.CONFIGneeds to be specified in this step.Running
maketo compile and link. This is easyC:\MinGW32\bin\mingw32-make -f Makefile.DebugRemember to point
maketo the correct makefile.
In the project tab of QtCreator you have the exact command, QtCreator runs on build for both debug and release. Just run those lines in a environment your project can be build (Qt console). But basically Qt projects are build with a qmake.exe then a nmake.exe or the Qt multi-thread make-like executable jom.exe.
For your "production" mode your can use CONFIG+=production argument in the qmake command, then in your .pro files :
CONFIG(production){
DEFINES+=PRODUCTION
}else{
}
来源:https://stackoverflow.com/questions/6127357/building-qt-creator-projects-from-command-line