I have a main task (to develop a library) that I split up to get it more manageable.
Basically I have a template class for vectors and matrices, several classes that use these two, the main library that uses all of these classes and a Demo application that uses the library to display the features and test them.
The demo application is a Qt/cdt project.
The library is a pure cdt project.
The vector and matrix class are one cdt project.
Each of the other classes have an own cdt project.
Now I am mainly developing the library and want to see the results in the demo application. So the main development cycle is to change the source of the library and recompile the demo application.
My problem is: How to setup the projects builds to have only to rebuild the files necessary and link them accordingly.
My first approach was to include all the source files of all projects (including the library) in the demo application. That worked but did not trigger on updated files in the library (so I head to clean and build everything again each time).
After this I thought of building the library statically and then linking it into the source file, while referencing the projects. This triggered recompilation at the right place but it seems that the new binary files were not linked into the executable.
Basically the question is: How should I arrange all those files to have a clear layout (not everything in one project), build the right things (and not everything) if necessary and link them into the executable (in case there were changes).
Side note Another problem with project referencing was, that the template classes were compiled in their project which led to distracting error messages.
Edit To give a better understanding of the directory layout:
eclipse_workspace/
demo_application/
.cproject
.project
main.cpp
somewidget.h
somewidget.cpp
demo_application.pro
...
main_library/
.cproject
.project
class1_header.h
class1_implementation.cpp
class2_header.h
class2_implementation.cpp
...
.../
vector_matrix/
.cproject
.project
vector.h
vector.cpp
matrix.h
matrix.cpp
...
Each project depends on the projects beneath it.
Finally I found the solution after finding the right words to search for. The main problem was that the QMake created Makefiles did not check for the “static” library as a dependency of the target. I solved this by adding
To the project file. With that the binary gets relinked, when there were changes in the library.
Additionally I setup each project in eclipse to reference the dependent projects (Project properties -> Project References) to trigger rebuilds if necessary.
Furthermore I got rid of the ugly error messages from my template project by setting up the build correctly (I had a main.cpp to show some example usage of the template, so building was nice). The problem was, that the .cpp files of the template classes were in the build too so they were compiled twice, which gave the errors (previous declaration of … on line [exact same line]). I solved this by excluding all those template files from the build.