User Documentation
RAVL, Recognition And Vision Library
DEVELOP HOME PAGE CLASS LIST CONTENTS
Ravl - QMake


  SUBTOPICS

QMake: A simple "make" system

QMake is a flexible compilation aid, based on the GNU "make" program. It was originally developed for building the RAVL (and its predecessors) library, but it can be used for compiling any software project, however big or small.

Running QMake

The basic command is qm, which is an alias for make that is defined when you set up the RAVL environment.

Typing qm with no arguments will build code that contains basic checks such as array bound violations. It will use (and optionally create) static libraries.

There are various other QMake command-line options you can use, e.g.:

  • The debug options (e.g. qm debug) will build in debugging information.
  • The optimised versions (e.g. qm opt) produce optimised code with no checking.
  • You can include (and create) shared rather than static RAVL libraries in your executable (e.g. qm shared, qm optshared).
  • You can list the command-line options at any time by typing qm help.

The "defs.mk" file

QMake relies on a simple text file ("defs.mk") being present in each directory of the project. Each defs.mk contains a set of variables that describe what must be compiled from that directory.

Information describing the many variables in the defs.mk file for controlling what is built is given under Description File Variables . But to begin with, all you probably need is one or two of these:

  • MAINS A list of programs to compile.
  • SOURCES Other source files to compile.
  • HEADERS Header files for this source code that need to be shared.
  • PLIB Name of library to be created from the entries in SOURCES.
  • PROGLIBS Additional libraries only needed for executables defined in MAINS.
  • USESLIBS Libraries needed by the library defined by PLIB.
  • NESTED Subdirectories to compile.

E.g. if all you wanted to compile was one file called "fred.cc" containing a main program, the defs.mk file would contain the single line:

MAINS = fred.cc

Any of these variables can also be overridden on the command line, e.g.:

qm "MAINS = fred.cc"

However a defs.mk file, even if empty, must exist in the current directory.

Advanced Configuration

QMake uses a configuration file to establish what libraries are available called config.local.(system name) . e.g. config.local.linux. To avoid problems with changes to the default ravl config files, there is an environment variable which if set redirects QMake to a local configuration file. This should avoid odd problems with compilers changing unexpectedly, or different libraries being enabled/disabled. Just added the following to your .cshrc :

setenv QMAKECONFIGHOME /vol/src/QMakeConfig

or for bash users the following should be added to .bashrc

export QMAKECONFIGHOME=/vol/src/QMakeConfig

Build Tags

If you have several versions of a piece of source code, built to different project outs it is very easy to get them confused and build the a piece of code to the wrong place. To avoid doing this you can use a feature of QMake called "Build Tags". This feature attaches a tags your project out, build alias and source tree and then checks the tags are consistent before making a directory.

To use this feature you must:
  • Set BUILD_TAG=(Some tag) in your build alias or shell environment.
  • Write a file in the root of your project out called 'buildTag' containing the name of the build
  • Write a file in the root of the source tree called 'buildTag' containing the name of the build

When you do a build QMake will first go up the source tree looking for the 'buildTag' file, it will use the contents of the first one it finds. It will then check that the value in the file match (less any whitespace) the one in the environment variable BUILD_TAG. It will also check that the buildTag in the project out matches the BUILD_TAG value. Only if these two tests pass will QMake execute the compile command.

Advanced: Including the results of other project outs in your build

It is possible to use the includes and libraries of another project in your own. To do this create a file with a name of your choice with the extension 'qpr'. In this file add a line 'EXTERNAL_PROJECTS += (project out to be used)'. There may be more than project directory if required, the names should be seperated by spaces. Then install this is either the make system's install directory or the libdeps directory of your current project out. You can do this by adding this to a defs.mk in your project.

For example, testBuild.gpr would contain:

EXTERNAL_PROJECTS += /tmp/Build

And the following would be added to a defs.mk in your main source tree:

AUXDIR = lib/RAVL/libdep AUXFILES = anotherProject.qpr

Note: You will have to run make twice to build code, once to install the project file.

Normal Applications:

 Validate Utility used by QMake to do regression testing.
Documentation by CxxDoc: Mon May 14 23:38:44 2012