I am looking for a way to organize my project's structure using QMake. I've found the subdirs
template but I have quite a hard time understanding it. I have tried to do something like this. Can anyone please just tell me that I am correct or not.
edit: I have read the following thread How to use QMake's subdirs template? but I am still stuck
My project structure is as follows:
MultiFuncTester.pro
- DMM
(DMM.cpp, DMM.h and Multifunctester.pri)
-Safety
(Safety.cpp, Safety.h and Multifunctester.pri)
-Solar
(Solar.cpp, Solar.h and Multifunctester.pri)
Main
(Main.pro, Main.cpp and Multifunctester.pri)
Here Multifunctester.pri file has common stuff for all the sub directories. I am pasting the MultiFuncTester.pro and .pri file and also the main.pro file
I have made project's pro file as MultiFuncTester.pro :
# build all components recursive
TEMPLATE = subdirs
######## normal build process ########
#
# Make sure your Main.pro is in the last line to ensure correct linking!
#
SUBDIRS = ../../MultiFuncTester/Components/Solar/Build/Solar.pro \
../../MultiFuncTester/Components/DMM/Build/DMM.pro \
../../MultiFuncTester/Components/Safety/Build/Safety.pro \
../../MultiFuncTester/Components/Setup/Build/Setup.pro \
../../MultiFuncTester/Components/Start/Build/Start.pro \
../../MultiFuncTester/Components/Main/Build/Main.pro \
CONFIG += ordered
MultiFunctester.pri file:
######################
# common stuff for all components
######################
TEMPLATE = lib
CONFIG += static \
warn_on \
qt \
thread \
rtti
QT += core \
gui
INCLUDEPATH +=/..\
../../MultiFuncTester/Components \
DEPENDPATH +=/..\
../../MultiFuncTester/Components \
CONFIG += debug_and_release
CONFIG += build_all
QMAKE_CXXFLAGS += -Wall
CONFIG(debug, debug|release) {
CONFIG_SUFFIX = dbg
} else {
CONFIG_SUFFIX = rel
DEFINES += QT_NO_DEBUG \
QT_NO_DEBUG_OUTPUT \
DBT_TRACE_DISCARD \
NDEBUG
CONFIG(gcov) {
QMAKE_CXXFLAGS_RELEASE += -fprofile-arcs -ftest-coverage
QMAKE_LFLAGS_RELEASE += -fprofile-arcs
QMAKE_CXXFLAGS_RELEASE -= -O2
QMAKE_CXXFLAGS_RELEASE += -O0
}
}
CONFIG(crosstgt) {
### To be able to build Target run qmake as follows:
#qmake CONFIG+=crosstgt
CONFIG_SUFFIX = $${CONFIG_SUFFIX}_tgt
DEFINES += TARGET_BUILD
}
OBJECTS_DIR = obj_$${CONFIG_SUFFIX}
MOC_DIR = moc_$${CONFIG_SUFFIX}
DESTDIR = lib_$${CONFIG_SUFFIX}
Main.pro file:
################# include pri file #################
!include("Main.pri") {
error("Main.pri not found")
}
####################################################
################# override some pri settings #################
TEMPLATE = app
TARGET = MultiFuncTester
CONFIG -= static
QT += core \
gui
##############################################################
################# list used MultiFuncTester libraries #################
MultiFuncTester_COMPONENTS_DIR =../../MultiFuncTester/Components
################################################################
################# list MultiFunTester libraries #################
MultiFunTester_COMPONENTS_DIR =../../MultiFuncTester/Components
MultiFunTester_COMPONENTS = DMM \
SOLAR\
Safety\
Setup
################# own sources #################
INCLUDEPATH += ../../MultiFuncTester/Components \
SOURCES +=../Source/Main.cpp
################# set destination path
DESTDIR = bin_$$CONFIG_SUFFIX
################# edit include path
INCLUDEPATH += $$MultiFunctester_COMPONENTS_DIR \
################# start group
LIBS += -Wl,--start-group \
################# include MultiFunctester libraries and set dependencies
for(TheComponent, MultiFunctester_COMPONENTS) {
THELIBPATH = $$MultiFunctester_DIR/$${TheComponent}/Build/lib_$$CONFIG_SUFFIX
PRE_TARGETDEPS += $$THELIBPATH/lib$${TheComponent}.a
LIBS += $$THELIBPATH/lib$${TheComponent}.a
}
################# end group
LIBS += -Wl,--end-group
Each subdirectory has a .pro file which have headers and sources defined and also the common multifunctester.pri file
Please let me know that putting a common static library (MultiFunctester.pri file) is a right approach and what shall it do in the code.....and if not please help me in correcting me wherever I am wrong.
Thanks