2016-06-20 Small grocery store ly First, the introduction of Qmake
Qmake is a tool created by Trolltech company to write makefile for different platforms and compilers.
Handwritten makefile are difficult and error-prone, especially when you need to write several makefile for different platforms and compiler combinations. Using Qmake, the developer creates a simple "project" file and runs qmake to generate the appropriate makefile. Qmake will pay attention to the dependencies of all compilers and platforms, freeing developers to care only about their code. Trolltech Company uses Qmake as the primary tool for the QT Library and QT-provided tools.
Qmake also noted the special needs of QT, which can automatically include the MOC and UIC rules.
Qmake compilation information can be configured through qmake.conf.
Second, pro, PRI, PRF, PRL
QT Project management files are mainly divided into pro, PRI, PRF, PRL Four types of files, which pro file is the main file, and the other three can be included in the pro file, their writing rules follow qmake rules.
1. PRL link file, this file mainly and generated with the use of static library is closely related.
When generating a static library, we need to use Config + = CREATE_PRL configuration, compile and build the *.prl file with the same name as the library file;
When the project template for the app, will automatically add the following command config + = LINK_PRL, when looking for the library file, will try to find the appropriate *.PRL file to link.
2, PRF signature file, this file mainly identifies the compilation characteristics, you can use two ways to load
1) CONFIG + = *PRF;
2) Load (*PRF).
3, the PRI configuration file, usually put some general configuration information, for project management.
4, Pro Project management documents, usually placed in the specific project-related information, as well as the Cascade module management.
Iii. Introduction to the rules of Qmake
1, use # to annotate;
2. The template variable tells Qmake what kind of makefile to generate for this application.
For example, TEMPLATE = App App
App-Build an app for makefile.
Lib-Create a library of makefile.
Vcapp-Build an application's VisualStudio project file.
Vclib-Create a library of VisualStudio project files.
Subdirs-This is a special template that creates cascading subdirectories for project management.
(Eg:template = Subdirs
Subdirs + = One
Subdirs + =)
3. Specify the directory where the generated application is placed DESTDIR + =. /bin;
4. Specify the generated application name TARGET = Pksystem (same as pro filename);
5, configuration information, config is used to tell Qmake about the application configuration information.
For example config+= QT warn_on release, where + = is appended, = is assigned, warn_on is qmake to set the compiler as the output warning message, the release section tells the Qmake application must be linked to a published application, You can use debug replacement here.
6. Specify the UIC command to convert the. UI file into the directory where the ui_*.h file is stored ui_dir + = forms;
7. Specify the RCC command to convert the. qrc file to the storage directory for the qrc_*.h file
Rcc_dir + =. /tmp;
8. Specify MOC command to convert the header file containing q_object to the standard. h File storage Directory
Moc_dir + =. /tmp;
9. Specify the destination file (obj) for the storage directory Objects_dir + =. /tmp;
10, the program compiles the dependent path Dependpath + =. forms include QRC sources;
11. Header file contains path Includepath + =. ;
12, source file encoding mode CODECFORSRC = GBK;
13, the project contains the head file HEADERS + = *.h;
14, the project contains the source file sources + = *.cpp;
15. The. UI design file included in the project FORMS + = *.ui;
16. Resources files included in the project + = *.QRC;
17, LIBS + =-L library path-l library name;
18, the definition of compilation options, defines + = XX, in the. h file can be used: #ifdefine XX;
19, conditional compilation (mainly distinguish between different platforms and release, Debug version)
Win32 {
SOURCES + = *.cpp
}
UNIX {
SOURCES + = *.cpp
}
!exists (main.cpp) {
Error ("No main.cpp file Found")
}
Win32:debug {
CONFIG + = Console
}
CONFIG (Debug, Debug|release) {
}
(Note: {must be placed on the same line of the condition)
20, message (information);
21, Include (*.PRO/*.PRI);
22. Translations QT Language Internationalization file
23, command line (Configure the QT environment variable) qmake-project Generate Pro file (need to configure qmake.conf manual modification Pro file for processing), Qmake *.pro generate makefile file, nmake (compiler) compile can;
24, QMAKE-TP VC *.pro (-R) generation VS solution;
25, Qmake-spec Macx-xcode *.pro generate Xcode project files;
26. Warn_off-the compiler will output as few warning messages as possible;
27, QT + + XML added QT module;
28, Installs + = target sources specify the installation path;
29, qmake_cxxflags_warn_on C + + compiler warning;
30, qmake_cflags_warn_on C compiler warning;
31, W34100 unreferenced formal parameter;
32, W34189 local variable is initialized and not referenced;
33, contains (Config,thread) according to whether the thread is compiled in CONFIG.
Iv. qmake Compilation Options
1. qmake [Options] Files
1)-help list qmake help information;
2)-o file is output directly to files, if this option is not specified, Qmake will attempt to use the appropriate file name as the output, depending on the current operating mode.
3)-D lists debug information for Qmake;
4)-wall Qmake will report all known warning messages.
V. Reference links
1, http://www.kuqin.com/qtdocument/qmake-manual-7.html
2, Https://msdn.microsoft.com/en-us/library/ysb0wexw.aspx
http://mp.weixin.qq.com/s?__biz=MzI4NzIwMDQ3OA==&mid=2247483680&idx=1&sn= 33844b0bfdb9cae3be8c2137f9e70d11&scene=23&srcid=0620axbp8ko6hzc03mhxqfnv#rd
QT Project Management (33 rules)