QT compilation method Qmake



Author: Billy
Copyright statement: The copyright is owned by the author. Please contact the author to get authorized for business reprints. Please indicate the source for non -business reprints

QT's help document introduces QMAKE like this:
Insert a picture description here
QMAKE tools help simplify the construction process of development projects on different platforms.It automatically generates a makefile, so it only takes a few lines of information to create each makefile.You can use QMAKE for any software items, whether it is written in QT.

Qmake is a very convenient tool with a QT toolkit.CanUsed to generate makefile and various engineering filesIt can also generate project files that Microsoft Visual Studio can be used.The most important thing is that it canAutomatically solve the dependencies, do not need to write Makefile, and it is a cross -platformEssence

1. Note

Different comments and codes in QMAKE start with symbol ‘#’.

2. Qt

QT module used to specify the projectIn the C ++ implementation level, the QT module uses the header file to be used to include and connect it to binary.By default, QT contains Core and GUI to ensure that the standard GUI application can be constructed without further configuration.If you want to build a project without the QT-GUI module, you need to use the "-=" operator to eliminate the GUI.

3. target

Specify the name of the target fileThe basic name of the project file contained in the default situation.

 

After this project is running, a executable file will be generated, under the Windows is myapp.exe, and the MyApp is under Linux.

4. Template

Template variable tells what kind of makefile is generated for this applicationThere are the following options to choose from:

OptionillustrateAPPCreate a Makefile for building an application (default)libCreate a Makefile for building librariessubdirsCreate a Makefile for building a target directory, and the subdirectory uses subders variables specifyAUXCreate a Makefile that does not build anything.If there is no compiler, you need to be called to create a target. For example, your project is written in interpreted language, and this feature is used.Note: This template type can only be used for Makefile-Based generator.Especially it will not work in VCXPROJ and Xcode generatorsVCAPPApplicable to Windows.Create a Visual Studio application projectvclibApplicable to Windows.Create a Visual Studio Library Project
5. Config

Specific project configuration and compiler optionThe value is recognized by Qmake and has special significance.

OptionillustratereleaseThe project is built in the Release mode.If you also specify the debug, then the last one takes effectdebugThe project is built in the debug modedebug_and_releaseProject preparation is built in two modes of Debug and Releasedebug_and_release_targetThis option is set by default.If you also specify the debug_and_release, the final debug and release are built in different directorybuild_allIf you specify the debug_and_release, by default, the project will be built as a Debug and Release modeautogen_precompile_source_sourceAutomatically generate a .cpp file, which contains the pre -edited header file specified in .proorderRedWhen using the Subders template, this option specifies should handle them in the order of the directory listPrecompile_HeaderYou can use the support of the pre -translation header file in the projectwarn_onThe compiler should output as many warnings as possible.If you are also specified by warn_off, the last one will take effectwarn_offThe compiler should output the warning as little as possibleExceptionsEnable abnormal support.default settingExceptions_offDisable abnormal supportRTTIEnable RTTI support.By default, use the compiler to defaultrtti_offDisable RTTI support.By default, use the compiler to defaultSTLEnable STL support.By default, use the compiler to defaultstl_offDisable STL support.By default, use the compiler to defaultthreadEnable thread support.When config is enabled when it includes QT, this is the default settingC ++ 11Enable C ++ 11 support.If the compiler does not support the option of C ++ 11, it has no effect.By default, support is disabledC ++ 14Enable C ++ 14 support.If the compiler does not support the option of C ++ 14, it has no effect.By default, support is disabled
6. DEFINES

Qmake adds the value of this variable as a compiler C preprocessor macro (-D option)Essence
Simple example:

 
7. DEF_FILE

Specify the .def file to be included in the projectEssence
Note: This variable is only used on Windows when using an application template.

8. Dependpath

Specify a list of all directory to analyze the dependenciesEssence

9. Destdir

Specify the position of the target fileEssence
For example:

10. Distfiles

Specify a list of files that should be included in the DIST targetEssenceThis function is only supported by the UNIXMAKE specification.
For example:

11. dlldestdir

Specify the position of the copy target DLLEssence
Note: This variable is only suitable for Windows targets.

12. Extra_translations

Specify a list of files that contain the transition of the user interface text into a non -native language (.TS) file listEssence
Unlike translation, the translation files in additional translation can only be processed by Lrelease, not Lupdate.
You can automatically compile files with config += LRELEASE during the construction, and config += LRELEASE EMBED_TRANSLATIONS to make them available in the QT resource system.

13. Forms

UI file specified before the compilation by UICEssence
All dependent items, header files, and source files required to build these UI files will be automatically added to the project.
For example:

 
14. GUID

Specify the GUID set in the .vcproj fileEssence
Guid is usually randomly determined.However, if you need a fixed Guid, you can use this variable to set it.This variable is only in the .vcproj file; otherwise it will be ignored.

15. Headers

Define the header file of the projectEssence
Qmake automatically detects the class in the header file to require MOC, and add appropriate dependencies and files to the project to generate and link MOC files.
For example:

 
16. icon

This variable is only used to set the application icon on Mac OSEssenceFor details, see the application icon document.

17. Includepath

When specifying the compilation project, the search should include the directory includedEssence
For example:

If it is the path of different systems, you can add system judgment

 
18. Installs

Specify a list of resource lists that will be installed when you execute the Make Install or are similar to the installation processEssenceEach item in the list is usually defined with attributes that provide installation location information.

For example, the target.path definition below describes the location of the installation of the target, and the Installs allocation will generate the target to the existing resource list to be installed:

 
19. libs

Specify the list of library to the projectEssence
If you use the unix-l (library) and -l (library path) logos, QMAKE will properly handle the library on Windows (the full path of the upcoming library is passed to the linker).The library must exist to find the directory where the -l lib is located.
For example:

 
20. MOC_DIR

Specify the directory of placing all intermediate moc filesEssence
For example:

 
21. Objects_dir

Specify the directory where all middle objects are placedEssence
For example:

 
22. PWD

Specify the complete path of the directory of the current file that is to be analyzedEssence
This is very useful for the files in the source tree when writing project files to support shadow generation.
Note: Don't try to cover the value of this variable.

23. qm_files_install_path

Specify the directory in the resource systemThe .qm file will be provided by Config += Embed_translations.
The default value is:/i18n/.

24. qmake

Specify the name of the QMAKE program itself, and place it in the generated MakefilesEssence
The value of this variable is usually processed by qmake or qmake.conf, which rarely needs to be modified.

25. qtplugin

Specify the list of static QT plug -in to the application link with the application, so that they can be available as built -in resourcesEssence
QMAKE automatically adds the plug -in that the QT module is usually required.
When the link to the sharing/dynamic construction or link library of QT, this variable is currently incapable.It can be used in the deployment of dynamic plug -ins.

26. rc_file

Specify the resource file name of the applicationEssence
The value of this variable is usually processed by qmake or qmake.conf, which rarely needs to be modified.

27. RC_icons

Specify the icon that should be included in the .rc file generated.Essence
Only Windows.This option is used only when RC_File and Res_file variables are not set.

28. RCC_DIR

Specify the directory of the QT resource compiler output fileEssence

 
29. Requires

Specify a list of values as conditional calculationsEssence
If any condition is wrong, QMAKE will skip this project (and sub -projects) when constructing.
Note: If you want to skip the project or sub -project during generation, it is recommended to use the requires () function

30. Resources

The name of the resource collection file (QRC) specifies the targetEssence

31. Sources

发表评论

您的电子邮件地址不会被公开 必填项已标记*