What is the difference between *.pro
and *.pri
configuration files for qmake?
What should go into a *.pro file and what should go into a *.pri file?
There is one main difference between their targetted reuse:
This is usually called Project File.
This is usually called Project Include File.
As you can see in their names, the main difference is that .pri
files are meant to be include files. That is similar to including modules in programming language to share the functionality, essentially.
You will be able to write the common settings and code into those .pri
files and include them from several .pro
files as the need arises. This is how you would use it in practice:
FOO = BAR
...
include($$PWD/foo.pri)
...
...
include($$PWD/foo.pri)
...
This way, the commonality would be available both in hello.pro
as well as world.pro
. It does not make much of difference in this scenario, but when the shared functionality gets longer, it will save you some writing as well as sync'ing, bugfixing, and so on.
You could even include a .pri
file inside another .pri
file if you wish. You could also include .pri
files in different subprojects, etc. It is very nice.
The syntax is the same, however, for both the .pro
and .pri
files. In the end, you would run qmake on the .pro
files, and that is also what qmake generates for you if you do not have a project file existing and you intend to use qmake -project
.
You can read more about the include function in here:
include(filename)
Includes the contents of the file specified by filename into the current project at the point where it is included. This function succeeds if filename is included; otherwise it fails. The included file is processed immediately.
You can check whether the file was included by using this function as the condition for a scope.
Just to be complete, there are also .prf
Project Feature Files and .prl
Project Linker Files, but as an end user, you do not need to deal with that for now.