Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Dependence issue when using the "subdirs" template
Hi all. Currently I'm developing a game consists of two executables (like game itself and the editor in wesnoth); they share some code, so I decided to make three sub directories; one for the common part (which will be compiled into static libraries), and the other two dirs for the remaining code.
But, when headers in the common part changes, qmake will not recompile the corresponding part in the other dirs. It's so horrible and time-wasting... So, any ideas?
I you could give more information on which platform/evironment/ide you are using, that's would help us to help you :).
linux + bare qmake + emacs.
I suppose that you do 3 distinct projects: a shared lib and 2 executables? You declare too all your includes in the INCLUDES tag of the .pro files?
They are not "distinct"; I do so just because Qt cannot generate multiple executables in an easy way.
So adding the headers to INCLUDES manually is the way you usually handle problems like this? Alright I'll try it. Thanks.
It seems not working.
The shared code is put in the "common" directory, which is under the root directory of the project;
there's another directory "editor" under the root, which is used to store executable-specific code.
Under project/editor/editor.pro, I wrote "include(options.pri)"; and inside project/editor/options.pri, I added "INCLUDE += ../common/common.hpp".
But it's not working! I modified common.hpp, recompiled code under common/, then switch back to editor/ and called 'qmake editor.pro && make' -- make only relinked the object files.
You could check the makefile directly to check if the dependencies are ok. Normally it should correctly work, I have a complex project with like 10 shared library + 2 static + 2 executables and the dependencies work perfectly (if I register them correctly :P )!
It's possible or you make typos or you have a problem of location: you could use the prefix $$PWD/myinclude.h (pwd gives the current path of the .pri/.pro file).
It's difficult to see where is the problem with the informations you give.
Well, after some test, I found it was because I did not add this:
DEPENDPATH += ../
it seems that having only INCLUDEPATH += ../ is not enough.