Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

Running qmake

The behavior of qmake can be customized when it is run by specifying various options on the command line. These allow the build process to be fine-tuned, provide useful diagnostic information, and can be used to specify the target platform for your project.

Command-Line Options

Syntax

The syntax used to run qmake takes the following simple form:

 qmake [mode] [options] files

qmake supports two different modes of operation: In the default mode, qmake will use the description in a project file to generate a Makefile, but it is also possible to use qmake to generate project files. If you want to explicitly set the mode, you must specify it before all other options. The mode can be either of the following two values:

  • -makefile
    qmake output will be a Makefile.
  • -project
    qmake output will be a project file.

The following options are used to specify both general and mode-specific settings. Options that only apply to the Makefile mode are described in the Makefile Mode Options section; options that influence the creation of project files are described in the Project File Options section.

The files argument represents a list of one or more project files, separated by spaces.

Options

A wide range of options can be specified on the command line to qmake in order to customize the build process, and to override default settings for your platform. The following basic options provide usage information, specify where qmake writes the output file, and control the level of debugging information that will be written to the console:

  • -help
    qmake will go over these features and give some useful help.
  • -o file
    qmake output will be directed to file. If this option is not specified, qmake will try to use a suitable file name for its output, depending on the mode it is running in.
    If '-' is specified, output is directed to stdout.
  • -d
    qmake will output debugging information.

For projects that need to be built differently on each target platform, with many subdirectories, you can run qmake with each of the following options to set the corresponding platform-specific variable in each project file:

  • -unix
    qmake will run in unix mode. In this mode, Unix file naming and path conventions will be used, additionally testing for unix (as a scope) will succeed. This is the default mode on all Unices.
  • -macx
    qmake will run in Mac OS X mode. In this mode, Unix file naming and path conventions will be used, additionally testing for macx (as a scope) will succeed. This is the default mode on Mac OS X.
  • -win32
    qmake will run in win32 mode. In this mode, Windows file naming and path conventions will be used, additionally testing for win32 (as a scope) will succeed. This is the default mode on Windows.

The template used for the project is usually specified by the TEMPLATE variable in the project file. We can override or modify this by using the following options:

  • -t tmpl
    qmake will override any set TEMPLATE variables with tmpl, but only after the .pro file has been processed.
  • -tp prefix
    qmake will add the prefix to the TEMPLATE variable.

The level of warning information can be fine-tuned to help you find problems in your project file:

  • -Wall
    qmake will report all known warnings.
  • -Wnone
    No warning information will be generated by qmake.
  • -Wparser
    qmake will only generate parser warnings. This will alert you to common pitfalls and potential problems in the parsing of your project files.
  • -Wlogic
    qmake will warn of common pitfalls and potential problems in your project file. For example, qmake will report whether a file is placed into a list of files multiple times, or if a file cannot be found.

Makefile Mode Options

 qmake -makefile [options] files

In Makefile mode, qmake will generate a Makefile that is used to build the project. Additionally, the following options may be used in this mode to influence the way the project file is generated:

  • -after
    qmake will process assignments given on the command line after the specified files.
  • -nocache
    qmake will ignore the .qmake.cache file.
  • -nodepend
    qmake will not generate any dependency information.
  • -cache file
    qmake will use file as the cache file, ignoring any other .qmake.cache files found.
  • -spec spec
    qmake will use spec as a path to platform and compiler information, and the value of QMAKESPEC will be ignored.

You may also pass qmake assignments on the command line; they will be processed before all of the files specified. For example:

 qmake -makefile -unix -o Makefile "CONFIG+=test" test.pro

This will generate a Makefile, from test.pro with Unix pathnames. However many of the specified options aren't necessary as they are the default. Therefore, the line can be simplified on Unix to:

 qmake "CONFIG+=test" test.pro

If you are certain you want your variables processed after the files specified, then you may pass the -after option. When this is specified, all assignments on the command line after the -after option will be postponed until after the specified files are parsed.

Project Mode Options

 qmake -project [options] files

In project mode, qmake will generate a project file. Additionally, you may supply the following options in this mode:

  • -r
    qmake will look through supplied directories recursively
  • -nopwd
    qmake will not look in your current working directory for source code and only use the specified files

In this mode, the files argument can be a list of files or directories. If a directory is specified, it will be included in the DEPENDPATH variable, and relevant code from there will be included in the generated project file. If a file is given, it will be appended to the correct variable, depending on its extension; for example, .ui files are added to FORMS, and .cpp files are added to SOURCES.

You may also pass assignments on the command line in this mode. When doing so, these assignments will be placed last in the generated project file.

[Previous: qmake Project Files] [Contents] [Next: qmake Platform Notes]

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 53
  2. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  3. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  4. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. La rubrique Qt a besoin de vous ! 1
Page suivante

Le blog Digia au hasard

Logo

Déploiement d'applications Qt Commercial sur les tablettes Windows 8

Le blog Digia est l'endroit privilégié pour la communication sur l'édition commerciale de Qt, où des réponses publiques sont apportées aux questions les plus posées au support. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt qtextended4.4
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web