PDA

View Full Version : Share my qmake project file



ibingow
30th August 2011, 09:19
I don't like the default pro file. The objects will be in release/debug in windows, but in linux they are in the same dir of source files. With my method, the objects will be output into .obj/_win32 in windows, .obj/_linux in linux and .obj/_linux_arm and so on. Moc generated files will be in .moc/$[QT_VERSION](e.g. .moc/4.7.3), because they does not depends on platform, but the qt version.
here is config.pri

CONFIG += #ezx#static ezx
CONFIG += profile
#profiling, -pg is not supported for msvc
debug:!*msvc*:profile {
QMAKE_CXXFLAGS_DEBUG += -pg
QMAKE_LFLAGS_DEBUG += -pg
}

#$$[TARGET_PLATFORM]
#$$[QT_ARCH] #windows symbian windowsce arm
PLATFORM_EXT =
ARCH_EXT =
TOOLCHAIN_EXT =
unix {
PLATFORM_EXT = _unix
*linux*: PLATFORM_EXT = _linux
maemo*: PLATFORM_EXT = _maemo
} else:win32 {
PLATFORM_EXT = _win32
} else:macx {
PLATFORM_EXT = _macx
}

ezx {
QT_VERSION = 2.3.8
CONFIG += qt warn_on release
DEFINES += QT_THREAD_SUPPORT CONFIG_EZX
PLATFORM_EXT = _ezx
QMAKE_CXXFLAGS.ARMCC +=
}

#*arm*: ARCH_EXT = $${ARCH_EXT}_arm
#isEqual(QT_ARCH, arm) {
contains(QT_ARCH, arm.*) {
ARCH_EXT = $${ARCH_EXT}_$${QT_ARCH}
}
*64: ARCH_EXT = $${ARCH_EXT}_x64

*llvm*: TOOLCHAIN_EXT = _llvm
#*msvc*:

DESTDIR = bin
TARGET = $${TARGET}$${PLATFORM_EXT}$${ARCH_EXT}$${TOOLCHAIN _EXT}
OBJECTS_DIR = .obj/$${PLATFORM_EXT}$${ARCH_EXT}$${TOOLCHAIN_EXT}
#for Qt2, Qt3 which does not have QT_VERSION. Qt4: $$[QT_VERSION]
MOC_DIR = .moc/$${QT_VERSION}
RCC_DIR = .rcc/$${QT_VERSION}
UI_DIR = .ui/$${QT_VERSION}

In a pro file, just write a few information and include config.pri, for example

TEMPLATE = app
TARGET = hello
INCLUDEPATH += src
LIBS +=
TRANSLATIONS+= i18n/hello_zh-cn.ts
FORMS =

include(config.pri)
HEADERS = hello.h
SOURCES = hello.cpp