How do I build a static library and executable with Qt?

c++, qmake, qt

Solution

Filesystem layout:

MyProject
|_ myproject.pro
|_ core
   |_ core.cpp
   |_ core.h
   |_ core.pro
|_ app
   |_ main.cpp
   |_ app.pro

myproject.pro:

TEMPLATE = subdirs
CONFIG += ordered
SUBDIRS = core \
          app
app.depends = core

core.pro:

TEMPLATE = lib
CONFIG += staticlib
HEADERS = core.h
SOURCES = core.cpp

app.pro:

TEMPLATE = app
SOURCES = main.cpp
LIBS += -L../core -lcore
TARGET = ../app-exe # move executable one dire up

Problem

To simplify the situation, lets say that there are 2 files: `core.cpp` and `main.cpp`. `core.cpp` contains the functionality of the program and `main.cpp` contains the basic `main()` implementation. I want Qt (using qmake and the .pro files) to - first build `core.a` and then - use that and `main.cpp` to build `main.exe`. How do I set this up in the qmake file?

Original source