Nathan Osman
Nathan Osman

Reputation: 73195

Problem getting qmake project dependencies to work

I have the following directory structure:

 - project
     - test.pro
     - test2
         - test2.pro

test.pro looks like this:

# ...
SUBDIRS = test2

The problem is that when I run:

qmake test.pro
make

...it only builds test and not test2.

How come test2 isn't getting built as well? What do I have to do to tell one Qt project to build another one first?

Upvotes: 1

Views: 469

Answers (1)

rohanpm
rohanpm

Reputation: 4274

Adding to SUBDIRS has no effect for any TEMPLATE other than subdirs, and you cannot have multiple TEMPLATEs in a single .pro file. In other words, you can't have a single .pro file to both build some binaries and invoke some subdirs projects.

You need one top-level .pro file which only contains subdirs. For example, your test.pro could be:

TEMPLATE = subdirs
SUBDIRS = test1 test2

... and you would then have subdirectories for test1 and test2.

If you don't want to reorganize your code into a subdirectory, you can also put the names of .pro files (instead of directory names) into SUBDIRS. For example, your test.pro could be:

TEMPLATE = subdirs
SUBDIRS = test1.pro test2

... where test1.pro may exist in the same directory as test.pro, and have the usual TEMPLATE=app stuff.

Upvotes: 4

Related Questions