Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt: *.pro vs *.pri

Tags:

qt

qmake

qtcore

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?

like image 916
Roman Byshko Avatar asked Dec 02 '11 15:12

Roman Byshko


3 Answers

There is one main difference between their targetted reuse:

.pro

This is usually called Project File.

.pri

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.pri

FOO = BAR

hello.pro

...
include($$PWD/foo.pri)
...

world.pro

...
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.

like image 71
lpapp Avatar answered Nov 05 '22 00:11

lpapp


A .pro file is what you would run QMake on. A .pri file is included by a .pro file. Other than that there is not much of a difference between the two.

Example usage could be if you have different builds which need different options. You could put shared information in the .pro, while deferring the options to various .pri files. A bit more information, although admittedly not much more, can be found here.

like image 55
Bart Avatar answered Nov 05 '22 00:11

Bart


The format of the .pri files is exactly the same as the format of the .pro files. The main difference is one of intent; a .pro is what most people would expect to run qmake on directly, while a .pri is to be included by a .pro. When you instruct qmake to include another file, it just processes the commands in that file as if it were in the current file.

For Reference: *.pro vs *.pri

like image 16
AlphaMale Avatar answered Nov 05 '22 00:11

AlphaMale