Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

qt

qmake

I'm writing a small qt app suite that consists of a set of small programs that work on the same set of files. They are organized like this:

/   app1/     main.cpp   app2/     main.cpp   app3/     main.cpp   common/     project.h     project.cpp     somemore.h     somemore.cpp   appsuite.pro 

When I do qmake && make, I want the following binaries to be built:

  • app1/app1
  • app2/app2
  • app3/app3

How do I write appsuite.pro to work like this?
I have heard something about .pri files, but I could not figure out how to use them in my "situation".

Help appreciated,
jrh

like image 615
jrharshath Avatar asked Oct 08 '09 15:10

jrharshath


People also ask

What does run qmake do?

The behavior of qmake can be customized when it is run by specifying various options on the command line. These allow the build process to be fine-tuned, provide useful diagnostic information, and can be used to specify the target platform for your project.

What is qmake command?

QMake is a build system that generates Makefiles for GNU Make or project build files for Microsoft Visual Studio. It is part of the Qt software framework by Trolltech. While it is commonly used to construct Qt-based software, any project can benefit from it.

Does qmake come with Qt?

qmake was created by Trolltech (now The Qt Company). It is distributed and integrated with the Qt application framework, and automates the creation of moc (meta object compiler) and rcc (resource compiler) sources, which are used in Qt's meta-object system and in the integration of binary resources (e.g., pictures).


1 Answers

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 
like image 165
PiedPiper Avatar answered Sep 17 '22 17:09

PiedPiper