Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Building a subdirs project



  • I have a project which is organzed as follows

    project.pro

    project.pro:

    TEMPLATE = subdirs
    SUBDIRS =
    lib
    app
    app.depends = lib

    lib.pro

    TARGET = MyLib
    TEMPLATE = lib
    CONFIG += staticlib
    CONFIG += create_prl # Following http://qt-project.org/doc/qt-5/qmake-advanced-usage.html

    app.pro:

    TARGET = MyApp
    TEMPLATE = app
    CONFIG += link_prl # Following http://qt-project.org/doc/qt-5/qmake-advanced-usage.html

    Problem

    If I make a change in the lib source, then I find that if I build the project (by pressing the hammer in QtCreator), then the changes do not actually show up in the program that runs. If I try to build by just pressing Run or Start Debugging, I get the same effect. MyApp is the only build target I can choose from the Computer icon in QtCreator. As a result I actually have to Rebuild (by right clicking on root node in the Project explorer tree), which takes ages every time, however small the change I make.

    How can I get QtCreator to only build the small parts of my project where a change occurs?


  • Lifetime Qt Champion

    Hi,

    IIRC, you need to use PRE_TARGETDEPS in your app.pro to tell the system to watch for changes in your static library



  • @SGaist said:

    PRE_TARGETDEPS

    That seems to have done it, thanks!!!



  • I recently resolved a boatload of issues like this in my project, and I found that if you use the wizard to add an internal library, pointing to your dependent library, all of the necessary bookkeeping is done for you. I then took the resulting auto-generated code and created a .pri file. Then instead of using the wizard all the time, I just include the .pri file and all of the paths etc. are taken care of.


Log in to reply