[Interest] Adding extra target to pro file

Konrad Rosenbaum konrad at silmor.de
Fri Jan 10 11:15:32 CET 2014


Hi,

On Thursday 09 January 2014, Till Oliver Knoll wrote:
> Am 09.01.2014 um 17:19 schrieb Francisco Ares <frares at gmail.com>:
> > 2014/1/9 Igor Mironchik <igor.mironchik at gmail.com>
> > 
> >> ... If so and AFAIK, you can't do this in a single .pro file
> 
> Correct: each *.pro file with either an "app" or "lib" set as template
> will produce exactly one binary, either an executable or (shared)
> library.

> The magic keyword here is the template "subdirs"! You specify a bunch of
> subdirs in some "top-level" *.pro file with
> 
>   template = subdirs
>   subdirs = foo \
>                   bar \
>                   baz
> 
> 
> Each subdir then has its own *.pro file (with template set to "ap"p or
> "lib"). Make sure the generated binaries end up in some common "bin"
> directory, then it becomes easier for specifying the folder for linking
> the dependencies.

The fun part is: it does not have to be real sub-directories, you can have 
several targets in the same directory, you can even specify dependencies.

A little example.pro:

TEMPLATE = subdirs
SUBDIRS = dir1 dir2 file3 file4
dir2.depends = dir1
file3.depends = dir2 dir1
file3.file = anotherfile.pro
file4.file = some/where/myfile.pro

As you can see - you can specify extra options for each "subdir" that this 
.pro file wants to generate:

*.depends: tells qmake to make sure the dependency is built first - in this 
case it makes sure that dir2 is only built after dir1 is complete and that 
file3 is only built with complete dir1 and dir2

*.file: overrides the default for .pro file names - the default is to look 
for the same name as the directory with .pro attached, so dir1 actually 
interprets dir1/dir1.pro and dir2 means dir2/dir2.pro; file3 is different - 
it gets redirected to use anotherfile.pro in the same directory as 
example.pro; and file4 gets redirected to myfile.pro in the some/where 
directory

One more hint: if you build several targets in the same directory and their 
build settings differ (e.g. different preprocessor settings) use different 
directories for temporary files (OBJECTS_DIR, MOC_DIR, RCC_DIR) to avoid 
mixing the binary files for them


	Konrad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140110/ab8e2226/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 588 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140110/ab8e2226/attachment.sig>


More information about the Interest mailing list