PDA

View Full Version : QMake INCLUDEPATH Recursively search in all Subdirectories (ITK Setup)



Nathalia
5th March 2015, 11:00
Dear Community,

I am since a while trying to include all header files of my ITK library located in /usr/include/InsightToolkit/... However, this library is pretty big and contains around 50-100 sub directories. So what I did until now is writing
INCLUDEPATH += /usr/include/InsightToolkit/XY; /usr/include/InsightToolkit/XZ; ... but this is getting frustrating. Isn't there an elegant way? I was search for this in Google now for 3 hours without any result! I mean there are many people asking for this but I haven't seen a useful answer so far. I can't believe one can not include the sub directories automatically.

One of the answers were (also from this forum):

"You have to add ‘em all manually. I did it by adding subproject files (.pri by convention) which add all the source and header and incl paths for a particular component. Then in my main .pro file you can use the include directive. This could probably be scripted in qmake language. I’m too lazy for that."

I do not even understand what is meant by adding subproject files .pri.


Thanks for any help :D

Nathi

wysota
5th March 2015, 18:05
You should only add the top level directory to INCLUDEPATH and when including files use paths relative to that directory, e.g. #include <XY/sometime.h>

Nathalia
6th March 2015, 13:07
Sorry but this is not helpful. I use a relative huge library and I need many classes of hit since I will write a complex project. I will definitely not include every time I need a new class include it search for its path. The library contains around 7 basic folders, most of these contain again 5 sub folders, these again contain 10 sub folders. It is insane that there is no other way. Moreover I will add more huge libraries such as VTK.

wysota
6th March 2015, 13:20
I will definitely not include every time I need a new class include it search for its path.
That is a standard approach for every library I know of.

And you definitely don't want your compiler to search for every include file in thousands of directories. Unless you are paid by an hour and don't care that the compilation takes 10 times as long as needed.

aamer4yu
6th March 2015, 13:32
Thats quite true, do you really to include so many headers as Wysota asked ?

If yes, you can save time by listing headers from a command prompt, include the result in INCLUDEPATH in some text editor
find . -names *.h
// Open in text editor and extract directory by removing file names [hint : reg ex for header like "/[A-Z ]+\.h" ]

Nathalia
6th March 2015, 13:39
Thank you, that helped me a lot. I just have basic issues getting an overview of how linux works since so many things are done by command window.

Thanks.
Nathi

wysota
6th March 2015, 14:20
Using include statements in your C/C++ code is nothing Linux specific.

One more thing, be prepared that if you spit out thousand directories on your compiler's command-line, you will get an error about the line being too long. What you are trying to do is really Bad And Evilâ„¢.

If you are lazy then create an include file where you will list all the include files you may use (with full paths relative to some directory in INCLUDEPATH) and always include that file in your code. Your project will still build very slowly but at least you won't be getting errors on the command line.

d_stranz
7th March 2015, 04:09
VTK, ITK, and the other kits from KitWare are designed to use CMake. Build conditions are specified using CMakeLists.txt files, which can be processed using the CMake-gui tool.

Once you have a correct CMakeLists.txt file, you can import this into Qt Creator and generate the .pro / Makefile file from it.

In the VTK Cylinder (http://www.vtk.org/Wiki/VTK/Examples/Cxx/Rendering/Cylinder) example, all of the header files needed to build the program are included without any need to specify the directories in which they are found, because CMake takes care of all of that.

But you seem intent on doing things the hard way.