Search code examples
qtqt-creatorqmake

Project organization with QtCreator and QMake


I'm trying to create a project in Qt creator where the presentation layer and and business logic layer are separated into sub projects. Here's an illustration I'm talking about:

MainProject.pro
|
---- BusinessLogic.pro
|       |
|       ---- source/header files
|
---- PresentationLayer.pro
        |
        ---- source/header files

Currently, my code in the presentation layer refers to the header files in the business logic project by specifying INCLUDEPATH = ../BusinessLogic/headers in the .pro file. It appears to work, but is there a better way of doing this? Perhaps even a recommended way?

I'm trying to do something similar with the lib files, but as these are generated at compile time and they can be in either a release or debug folder, I'm not sure how I'd go about doing this.

This seems like a very common way of organizing projects but I don't seem to find much information on how to accomplish this with QtCreator or QMake.


Solution

  • Considering inclusion of different debug/release libraries, you can do the following in the project file:

    build_pass:CONFIG(debug, debug|release) {
        LIBS += -L../BusinessLogic/bin/debug -lBusinessLogicd
    }
    else:build_pass {
        LIBS += -L../BusinessLogic/bin/release -lBusinessLogic
    }
    

    This is assuming you have a BusinessLogicd.lib in your BusinessLogic/bin/debug folder and a BusinessLogic.lib in your BusinessLogic/bin/release folder.

    Concerning the includepath, I think a relative path is alright as long as you are within the same main project.