PDA

View Full Version : SUBDIR qmake structure



mrandreas
28th September 2010, 12:00
I want to organize my project in the following order:

projectname\
projectname.pro
common.pri

projectname\gui\
gui.pro
mainwindow.cpp
mainwindow.h
mainwindow.ui

projectname\aname\
aname.pro
h and cpp files only

projectname\test\
test.pro
main.cpp

projectname.pro:

TEMPLATE = subdirs
SUBDIRS = gui \
aname
QT += core gui
# main app
CONFIG += ordered
SUBDIRS += test

common.pri:

INCLUDEPATH += gui \
aname
WARNINGS += -Wall
# The following keeps the generated files at least somewhat separate
# from the source files.
UI_DIR = uics
MOC_DIR = mocs
OBJECTS_DIR = objs

gui.pro:

! include( ../common.pri ) {
error( Couldn't find the common.pri file! )
}
QT += core gui
FORMS += \
mainwindow.ui
SOURCES += \
mainwindow.cpp
HEADERS += \
mainwindow.h \
OBJECTS_DIR += projectname\gui\mainwindow.h
QMAKE_EXT_OBJ += projectname\gui\mainwindow.h
LIBS += -L../aname -laname


aname.pro:

! include( ../common.pri ) {
error( Couldn't find the common.pri file! )
}
QT += core gui
SOURCES += \
...cpp

HEADERS += \
....h

OBJECTS_DIR += projectname/aname/....h \

QMAKE_EXT_OBJ = projectname/aname/....h \
test.pro
! include( ../common.pri ) {
error( Couldn't find the common.pri file! )
}
QT += core gui
TARGET = test
TEMPLATE = app
SOURCES += \
main.cpp \
LIBS += -L../gui -lgui

I want my header and source located in the same folder, but I want the #include to be <projectname/amame/...h>. I have tried the OBJECTS_DIR and QMAKE_EXT_OBJ but it don't seem to find the header files. It can't find the header in #include <...h> current folder ether. The qtcreator auto completion seems to be a bit smarter since it finds the headers... hehe.
Can anyone see what I'm doing wrong and how I can get the #include <projectname/aname/..>

lyuts
28th September 2010, 14:42
Objects have nothing to do with includes. If you want to be able to include headers as <p1/p2/p3/file> then add a corresponnding path to INCLUDEPATH variable. Set it to "." in common.pri file.

By the way, I think that prefixing your include with project's name is not a good idea.