Dependencies in Qt project
I have a problem building my subdired project with Qt creator 3.6.0.
My Qt project is structured as suggested here:
This results in three subdirectories with corresponding pro files:
- src (creates a static lib for the project)
- app (creates the application including static lib)
- tests (creates tests including static lib)
The main pro file looks as follows:
TEMPLATE = subdirs CONFIG+=ordered SUBDIRS = \ src \ app \ tests app.depends = src tests.depends = src OTHER_FILES += \ defaults.pri
INCLUDEPATH += $$PWD/src SRC_DIR = $$PWD
When I change the source code and type F5 to build and run the project, the app folder is not rebuilt (although I have set app.depends = src). The change is not applied and the application remains unchanged.
What I have to do to correctly build the application is the following:
- Run "Build src" on src folder
- Run "Rebuild" on app folder
- Start application with F5.
How can I define my pro files in order to build & run my application simply by typing F5?
Thanks for suggestions...
Hi and welcome to devnet,
You should remove
CONFIG += orderedsince your are setting the dependency.
See this article for more information.
thanks a lot for your suggestion. However it did not solve the problem.
I have made some more attempts with the following sample project:
Seems that F5 build is working for MinGW but not for MSVC2013 projects (which I am using). When I configure the sample project with MinGW code changes are automatically rebuilt (as expected). When I configure the sample project with MSVC2013 automatic rebuild is not working, so I first have to build the source and then rebuild the app folder (as described in my previous post).
Any ideas why the behavior is different and how I can change the project config to work with MSVC as well?
Silly question but after removing the CONFIG line, did you do a full rebuild ?
Yes, full rebuild is indeed working, but my hope was that the project dependencies are sufficient for Qt Creator to know what needs to be rebuilt when typing F5.
Also, I do not understand why it is working for MinGW but not for MSVC2013.
When changing a CONFIG option, a full rebuild is generally a good step. However, are you still experimenting the issue after that ?
Visual Studio has it's own project handling. MinGW is just a set of tools, the projects using it generally have Makefiles to handle the building part.
I think my answer was not clear enough: For the MSVC configuration, I have to do a full rebuild every time something has changed in the sources, not just after changing the CONFIG option. This takes much more time for building than just "refreshing" the application with F5.
But maybe it is better to give a closer look at the Makefiles (as you suggest) in order to see what really happens.
In the end what helped was adding a direct dependency to the lib in app.pro/tests.pro, e.g.
PRE_TARGETDEPS += $$OUT_PWD/../src/debug/<libname>.lib