New to Qt (but loving it) and trying to build up our own libraries for some products.

I was hoping to be able to nest .PRI files so that each of them would explicitly include other .PRI files whose headers/sources are needed. That way, the main .PRO file would not have to "know" about dependent .PRI files. Suppose for example my main project requires the use of a class defined in foo.h/foo.cpp. The main .PRO file should include only foo.pri in it.

Now suppose that the class defined in foo needs some dependant class defined in bar. The foo.pri file could include bar.pri (representing bar.h/bar/cpp) and life would be wonderful. This seems to work fine.

However, now suppose that the main .PRO wants both foo and bar and is not aware that foo already has bar as a dependency (and the user of the main program should NOT have to be aware of that dependency).

The main .PRO file will include both foo.pri and bar.pri.

But when I try this, I have found that the makefile has (among other things) the target bar.o defined twice, leading to duplicate symbols in the link process.

I thought I could write all the pri files using a similar wrapper as is used to prevent H files from being included more than once. Example:

#bar.pri
!contains(HEADERS, bar.h)
{
HEADERS += bar.h
SOURCES += bar.cpp
}


#foo.pri
!contains(HEADERS, foo.h)
{
include(bar.pri)
HEADERS += foo.h
SOURCES += foo.cpp
}


However, I have found that this does not seem to work and the targets continue to be duplicated.

Anyone know the right way to handle this?

THanks,

David