I have the fololowing directory structure and I would like to simplify things using the Qt .pri files.
Project1/
project1.pro
main.cpp
Algorithms/
algorithm1.h
algorithm1.cpp
...
// add an algorithms.pri file here
Utilities/
utiliy1.h
utiliy1.cpp
...
// add an utilities.pri file here
Gui/
gui1.h
gui1.cpp
...
// add a gui.pri file here
AlgorithmsUnitTest/
algorithms_unit_test.pro
main.cpp
UtilitiesUnitTest/
utilities_unit_test.pro
main.cpp
One of the problems I am trying to solve is, that when I add or remove a source file from one of the Algorithms, Utilities or Gui folders, I have to remove it from all the other .pro files.
I would like to create a .pri file for each folder containing source and header files in that folder. These files would be included from all the other projects. Then if I add/remove a source or header file, I would remove it only from the corresponding .pri file.
The problem with this approach is that the inclusion of a .pri file in a .pro file is just a simple copy-paste. That is if algorithms_unit_test.pro included the algorithms.pri file, the qmake build system would look for the files in a nonexisting AlgorithmsUnitTest/Algorithms folder.
The solution would be to prepend the contents of the .pri file with
../Project1/
But I do not know how to do this. Please could you teach me how to do it or suggest some other way to organize my projects?
You can use the qmake variable
PWDin yours .pri files.algorithms.pri
utilities.pri
…
http://doc.qt.digia.com/qt/qmake-variable-reference.html