![]() |
Home · Examples |
[Previous: Running qmake][qmake Manual][Next: qmake Advanced Usage]
Many cross-platform projects can be handled by the qmake's basic configuration features. On some platforms, it is sometimes useful, or even necessary, to take advantage of platform-specific features. qmake knows about many of these features, and these can be accessed via specific variables that only have an effect on the platforms where they are relevant.
Users of each package can override this configuration by invoking qmake with the -spec option (see Running qmake for more information). This makes it possible, for example, to use qmake from a binary package to create a Makefile in a project directory with the following command line invocation:
qmake -spec macx-g++
Directories other than the standard framework directory need to be specified to the build system, and this is achieved by appending linker options to the QMAKE_LFLAGS variable, as shown in the following example:
QMAKE_LFLAGS += -F/path/to/framework/directory/The framework itself is linked in by appending the -framework options and the name of the framework to the LIBS variable:
LIBS += -framework TheFramework
TEMPLATE = lib CONFIG += lib_bundleThe data associated with the library is specified using the QMAKE_BUNDLE_DATA variable. This holds items that will be installed with a library bundle, and is often used to specify a collection of header files, as in the following example:
FRAMEWORK_HEADERS.version = Versions FRAMEWORK_HEADERS.files = path/to/header_one.h path/to/header_two.h FRAMEWORK_HEADERS.path = Headers QMAKE_BUNDLE_DATA += FRAMEWORK_HEADERSHere, the FRAMEWORK_HEADERS variable is a user-defined variable that is used to define the headers required to use a particular framework. Appending it to the QMAKE_BUNDLE_DATA variable ensures that the information about these headers are added to the collection of resources that will be installed with the library bundle. Also, the framework's name and version are specified by QMAKE_FRAMEWORK_BUNDLE_NAME and QMAKE_FRAMEWORK_VERSION variables. By default, the values used for these are obtained from the TARGET and VERSION variables.
See Deploying an Application on Mac OS X for more information about deploying applications and libraries. The architectures to be supported in the binary are specified with the CONFIG variable. For example, the following assignment causes qmake to generate build rules to create a universal binary for both PowerPC and x86 architectures: Creating Universal Binaries
To create a universal binary for your application, you need to be using a version of Qt that has been configured with the -universal option.
CONFIG += x86 ppc
Additionally, developers using a PowerPC-based platform need to set the QMAKE_MAC_SDK variable. This process is discussed in more detail in the deployment guide for Mac OS X.Creating and Moving Xcode Projects
Developers on Mac OS X can take advantage of qmake's support for Xcode project files, as described in Qt is Mac OS X Native, by running qmake to generate an Xcode project from an existing qmake project files. For example:
qmake -spec macx-xcode project.proNote that, if a project is later moved on the disk, qmake must be run again to process the project file and create a new Xcode project file.
However, some developers may need to import an existing qmake project into Visual Studio. qmake is able to take a project file and create a Visual Studio project that contains all the necessary information required by the development environment. This is achieved by setting the qmakeproject template to either vcapp (for application projects) or vclib (for library projects).
This can also be set using a command line option, for example:
qmake -tp vcIt is possible to recursively generate .vcproj files in subdirectories and a .sln file in the main directory, by typing:
qmake -tp vc -rEach time you update the project file, you need to run qmake to generate an updated Visual Studio project.
Removing manifest embedding for application executables can be done with the following assignment to the CONFIG variable:
CONFIG -= embed_manifest_exeAlso, the manifest embedding for DLLs can be removed with the following assignment to the CONFIG variable:
CONFIG -= embed_manifest_dllThis is discussed in more detail in the deployment guide for Windows.
Copyright © 2008 Trolltech | Trademarks | Qt Jambi 4.4.2_01 |