×
Namespaces

Variants
Actions
Revision as of 05:03, 24 July 2012 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

How to use qmake to install files preserving file paths

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Tested with
Devices(s): N900
Compatibility
Platform(s): Maemo/MeeGo
Article
Keywords: qmake
Created: gnuton (31 Dec 2010)
Last edited: hamishwillee (24 Jul 2012)

This article shows how to specify to Qmake that a directory and its sub-folder structure be installed to the specified target.

Overview

QMake is a Qt tools which automates the generation of Makefiles from Qt project files (.pro). Makefiles are used to build and to install the files needed by the application. Writing a project file in the right way is fundamental. QMake has several templates such as lib, src and app. All of those targets but the last one define a default target. QMake targets are qmake variables which define a set of files and the path where those files will be installed by "make install" command. The default target contains the name of the built binary (lib or app) and the default path where the lib or binary have to be installed (these info comes from the Qt spec files relative to the platform where qmake runs). In case the application or library need more files to work, the developer have to define other targets to deploy them. In case we are dealing with Maemo this is fundamental to generate a working debian /rpm package.

The problem

As I told before, QMake targets accept files and they are defined in the project file as follow:

INSTALLS += target other_files
 
#define extras_files
other_files.files = file.ext file2.ext
other_files.path = PATH_WHERE_OTHER_FILES_WILL_BE_INSTALLED

The previous snippet will install the files "files.ext" and "file2.ext" in the path defined by other_files.path. Here the problem: How do you write a project file which have to install files in several different directories?

The solution

To explain this better, let's think a scenario like this one. The application needs some png files in the a/ b/ and c/ directories.

├── other_files
│   ├── a
│   │   └── a.png
│   ├── b
│   │   └── b.png
│   └── c
│   └── c.png

Since other_files.path variable accepts just one path, one target for file is needed. There is another way which is define the name of the directory instead of the single files: The project files will look like this:

INSTALLS += target other_files
 
#define extras_files
other_files.files = other_files
other_files.path = PATH_WHERE_OTHER_FILES_WILL_BE_INSTALLED

QMake will install all files and directories in the other_files directory in the path specified by the target. Note that Nokia Qt SDK UI doesn't allow to add directories to project files, but you can anyway use the Nokia Qt SDK editor to edit the project file manually.

This page was last modified on 24 July 2012, at 05:03.
149 page views in the last 30 days.
×