![]() |
Home · Overviews · Examples |
This chapter describes how to set up qmake project files for three common project types that are based on Qt. Although all kinds of projects use many of the same variables, each of them use project-specific variables to customize output files.
Platform-specific variables are not described here; we refer the reader to the Deploying Qt Applications document for information on issues such as building universal binaries for Mac OS X and handling Visual Studio manifest files.
windows | The application is a Windows GUI application. |
console | app template only: the application is a Windows console application. |
TEMPLATE = app DESTDIR = c:/helloapp HEADERS += hello.h SOURCES += hello.cpp SOURCES += main.cpp DEFINES += QT_DLL CONFIG += qt warn_on releaseFor items that are single valued, e.g. the template or the destination directory, we use "="; but for multi-valued items we use "+=" to add to the existing items of that type. Using "=" replaces the item's value with the new value, for example if we wrote DEFINES=QT_DLL, all other definitions would be deleted.
When using the lib template, the following options can be added to the CONFIG variable to determine the type of library that is built:
dll | The library is a shared library (dll). |
staticlib | The library is a static library. |
plugin | The library is a plugin; this also enables the dll option. |
When qmake processes the project file, it will generate a Makefile rule to allow the project to be built in both modes. This can be invoked in the following way:
make allThe build_all option can be added to the CONFIG variable in the project file to ensure that the project is built in both modes by default:Error parsing snippet. This allows the Makefile to be processed using the default rule:
make
make installIt is possible to customize the names of the build targets depending on the target platform. For example, a library or plugin may be named using a different convention on Windows to the one used on Unix platforms:
CONFIG(debug, debug|release) { mac: TARGET = $$join(TARGET,,,_debug) win32: TARGET = $$join(TARGET,,d) }The default behavior in the above snippet is to modify the name used for the build target when building in debug mode. An else clause could be added to the scope to do the same for release mode; left as it is, the target name remains unmodified.
Copyright © 2008 Trolltech | Trademarks | Qt Jambi 4.4.0_01 |