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:
    http://dragly.org/2014/03/13/new-project-structure-for-projects-in-qt-creator-with-unit-tests

    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
    

    default.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:

    1. Run "Build src" on src folder
    2. Run "Rebuild" on app folder
    3. 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...


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    You should remove CONFIG += ordered since your are setting the dependency.

    See this article for more information.



  • Hello SGaist,

    thanks a lot for your suggestion. However it did not solve the problem.

    I have made some more attempts with the following sample project:
    https://github.com/ComputationalPhysics/qtcreator-project-structure

    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?


  • Lifetime Qt Champion

    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.


  • Lifetime Qt Champion

    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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.