I need to make hierarchy for this example. Base and Components is directories with headers and sources. What template I need to use in place of ???
? What template use in these directories ?
App(???)
--Base
--Component1
--Component2
--Component3
CLI(app)
GUI(app)
test(app)
You can make a Subdirs project and add the subprojects to its .pro file :
TEMPLATE = subdirs
CONFIG += ordered
SUBDIRS += \
Base \
Component1 \
Component2 \
Component3 \
CLI \
GUI \
test
You should bring the subprojects that others depend on, first in the list. Also notice that the name of the .pro file of the subproject should be the same as it's folder name. This way the subprojects are detected and listed in the Projects pane.
The subprojects Base, Component1, Component2 and Component3 could be libraries. Part of .pro file for Base :
TARGET = Base
TEMPLATE = lib
DEFINES += Base_LIBRARY
SOURCES += ...
HEADERS += ...
The subprojects CLI, GUI and test should be app. Part of .pro file for GUI :
TARGET = GUI
TEMPLATE = app
You can use the libraries in each subproject by linking it to the subproject. This can be done by right clicking on the subproject and choosing "Add Library" and then "Internal Library". When you select one library from the list of subprojects, the linking configurations are added to the .pro automatically. It will be like :
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../Base/release/ -lBase
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../Base/debug/ -lBase
else:unix: LIBS += -L$$OUT_PWD/../Base/ -lBase
INCLUDEPATH += $$PWD/../Base
DEPENDPATH += $$PWD/../Base