Building Qt Creator projects from command line

余生颓废 提交于 2019-12-03 18:38:22

问题


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.


回答1:


There are two steps involved here:

  1. Running qmake to generate Makefiles. The usual command is

    c:\qt\4.7.2\bin\qmake.exe" path\to\some\project.pro -r -spec win32-g++ CONFIG+=...
    

    The -spec switch is important. Make sure you supply a valid makespec file. CONFIG needs to be specified in this step.

  2. Running make to compile and link. This is easy

    C:\MinGW32\bin\mingw32-make -f Makefile.Debug
    

    Remember to point make to the correct makefile.




回答2:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!