[SOLVED] Include a .pro file in Qt?


I have a project which has lots of includepaths, source and header files. The project is run as a standalone application (it’s not a library).

I would like to implement tests (Qt unit test framework) for new features for that application and for that, I require the includes, sources and header files of the (application) project to be available in the (testing) project.

I have tried putting the following in the testing project .pro file:

include(../application/app.pro)     #app.pro is the application project

However first it complains about main.cpp, and if I comment that out there is a parsing error. (commenting main.cpp is bad since I’m changing the main project just so that the testing will compile)

I can get the behavior I want by manually copying all the includepath’s, source and header fields from the (application) project but am looking for a cleaner way.

What would be the optimal way to do this? Is it possible to painlessly include one .pro into another?


You should perform two modifications:

  1. Separate out all header files and build-specific settings into a *.pri file. This is what you need instead of including a *.pro.
  2. Move all business logic into a library in order to be able to test it in a separate project.

E.g., you will have build.pri:

# build.pri


INCLUDEPATH += $$TOPDIR/additional/libararies

HEADERS += all.h \
           your.h \
           headers.h \
           of.h \

QT      += xml
# etc., etc.

and core.pro

# core.pro

CONFIG  += dll thread create_prl
QT      += network xml xmlpatterns sql



SOURCES  += sources.cpp \

TARGET     = core
# etc., etc.

(note the include(../build.pri)), and then make your main project app.pro as a subdirs project with core and gui as components of application, and test.pro with obligative core and as many tests as you want.

Answered By – Andrey Rogozhnikov

Answer Checked By – Terry (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *