[Qt-interest] Splitting library?

Oliver.Knoll at comit.ch Oliver.Knoll at comit.ch
Fri Feb 12 11:07:40 CET 2010


Anatoly Burakov wrote on Thursday, February 11, 2010 2:49 PM:

> ...
> However, i've been exploring deeper into direct modification of *.pro
> files and i have some other questions. First, when i create
> subdir-based projects i can't really specify project dependencies
> from within the GUI,

Are you refering to the Qt Creator "GUI"? Note that when you open two projects, Foo.pro and Bar.pro, and you want to define a dependency from Bar to Foo, you actually can define this in the "Projects" tab, see attached screenshot.

But to be honest I have no clue what it does, because I don't see either *.pro file changed, and the next time I start Qt Creator (1.3, for that matter) this setting is gone again. So it seems it is also not stored in these Bar.pro.user files (which are generated by Qt Creator).

So I don't know whether this feature is supposed to work already or how it works.

But when it comes to specifying the order in which to build projects, see below.

If you find out anything, let me know :)

>  so i assume i must specify them somewhere else.
> I didn't find a keyword in the *.pro files for that so it must be
> somewhere else - where? Also, are there any advantages/disadvantages
> of using multiple project files vs one project with lots of
> subprojects? 

I don't know what you mean with "subprojects". To my knowledge you can build only one executable or library per *.pro file. So typically you have one "top-level" *.pro file with TEMPLATE = subdirs, where you specify all "sub-projects" (the directories thereof).

The easiest (but I agree, somewhat cumbersome, since manual) way is to simply specify the order of the directories (projects) in the order of their dependency. The project with no dependencies first, last the "topmost" project.

So when you do a

%> make distclean
%> make

then your build compiles in the correct order (and succeeds always, since everything is re-moc'd, rebuild etc.).

That's how I have done it with the FooBar.pro example given previously.

What I have omitted however, is the fact that projects need to be rebuild, once a header in a dependent project changes (and you DON'T want to build from scratch all the time ;)! And probably your question refers to that scenario (the more interesting one ;): read about http://doc.trolltech.com/4.6/qmake-variable-reference.html#dependpath - with this you can specify additional include directories which should be taken into account when creating the dependencies from header files.

Off course that means that the "toplevel" project (potentially) needs to add ALL source directories (with the relevant headers) it might depend on -> put these into DEPENDPATH. Or so I understand... (up to know I am more a Visual Studio user which does that all for me and which lets me specify dependencies between projects, too).


Hope that helps somewhat,
  Oliver


-- 
Oliver Knoll
Dipl. Informatik-Ing. ETH
COMIT AG - ++41 79 520 95 22
-------------- next part --------------
A non-text attachment was scrubbed...
Name: QtCreator_Dependencies.png
Type: image/png
Size: 11493 bytes
Desc: QtCreator_Dependencies.png
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100212/3a424ff2/attachment.png 


More information about the Qt-interest-old mailing list