[Qt-interest] How does QtCreator parse the .pro file
Bo Thorsen
bo at fioniasoftware.dk
Wed Sep 7 13:45:46 CEST 2011
Den 07-09-2011 13:32, Vannoote, Frederik skrev:
> Hi all,
>
> I’m using QtCreator as IDE. My application has next to the sources also
> some unit tests using QTestLib.
>
> My goal is to be able to debug and step through the classes when running
> a unit test.
>
> This is my directory structure:
>
> -source
>
> oproject.pro
>
> ocomponents
>
> §comp1.pri
>
> §comp2.pri
>
> osome other classes
>
> -tests
>
> ounittests.pro
>
> From the unittests.pro I want to include the project.pro. I do this
> using the regular include(../source/project.pro) statement. However the
> paths are not correct. To cover that, I prepend ../source to them using
> some qmake functions.
>
> At this point that is working fine. I can compile my unittests using the
> command line.
>
> However, when included in QtCreator, it only lists the .pri and .pro
> files without the headers and sources.
>
> Due to that, my code completion don’t work, nor can I put breakpoints.
>
> How can I overcome this?
>
> Is this the correct approach to do these kind of things?
You have to do two things:
In the .pri file, do this:
SOURCES += \
$$PWD/file.cpp ...
Always use the $$PWD in included pri files from other directories
Usually, I place the directories as subdirs of the one that hold the
.pro file(s) because then I can use #include "subdir/file.h". If you
prefer, you can add the subdirs to the include path by adding
INCLUDEPATH += $$PWD
in the .pri file.
One final thing: You *can not* have two files with the same names in
different directories when you are using pri files as subprojects
because the generated .o files are all placed in the same directory.
Bo Thorsen,
Fionia Software.
--
Expert Qt and C++ developer for hire
Contact me if you need expert Qt help
http://www.fioniasoftware.dk
More information about the Qt-interest-old
mailing list