I connect to the project (the goal is an executable file) another project (also an executable, that is, not a library) as a subproject. Here is a fragment of .pro:

include(adscreen/adscreen.pri) 

(The subproject directory in the adscreen subdirectory of the main project directory.)

Content adscreen.pri:

 TEMPLATE = app QT += qml quick CONFIG += c++11 SOURCES += $$PWD/main.cpp RESOURCES += $$PWD/qml.qrc # Additional import path used to resolve QML modules in Qt Creator's code model QML_IMPORT_PATH = # Default rules for deployment. include(deployment.pri) 

That is, only added $$PWD before the file names, the only difference from the previous adscreen.pri

But the main function should be both there and there (I want to run a screen with advertising films on a system without a window manager, that is, a screensaver type), can only library subprojects be connected?

    1 answer 1

    One project - one executable file. If you want to have several projects with several executable files, you need to integrate them into a special project.

    To do this, create another pro file that is one level up. And fill somewhere with such content

     # эта строка нужна, если не хочется заморачиваться # и пусть все проекты собираются в порядке упоминания CONFIG += ordered # а это то, что это такой себе "суперпроект" TEMPLATE = subdirs # список папок с вложенными проектами SUBDIRS = server client/simple client/second 

    That is, now there should be such a structure

     project.pro server/ server.pro ...файлы проекта client/ simple/ simple.pro ... second/ second.pro ... 

    The key point - the name of the folder and the project that it contains must be the same. If this is not possible (for a number of reasons), then you can prescribe everything with pens. That is, a project name is created (virtual) and the parameters are written to it: where the sources are located, on whom it depends. Details in the official documentation . Example right from the bottom

     template = subdirs SUBDIRS = \ lib2 \ # наши проекты lib \ эти имена - фейковые app # а теперь расскажем qmake где искать данные по проекту lib2.subdir = src/lib2 lib.subdir = src/lib app.subdir = src/app # А также, укажем зависимости # теперь проекты lib lib2 будут собраться "в паралель" (а могут и по очереди, как получиться) и только потом будет собираться app. app.depends = lib lib2 

    This method does not contain the word "ordered" and is preferred. It also benefits the build time.

    • Yes, it seems that the project will not be rebuilt quickly, you will have to abandon the idea of ​​building both projects with one click until better times :) Thank you! - asianirish
    • one
      It corresponds in ten minutes. And it will also be collected with one button. But if the dependent project has changed, and we are running the main project, then both will be redefined. - KoVadim
    • if local, then yes. But since the directory is higher, the repository will still need to be redone (re-created). Better just add as a subfolder - asianirish
    • In fact, everything can be dropped into one heap or made a new project, and two old ones as submodules - KoVadim
    • in this case, I don’t think that this subproject will change too often, but I’ll take your advice for the future, thanks again! - asianirish