source: trunk/doc/src/qmake-manual.qdoc@ 321

Last change on this file since 321 was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 164.4 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** Contact: Qt Software Information ([email protected])
5**
6** This file is part of the documentation of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial Usage
10** Licensees holding valid Qt Commercial licenses may use this file in
11** accordance with the Qt Commercial License Agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Nokia.
14**
15** GNU Lesser General Public License Usage
16** Alternatively, this file may be used under the terms of the GNU Lesser
17** General Public License version 2.1 as published by the Free Software
18** Foundation and appearing in the file LICENSE.LGPL included in the
19** packaging of this file. Please review the following information to
20** ensure the GNU Lesser General Public License version 2.1 requirements
21** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
22**
23** In addition, as a special exception, Nokia gives you certain
24** additional rights. These rights are described in the Nokia Qt LGPL
25** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
26** package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you are unsure which license is appropriate for your use, please
37** contact the sales department at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42/*!
43 \page qmake-manual.html
44 \title qmake Manual
45 \startpage {index.html}{Qt Reference Documentation}
46 \nextpage qmake Tutorial
47
48 \ingroup buildsystem
49 \ingroup qttools
50 \keyword qmake
51
52 \c qmake is a tool that helps simplify the build
53 process for development project across different platforms. \c qmake
54 automates the generation of Makefiles so that only a few lines of
55 information are needed to create each Makefile. \c qmake can be used for
56 any software project, whether it is written in Qt or not.
57
58 \c qmake generates a Makefile based on the information in a project
59 file. Project files are created by the developer, and are usually
60 simple, but more sophisticated project files can be created for
61 complex projects.
62 \c qmake contains additional features to support development with Qt,
63 automatically including build rules for \l{moc.html}{moc}
64 and \l{uic.html}{uic}.
65 \c qmake can also generate projects for Microsoft Visual studio
66 without requiring the developer to change the project file.
67
68 \section1 Getting Started
69
70 The \l{qmake Tutorial} and guide to \l{qmake Common Projects} provide overviews
71 that aim to help new users get started with \c qmake.
72
73 \list
74 \o \l{qmake Tutorial}
75 \tableofcontents{1 qmake Tutorial}
76 \endlist
77
78 \list
79 \o \l{qmake Common Projects}
80 \tableofcontents{1 qmake Common Projects}
81 \endlist
82
83 \section1 Table of Contents
84
85 \list
86 \o \l{Using qmake}
87 \tableofcontents{1 Using qmake}
88 \o \l{qmake Project Files}
89 \tableofcontents{1 qmake Project Files}
90 \o \l{Running qmake}
91 \tableofcontents{1 Running qmake}
92 \o \l{qmake Platform Notes}
93 \tableofcontents{1 qmake Platform Notes}
94 \o \l{qmake Advanced Usage}
95 \tableofcontents{1 qmake Advanced Usage}
96 \o \l{Using Precompiled Headers}
97 \tableofcontents{1 Using Precompiled Headers}
98 \o \l{qmake Reference}
99 \tableofcontents{1 qmake Reference}
100 \o \l{qmake Variable Reference}
101 \tableofcontents{1 qmake Variable Reference}
102 \o \l{qmake Function Reference}
103 \tableofcontents{1 qmake Function Reference}
104 \o \l{Configuring qmake's Environment}
105 \tableofcontents{1 Configuring qmake's Environment}
106 \endlist
107*/
108
109/*!
110 \page qmake-using.html
111 \title Using qmake
112 \contentspage {qmake Manual}{Contents}
113 \previouspage qmake Manual
114 \nextpage qmake Project Files
115
116 \c qmake provides a project-oriented system for managing the build
117 process for applications, libraries, and other components. This
118 approach gives developers control over the source files used, and
119 allows each of the steps in the process to be described concisely,
120 typically within a single file. \c qmake expands the information in
121 each project file to a Makefile that executes the necessary commands
122 for compiling and linking.
123
124 In this document, we provide a basic introduction to project files,
125 describe some of the main features of \c qmake, and show how to use
126 \c qmake on the command line.
127
128 \section1 Describing a Project
129
130 Projects are described by the contents of project (\c .pro) files.
131 The information within these is used by \c qmake to generate a Makefile
132 containing all the commands that are needed to build each project.
133 Project files typically contain a list of source and header files,
134 general configuration information, and any application-specific details,
135 such as a list of extra libraries to link against, or a list of extra
136 include paths to use.
137
138 Project files can contain a number of different elements, including
139 comments, variable declarations, built-in functions, and some simple
140 control structures. In most simple projects, it is only necessary
141 to declare the source and header files that are used to build the
142 project with some basic configuration options.
143
144 Complete examples of project files can be found in the
145 \l{qmake Tutorial}.
146 An introduction to project files can be found in the
147 \l{qmake Project Files} chapter, and a more detailed description is
148 available in the \l{qmake Reference}.
149
150 \section1 Building a Project
151
152 For simple projects, you only need to run \c qmake in the top
153 level directory of your project. By default, \c qmake generates a
154 Makefile that you then use to build the project, and you can then
155 run your platform's \c make tool to build the project.
156
157 \c qmake can also be used to generate project files. A full
158 description of \c{qmake}'s command line options can be found in the
159 \l{Running qmake} chapter of this manual.
160
161 \section1 Using Precompiled Headers
162
163 In large projects, it is possible to take advantage of precompiled
164 header files to speed up the build process. This feature is described
165 in detail in the \l{Using Precompiled Headers} chapter.
166*/
167
168/*!
169 \page qmake-project-files.html
170 \title qmake Project Files
171 \contentspage {qmake Manual}{Contents}
172 \previouspage Using qmake
173 \nextpage Running qmake
174
175 Project files contain all the information required by \c qmake to build
176 your application, library, or plugin. The resources used by your project
177 are generally specified using a series of declarations, but support for
178 simple programming constructs allow you to describe different build
179 processes for different platforms and environments.
180
181 \tableofcontents
182
183 \section1 Project File Elements
184
185 The project file format used by \c qmake can be used to support both
186 simple and fairly complex build systems. Simple project files will
187 use a straightforward declarative style, defining standard variables
188 to indicate the source and header files that are used in the project.
189 Complex projects may use the control flow structures to fine-tune the
190 build process.
191
192 The following sections describe the different types of elements used
193 in project files.
194
195 \section2 Variables
196
197 In a project file, variables are used to hold lists of strings.
198 In the simplest projects, these variables inform \c qmake about the
199 configuration options to use, or supply filenames and paths to use
200 in the build process.
201
202 \c qmake looks for certain variables in each project file, and it
203 uses the contents of these to determine what it should write to a
204 Makefile. For example, the list of values in the \c HEADERS and
205 \c SOURCES variables are used to tell \c qmake about header and
206 source files in the same directory as the project file.
207
208 Variables can also be used internally to store temporary lists of values,
209 and existing lists of values can be overwritten or extended with new
210 values.
211
212 The following lines show how lists of values are assigned to variables:
213
214 \snippet doc/src/snippets/qmake/variables.pro 0
215
216 Note that the first assignment only includes values that are specified on
217 the same line as the \c SOURCES variable. The second assignment splits
218 the items across lines by using the \c \\ character.
219
220 The list of values in a variable is extended in the following way:
221
222 \snippet doc/src/snippets/qmake/variables.pro 1
223
224 The \c CONFIG variable is another special variable that \c qmake
225 uses when generating a Makefile. It is discussed in the section on
226 \l{#GeneralConfiguration}{general configuration} later in this chapter.
227 In the above line, \c qt is added to the list of existing values
228 contained in \c CONFIG.
229
230 The following table lists the variables that \c qmake recognizes, and
231 describes what they should contain.
232
233 \table
234 \header \o Variable \o Contents
235 \row \o CONFIG \o General project configuration options.
236 \row \o DESTDIR \o The directory in which the executable or binary file will
237 be placed.
238 \row \o FORMS \o A list of .ui files to be processed by \c uic.
239 \row \o HEADERS \o A list of filenames of header (.h) files used when
240 building the project.
241 \row \o QT \o Qt-specific configuration options.
242 \row \o RESOURCES \o A list of resource (.rc) files to be included in the
243 final project. See the \l{The Qt Resource System} for
244 more information about these files.
245 \row \o SOURCES \o A list of source code files to be used when building
246 the project.
247 \row \o TEMPLATE \o The template to use for the project. This determines
248 whether the output of the build process will be an
249 application, a library, or a plugin.
250 \endtable
251
252 The contents of a variable can be read by prepending the variable name with
253 \c $$. This can be used to assign the contents of one variable to another:
254
255 \snippet doc/src/snippets/qmake/dereferencing.pro 0
256
257 The \c $$ operator is used extensively with built-in functions that operate
258 on strings and lists of values. These are described in the chapter on
259 \l{qmake Advanced Usage}.
260
261 Normally, variables are used to contain whitespace-separated lists
262 of values. However, it is sometimes necessary to specify values containing
263 spaces. These must be quoted in the following way:
264
265 \snippet doc/src/snippets/qmake/quoting.pro 0
266
267 The quoted text is treated as a single item in the list of values held by
268 the variable.
269
270 \section2 Comments
271
272 You can add comments to project files. Comments begin with the \c
273 # character and continue to the end of the same line. For example:
274
275 \snippet doc/src/snippets/qmake/comments.pro 0
276
277 To include the \c # character in variable assignments, it is necessary
278 to use the contents of the built-in \c LITERAL_HASH variable. See the
279 \l{qmake Variable Reference#LITERAL_HASH}{variable reference} for more
280 information.
281
282 \section2 Built-in Functions and Control Flow
283
284 \c qmake provides a number of built-in functions to allow the contents
285 of variables to be processed. The most commonly used function in simple
286 project files is the \c include function which takes a filename as an
287 argument. The contents of the given file are included in the project
288 file at the place where the \c include function is used.
289 The \c include function is most commonly used to include other project
290 files:
291
292 \snippet doc/src/snippets/qmake/include.pro 0
293
294 Support for conditional structures is made available via
295 \l{qmake Advanced Usage#scopes}{scopes} that behave like \c if
296 statements in programming languages:
297
298 \snippet doc/src/snippets/qmake/scopes.pro 0
299
300 The assignments inside the braces are only made if the condition is
301 true. In this case, the special \c win32 variable must be set; this
302 happens automatically on Windows, but this can also be specified on
303 other platforms by running \c qmake with the \c{-win32} command line
304 option (see \l{Running qmake} for more information). The opening
305 brace must stand on the same line as the condition.
306
307 Simple loops are constructed by iterating over lists of values using
308 the built-in \c for function. The following code adds directories
309 to the \l{qmake Variable Reference#SUBDIRS}{SUBDIRS} variable, but
310 only if they exist:
311
312 \snippet doc/src/snippets/qmake/functions.pro 0
313
314 More complex operations on variables that would usually require loops
315 are provided by built-in functions such as \c find, \c unique, and
316 \c count. These functions, and many others are provided to manipulate
317 strings and paths, support user input, and call external tools. A list
318 of the functions available can be found in the
319 \l{qmake Advanced Usage} chapter of this manual.
320
321 \section1 Project Templates
322
323 The \c TEMPLATE variable is used to define the type of project that will
324 be built. If this is not declared in the project file, \c qmake assumes
325 that an application should be built, and will generate an appropriate
326 Makefile (or equivalent file) for the purpose.
327
328 The types of project available are listed in the following table with
329 information about the files that \c qmake will generate for each of them:
330
331 \table
332 \header \o Template \o Description of \c qmake output
333 \row \o app (default) \o Creates a Makefile to build an application.
334 \row \o lib \o Creates a Makefile to build a library.
335 \row \o subdirs \o Creates a Makefile containing rules for the
336 subdirectories specified using the \l{qmake Variable Reference#SUBDIRS}{SUBDIRS}
337 variable. Each subdirectory must contain its own project file.
338 \row \o vcapp \o Creates a Visual Studio Project file to build
339 an application.
340 \row \o vclib \o Creates a Visual Studio Project file to build a library.
341 \endtable
342
343 See the \l{qmake Tutorial} for advice on writing project files for
344 projects that use the \c app and \c lib templates.
345
346 When the \c subdirs template is used, \c qmake generates a Makefile
347 to examine each specified subdirectory, process any project file it finds
348 there, and run the platform's \c make tool on the newly-created Makefile.
349 The \l{qmake Variable Reference#SUBDIRS}{SUBDIRS} variable is used to
350 contain a list of all the subdirectories to be processed.
351
352 \target GeneralConfiguration
353 \section1 General Configuration
354
355 The \l{qmake Variable Reference#CONFIG}{CONFIG variable} specifies the
356 options and features that the compiler should use and the libraries that
357 should be linked against. Anything can be added to the \c CONFIG variable,
358 but the options covered below are recognized by \c qmake internally.
359
360 The following options control the compiler flags that are used to build the
361 project:
362
363 \table
364 \header \o Option \o Description
365 \row \o release \o The project is to be built in release mode.
366 This is ignored if \c debug is also specified.
367 \row \o debug \o The project is to be built in debug mode.
368 \row \o debug_and_release \o The project is built in \e both debug and
369 release modes.
370 \row \o debug_and_release_target \o The project is built in \e both debug
371 and release modes. TARGET is built into \e both the debug and release directories.
372 \row \o build_all \o If \c debug_and_release is specified, the project is
373 built in both debug and release modes by default.
374 \row \o autogen_precompile_source \o Automatically generates a \c .cpp file that includes
375 the precompiled header file specified in the .pro file.
376 \row \o ordered \o When using the \c subdirs template, this option
377 specifies that the directories listed should be processed in the
378 order in which they are given.
379 \row \o warn_on \o The compiler should output as many warnings as possible.
380 This is ignored if \c warn_off is specified.
381 \row \o warn_off \o The compiler should output as few warnings as possible.
382 \row \o copy_dir_files \o Enables the install rule to also copy directories, not just files.
383 \endtable
384
385 The \c debug_and_release option is special in that it enables \e both debug and
386 release versions of a project to be built. In such a case, the Makefile that
387 \c qmake generates includes a rule that builds both versions, and this can be
388 invoked in the following way:
389
390 \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 0
391
392 Adding the \c build_all option to the \c CONFIG variable makes this rule
393 the default when building the project, and installation targets will be
394 created for both debug and release builds.
395
396 Note that each of the options specified in the \c CONFIG variable can also be
397 used as a scope condition.
398 You can test for the presence of certain configuration options by using the
399 built-in \l{qmake Function Reference#CONFIG(config)}{CONFIG()} function.
400 For example, the following lines show the function as the condition in a scope
401 to test whether only the \c opengl option is in use:
402
403 \snippet doc/src/snippets/qmake/configscopes.pro 4
404 \snippet doc/src/snippets/qmake/configscopes.pro 5
405
406 This enables different configurations to be defined for \c release and
407 \c debug builds, and is described in more detail in the
408 \l{qmake Advanced Usage#Scopes}{Scopes} section of the
409 \l{qmake Advanced Usage}{Advanced Usage} chapter of this manual.
410
411 The following options define the type of project to be built. Note that some
412 of these options only take effect when used on the relevant platform. On other
413 platforms, they have no effect.
414
415 \table
416 \header \o Option \o Description
417 \row \o qt \o The project is a Qt application and should link against the Qt
418 library. You can use the \c QT variable to control any additional
419 Qt modules that are required by your application.
420 \row \o thread \o The project is a multi-threaded application.
421 \row \o x11 \o The project is an X11 application or library.
422 \endtable
423
424 When using \l{qmake Variable Reference#TEMPLATE}{application or library project
425 templates}, more specialized configuration options can be used to fine tune the
426 build process. These are explained in details in the
427 \l{qmake-common-projects.html}{Common Projects} chapter of this manual.
428
429 For example, if your application uses the Qt library and you want to
430 build it as a multi-threaded application in \c debug mode, your project
431 file will contain the following line:
432
433 \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 1
434
435 Note, that you must use "+=", not "=", or \c qmake will not be able to
436 use Qt's configuration to determine the settings needed for your project.
437
438 \section1 Declaring Qt Libraries
439
440 If the \c CONFIG variable contains the \c qt value, qmake's support for Qt
441 applications is enabled. This makes it possible to fine-tune which of the
442 Qt modules are used by your application. This is achieved with the \c QT
443 variable which can be used to declare the required extension modules.
444 For example, we can enable the XML and network modules in the following way:
445
446 \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 2
447
448 Note that \c QT includes the \c core and \c gui modules by default, so the
449 above declaration \e adds the network and XML modules to this default list.
450 The following assignment \e omits the default modules, and will lead to
451 errors when the application's source code is being compiled:
452
453 \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 3
454
455 If you want to build a project \e without the \c gui module, you need to
456 exclude it with the "-=" operator. By default, \c QT contains both
457 \c core and \c gui, so the following line will result in a minimal
458 Qt project being built:
459
460 \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 4
461
462 The table below shows the options that can be used with the \c QT variable
463 and the features that are associated with each of them:
464
465 \table
466 \header \o Option \o Features
467 \row \o core (included by default) \o QtCore module
468 \row \o gui (included by default) \o QtGui module
469 \row \o network \o QtNetwork module
470 \row \o opengl \o QtOpenGL module
471 \row \o sql \o QtSql module
472 \row \o svg \o QtSvg module
473 \row \o xml \o QtXml module
474 \row \o xmlpatterns \o QtXmlPatterns module
475 \row \o qt3support \o Qt3Support module
476 \endtable
477
478 Note that adding the \c opengl option to the \c QT variable automatically
479 causes the equivalent option to be added to the \c CONFIG variable.
480 Therefore, for Qt applications, it is not necessary to add the \c opengl
481 option to both \c CONFIG and \c{QT}.
482
483 \section1 Configuration Features
484
485 \c qmake can be set up with extra configuration features that are specified
486 in feature (.prf) files. These extra features often provide support for
487 custom tools that are used during the build process. To add a feature to
488 the build process, append the feature name (the stem of the feature filename)
489 to the \c CONFIG variable.
490
491 For example, \c qmake can configure the build process to take advantage
492 of external libraries that are supported by
493 \l{http://www.freedesktop.org/wiki/Software_2fpkgconfig}{pkg-config},
494 such as the D-Bus and ogg libraries, with the following lines:
495
496 \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 5
497
498 More information about features can be found in the
499 \l{qmake Advanced Usage#Adding New Configuration Features}
500 {Adding New Configuration Features} section of the \l{qmake Advanced Usage}
501 chapter.
502
503 \section1 Declaring Other Libraries
504
505 If you are using other libraries in your project in addition to those
506 supplied with Qt, you need to specify them in your project file.
507
508 The paths that \c qmake searches for libraries and the specific libraries
509 to link against can be added to the list of values in the
510 \l{qmake Variable Reference#LIBS}{LIBS} variable. The paths to the libraries
511 themselves can be given, or the familiar Unix-style notation for specifying
512 libraries and paths can be used if preferred.
513
514 For example, the following lines show how a library can be specified:
515
516 \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 6
517
518 The paths containing header files can also be specified in a similar way
519 using the \l{qmake Variable Reference#INCLUDEPATH}{INCLUDEPATH} variable.
520
521 For example, it is possible to add several paths to be searched for header
522 files:
523
524 \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 7
525*/
526
527/*!
528 \page qmake-running.html
529 \title Running qmake
530 \contentspage {qmake Manual}{Contents}
531 \previouspage qmake Project Files
532 \nextpage qmake Platform Notes
533
534 The behavior of \c qmake can be customized when it is run by
535 specifying various options on the command line. These allow the
536 build process to be fine-tuned, provide useful diagnostic
537 information, and can be used to specify the target platform for
538 your project.
539
540 \tableofcontents
541
542 \target Commands
543 \section1 Command-Line Options
544
545 \section2 Syntax
546
547 The syntax used to run \c qmake takes the following simple form:
548
549 \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 8
550
551 \c qmake supports two different modes of operation: In the default mode,
552 \c qmake will use the description in a project file to generate a Makefile,
553 but it is also possible to use \c qmake to generate project files.
554 If you want to explicitly set the mode, you must specify it before all
555 other options. The \c mode can be either of the following two values:
556
557 \list
558 \o \c -makefile \BR
559 \c qmake output will be a Makefile.
560 \o \c -project \BR
561 \c qmake output will be a project file.
562 \endlist
563
564 The following \c options are used to specify both general and mode-specific
565 settings. Options that only apply to the Makefile mode are described in the
566 \l{#MakefileMode}{Makefile Mode Options} section; options that influence the
567 creation of project files are described in the
568 \l{#ProjectMode}{Project File Options} section.
569
570 The \c files argument represents a list of one or more project files, separated
571 by spaces.
572
573 \section2 Options
574
575 A wide range of options can be specified on the command line to \c qmake in
576 order to customize the build process, and to override default settings for
577 your platform. The following basic options provide usage information, specify
578 where \c qmake writes the output file, and control the level of debugging
579 information that will be written to the console:
580
581 \list
582 \o \c -help \BR
583 \c qmake will go over these features and give some useful help.
584 \o \c -o file \BR
585 \c qmake output will be directed to \e file. If this option
586 is not specified, \c qmake will try to use a suitable file name for its
587 output, depending on the mode it is running in.\BR
588 If '-' is specified, output is directed to stdout.
589 \o \c -d \BR
590 \c qmake will output debugging information.
591 \endlist
592
593 For projects that need to be built differently on each target platform, with
594 many subdirectories, you can run \c qmake with each of the following
595 options to set the corresponding platform-specific variable in each
596 project file:
597
598 \list
599 \o \c -unix \BR
600 \c qmake will run in unix mode. In this mode, Unix file
601 naming and path conventions will be used, additionally testing for \c unix
602 (as a scope) will succeed. This is the default mode on all Unices.
603 \o \c -macx \BR
604 \c qmake will run in Mac OS X mode. In this mode, Unix file
605 naming and path conventions will be used, additionally testing for \c macx
606 (as a scope) will succeed. This is the default mode on Mac OS X.
607 \o \c -win32 \BR
608 \c qmake will run in win32 mode. In this mode, Windows file naming and path
609 conventions will be used, additionally testing for \c win32 (as a scope)
610 will succeed. This is the default mode on Windows.
611 \endlist
612
613 The template used for the project is usually specified by the \c TEMPLATE
614 variable in the project file. We can override or modify this by using the
615 following options:
616
617 \list
618 \o \c -t tmpl \BR
619 \c qmake will override any set \c TEMPLATE variables with tmpl, but only
620 \e after the .pro file has been processed.
621 \o \c -tp prefix \BR
622 \c qmake will add the prefix to the \c TEMPLATE variable.
623 \endlist
624
625 The level of warning information can be fine-tuned to help you find problems in
626 your project file:
627
628 \list
629 \o \c -Wall \BR
630 \c qmake will report all known warnings.
631 \o \c -Wnone \BR
632 No warning information will be generated by \c qmake.
633 \o \c -Wparser \BR
634 \c qmake will only generate parser warnings. This will alert
635 you to common pitfalls and potential problems in the parsing of your
636 project files.
637 \o \c -Wlogic \BR
638 \c qmake will warn of common pitfalls and potential problems in your
639 project file. For example, \c qmake will report whether a file is placed
640 into a list of files multiple times, or if a file cannot be found.
641 \endlist
642
643 \target MakefileMode
644 \section2 Makefile Mode Options
645
646 \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 9
647
648 In Makefile mode, \c qmake will generate a Makefile that is used to build the
649 project. Additionally, the following options may be used in this mode to
650 influence the way the project file is generated:
651
652 \list
653 \o \c -after \BR
654 \c qmake will process assignments given on the command line after
655 the specified files.
656 \o \c -nocache \BR
657 \c qmake will ignore the .qmake.cache file.
658 \o \c -nodepend \BR
659 \c qmake will not generate any dependency information.
660 \o \c -cache file \BR
661 \c qmake will use \e file as the cache file, ignoring any other
662 .qmake.cache files found.
663 \o \c -spec spec \BR
664 \c qmake will use \e spec as a path to platform and compiler information,
665 and the value of \c QMAKESPEC will be ignored.
666 \endlist
667
668 You may also pass \c qmake assignments on the command line;
669 they will be processed before all of the files specified. For example:
670
671 \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 10
672
673 This will generate a Makefile, from test.pro with Unix pathnames. However
674 many of the specified options aren't necessary as they are the default.
675 Therefore, the line can be simplified on Unix to:
676
677 \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 11
678
679 If you are certain you want your variables processed after the
680 files specified, then you may pass the \c -after option. When this
681 is specified, all assignments on the command line after the \c -after
682 option will be postponed until after the specified files are parsed.
683
684 \target ProjectMode
685 \section2 Project Mode Options
686
687 \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 12
688
689 In project mode, \c qmake will generate a project file. Additionally, you
690 may supply the following options in this mode:
691
692 \list
693 \o \c -r \BR
694 \c qmake will look through supplied directories recursively
695 \o \c -nopwd \BR
696 \c qmake will not look in your current working directory for
697 source code and only use the specified \c files
698 \endlist
699
700 In this mode, the \c files argument can be a list of files or directories.
701 If a directory is specified, it will be included in the \c DEPENDPATH
702 variable, and relevant code from there will be included in the generated
703 project file. If a file is given, it will be appended to the correct
704 variable, depending on its extension; for example, .ui files are added
705 to \c FORMS, and .cpp files are added to \c SOURCES.
706
707 You may also pass assignments on the command line in this mode. When doing
708 so, these assignments will be placed last in the generated project file.
709*/
710
711/*!
712 \page qmake-platform-notes.html
713 \title qmake Platform Notes
714 \contentspage {qmake Manual}{Contents}
715 \previouspage Running qmake
716 \nextpage qmake Advanced Usage
717
718 Many cross-platform projects can be handled by the \c{qmake}'s basic
719 configuration features. On some platforms, it is sometimes useful, or even
720 necessary, to take advantage of platform-specific features. \c qmake knows
721 about many of these features, and these can be accessed via specific
722 variables that only have an effect on the platforms where they are relevant.
723
724 \tableofcontents
725
726 \section1 Mac OS X
727
728 Features specific to this platform include support for creating universal
729 binaries, frameworks and bundles.
730
731 \section2 Source and Binary Packages
732
733 The version of \c qmake supplied in source packages is configured slightly
734 differently to that supplied in binary packages in that it uses a different
735 feature specification. Where the source package typically uses the
736 \c macx-g++ specification, the binary package is typically configured to
737 use the \c macx-xcode specification.
738
739 Users of each package can override this configuration by invoking \c qmake
740 with the \c -spec option (see \l{Running qmake} for more information). This
741 makes it possible, for example, to use \c qmake from a binary package to
742 create a Makefile in a project directory with the following command line
743 invocation:
744
745 \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 13
746
747 \section2 Using Frameworks
748
749 \c qmake is able to automatically generate build rules for linking against
750 frameworks in the standard framework directory on Mac OS X, located at
751 \c{/Library/Frameworks/}.
752
753 Directories other than the standard framework directory need to be specified
754 to the build system, and this is achieved by appending linker options to the
755 \l{qmake Variable Reference#QMAKE_LFLAGS}{QMAKE_LFLAGS} variable, as shown
756 in the following example:
757
758 \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 14
759
760 The framework itself is linked in by appending the \c{-framework} options and
761 the name of the framework to the \l{qmake Variable Reference#LIBS}{LIBS}
762 variable:
763
764 \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 15
765
766 \section2 Creating Frameworks
767
768 Any given library project can be configured so that the resulting library
769 file is placed in a
770 \l{http://developer.apple.com/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WhatAreFrameworks.html}
771 {framework}, ready for deployment. To do this, set up the project to use the
772 \l{qmake Variable Reference#TEMPLATE}{\c lib template} and add the
773 \c lib_bundle option to the
774 \l{qmake Variable Reference#CONFIG}{CONFIG} variable:
775
776 \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 16
777
778 The data associated with the library is specified using the
779 \l{qmake Variable Reference#QMAKE_BUNDLE_DATA}{QMAKE_BUNDLE_DATA}
780 variable. This holds items that will be installed with a library
781 bundle, and is often used to specify a collection of header files,
782 as in the following example:
783
784 \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 17
785
786 Here, the \c FRAMEWORK_HEADERS variable is a user-defined variable that
787 is used to define the headers required to use a particular framework.
788 Appending it to the \c QMAKE_BUNDLE_DATA variable ensures that the
789 information about these headers are added to the collection of
790 resources that will be installed with the library bundle. Also, the
791 framework's name and version are specified by
792 \l{qmake Variable Reference#QMAKE_FRAMEWORK_BUNDLE_NAME}
793 {QMAKE_FRAMEWORK_BUNDLE_NAME}
794 and \l{qmake Variable Reference#QMAKE_FRAMEWORK_VERSION}
795 {QMAKE_FRAMEWORK_VERSION} variables. By default, the values used for
796 these are obtained from the \l{qmake Variable Reference#TARGET}{TARGET}
797 and \l{qmake Variable Reference#VERSION}{VERSION} variables.
798
799 See \l{Deploying an Application on Mac OS X} for more information about
800 deploying applications and libraries.
801
802 \section2 Creating Universal Binaries
803
804 To create a universal binary for your application, you need to be using
805 a version of Qt that has been configured with the \c{-universal} option.
806
807 The architectures to be supported in the binary are specified with the
808 \l{qmake Variable Reference#CONFIG}{CONFIG} variable. For example, the
809 following assignment causes \c qmake to generate build rules to create
810 a universal binary for both PowerPC and x86 architectures:
811
812 \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 18
813
814 Additionally, developers using a PowerPC-based platform need to set the
815 \l{qmake Variable Reference#QMAKE_MAC_SDK}{QMAKE_MAC_SDK} variable.
816 This process is discussed in more detail in the
817 \l{Deploying an Application on Mac OS X#Architecture Dependencies}{deployment guide for Mac OS X}.
818
819 \section2 Creating and Moving Xcode Projects
820
821 Developers on Mac OS X can take advantage of \c{qmake}'s support for Xcode
822 project files, as described in
823 \l{Qt is Mac OS X Native#Development Tools}{Qt is Mac OS X Native},
824 by running \c qmake to generate an Xcode project from an existing \c qmake
825 project files. For example:
826
827 \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 19
828
829 Note that, if a project is later moved on the disk, \c qmake must be run
830 again to process the project file and create a new Xcode project file.
831
832 \section1 Windows
833
834 Features specific to this platform include support for creating Visual
835 Studio project files and handling manifest files when deploying Qt
836 applications developed using Visual Studio 2005.
837
838 \section2 Creating Visual Studio Project Files
839
840 Developers using Visual Studio to write Qt applications can use the
841 Visual Studio integration facilities provided with the
842 \l{Qt Commercial Editions} and do not need to worry about how
843 project dependencies are managed.
844
845 However, some developers may need to import an existing \c qmake project
846 into Visual Studio. \c qmake is able to take a project file and create a
847 Visual Studio project that contains all the necessary information required
848 by the development environment. This is achieved by setting the \c qmake
849 \l{qmake Variable Reference#TEMPLATE}{project template} to either \c vcapp
850 (for application projects) or \c vclib (for library projects).
851
852 This can also be set using a command line option, for example:
853
854 \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 20
855
856 It is possible to recursively generate \c{.vcproj} files in subdirectories
857 and a \c{.sln} file in the main directory, by typing:
858
859 \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 21
860
861
862 Each time you update the project file, you need to run \c qmake to generate
863 an updated Visual Studio project.
864
865 \section2 Visual Studio 2005 Manifest Files
866
867 When deploying Qt applications built using Visual Studio 2005, it is
868 necessary to ensure that the manifest file, created when the application
869 was linked, is handled correctly. This is handled automatically for
870 projects that generate DLLs.
871
872 Removing manifest embedding for application executables can be done with
873 the following assignment to the \l{qmake Variable Reference#CONFIG}
874 {CONFIG} variable:
875
876 \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 22
877
878 Also, the manifest embedding for DLLs can be removed with the following
879 assignment to the \l{qmake Variable Reference#CONFIG}{CONFIG} variable:
880
881 \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 23
882
883 This is discussed in more detail in the
884 \l{Deploying an Application on Windows#Visual Studio 2005 Onwards}
885 {deployment guide for Windows}.
886*/
887
888/*!
889 \page qmake-reference.html
890 \title qmake Reference
891 \contentspage {qmake Manual}{Contents}
892 \previouspage Using Precompiled Headers
893 \nextpage qmake Variable Reference
894
895 This reference is a detailed index of all the variables and function
896 that are available for use in \c qmake project files.
897
898 \section1 Variable Reference
899
900 The \l{qmake Variable Reference} describes the variables that are
901 recognized by \c qmake when configuring the build process for
902 projects.
903
904 \section1 Function Reference
905
906 The \l{qmake Function Reference} describes the function that can be
907 used to process the contents of variables defined in project files.
908
909 \target FrequentlyUsedVariables
910 \section1 Frequently Used Variables
911
912 The following variables are frequently used in project files to describe
913 common aspects of the build process. These are fully described in the
914 \l{qmake-variable-reference.html}{Variable Reference}.
915
916 \list
917 \o \l{qmake Variable Reference#CONFIG}{CONFIG}
918 \o \l{qmake Variable Reference#DEF_FILE}{DEF_FILE}
919 \o \l{qmake Variable Reference#DEFINES}{DEFINES}
920 \o \l{qmake Variable Reference#DESTDIR}{DESTDIR}
921 \o \l{qmake Variable Reference#DISTFILES}{DISTFILES}
922 \o \l{qmake Variable Reference#DLLDESTDIR}{DLLDESTDIR}
923 \o \l{qmake Variable Reference#FORMS}{FORMS}
924 \o \l{qmake Variable Reference#FORMS3}{FORMS3}
925 \o \l{qmake Variable Reference#GUID}{GUID}
926 \o \l{qmake Variable Reference#HEADERS}{HEADERS}
927 \o \l{qmake Variable Reference#INCLUDEPATH}{INCLUDEPATH}
928 \o \l{qmake Variable Reference#LEXSOURCES}{LEXSOURCES}
929 \o \l{qmake Variable Reference#LIBS}{LIBS}
930 \o \l{qmake Variable Reference#MOC_DIR}{MOC_DIR}
931 \o \l{qmake Variable Reference#OBJECTS_DIR}{OBJECTS_DIR}
932 \o \l{qmake Variable Reference#QT}{QT}
933 \o \l{qmake Variable Reference#RCC_DIR}{RCC_DIR}
934 \o \l{qmake Variable Reference#REQUIRES}{REQUIRES}
935 \o \l{qmake Variable Reference#SOURCES}{SOURCES}
936 \o \l{qmake Variable Reference#SUBDIRS}{SUBDIRS}
937 \o \l{qmake Variable Reference#TARGET}{TARGET}
938 \o \l{qmake Variable Reference#TEMPLATE}{TEMPLATE}
939 \o \l{qmake Variable Reference#TRANSLATIONS}{TRANSLATIONS}
940 \o \l{qmake Variable Reference#UI_DIR}{UI_DIR}
941 \o \l{qmake Variable Reference#UI_HEADERS_DIR}{UI_HEADERS_DIR}
942 \o \l{qmake Variable Reference#UI_SOURCES_DIR}{UI_SOURCES_DIR}
943 \o \l{qmake Variable Reference#VERSION}{VERSION}
944 \o \l{qmake Variable Reference#YACCSOURCES}{YACCSOURCES}
945 \endlist
946
947 \section1 Environment Variables and Configuration
948
949 The \l{Configuring qmake's Environment} chapter of this manual
950 describes the environment variables that \c qmake uses when
951 configuring the build process.
952*/
953
954/*!
955 \page qmake-variable-reference.html
956 \title qmake Variable Reference
957 \contentspage {qmake Manual}{Contents}
958 \previouspage qmake Reference
959 \nextpage qmake Function Reference
960
961 \c{qmake}'s fundamental behavior is influenced by variable declarations that
962 define the build process of each project. Some of these declare resources,
963 such as headers and source files, that are common to each platform; others
964 are used to customize the behavior of compilers and linkers on specific
965 platforms.
966
967 Platform-specific variables follow the naming pattern of the
968 variables which they extend or modify, but include the name of the relevant
969 platform in their name. For example, \c QMAKE_LIBS can be used to specify a list
970 of libraries that a project needs to link against, and \c QMAKE_LIBS_X11 can be
971 used to extend or override this list.
972
973 \tableofcontents{3}
974
975 \target CONFIG
976 \section1 CONFIG