How do I use qmake to build multiple binaries in a single project?

南笙酒味 提交于 2019-11-29 21:03:15

One way of doing it is to have a .pro file per subdirectory.

appsuite.pro:

TEMPLATE = subdirs
SUBDIRS = common app1 app2 app3
app1.depends = common
app2.depends = common
app3.depends = common

app1/app1.pro:

TARGET = app1
SOURCES = main.cpp
INCLUDEPATH += ../common
LIBS += -L../common -lcommon

The common.pro file should build a static library you can then link into the binaries.

common/common.pro:

TEMPLATE = lib
CONFIG = staticlib
SOURCES = project.cpp more.cpp
HEADERS = project.h more.h

One way is to create your global project appsuite.pro, like this:

TEMPLATE = subdirs
SUBDIRS = app1 app2 app3

The subprojects app1.pro and app2.pro should also be created for those applications alone, with a dependency regarding the common/ subdirectory

You can also specify other dependencies in appsuite.pro, for example if app1 depends on app2, as:

app1.depends = app2
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!