1/****************************************************************************
2**
3** Copyright (C) 2015 The Qt Company Ltd.
4** Contact: http://www.qt.io/licensing/
5**
6** This file is part of the documentation of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:BSD$
9** You may use this file under the terms of the BSD license as follows:
10**
11** "Redistribution and use in source and binary forms, with or without
12** modification, are permitted provided that the following conditions are
13** met:
14**   * Redistributions of source code must retain the above copyright
15**     notice, this list of conditions and the following disclaimer.
16**   * Redistributions in binary form must reproduce the above copyright
17**     notice, this list of conditions and the following disclaimer in
18**     the documentation and/or other materials provided with the
19**     distribution.
20**   * Neither the name of The Qt Company Ltd nor the names of its
21**     contributors may be used to endorse or promote products derived
22**     from this software without specific prior written permission.
23**
24**
25** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
36**
37** $QT_END_LICENSE$
38**
39****************************************************************************/
40
41#! [0]
42make all
43#! [0]
44
45
46#! [1]
47CONFIG += qt thread debug
48#! [1]
49
50
51#! [2]
52CONFIG += qt
53QT += network xml
54#! [2]
55
56
57#! [3]
58QT = network xml # This will omit the core and gui modules.
59#! [3]
60
61
62#! [4]
63QT -= gui # Only the core module is used.
64#! [4]
65
66
67#! [5]
68CONFIG += link_pkgconfig
69PKGCONFIG += ogg dbus-1
70#! [5]
71
72
73#! [6]
74LIBS += -L/usr/local/lib -lmath
75#! [6]
76
77
78#! [7]
79INCLUDEPATH = c:/msdev/include d:/stl/include
80#! [7]
81
82
83#! [8]
84qmake [mode] [options] files
85#! [8]
86
87
88#! [9]
89qmake -makefile [options] files
90#! [9]
91
92
93#! [10]
94qmake -makefile -unix -o Makefile "CONFIG+=test" test.pro
95#! [10]
96
97
98#! [11]
99qmake "CONFIG+=test" test.pro
100#! [11]
101
102
103#! [12]
104qmake -project [options] files
105#! [12]
106
107
108#! [13]
109qmake -spec macx-g++
110#! [13]
111
112
113#! [14]
114QMAKE_LFLAGS += -F/path/to/framework/directory/
115#! [14]
116
117
118#! [15]
119LIBS += -framework TheFramework
120#! [15]
121
122
123#! [16]
124TEMPLATE = lib
125CONFIG += lib_bundle
126#! [16]
127
128
129#! [17]
130FRAMEWORK_HEADERS.version = Versions
131FRAMEWORK_HEADERS.files = path/to/header_one.h path/to/header_two.h
132FRAMEWORK_HEADERS.path = Headers
133QMAKE_BUNDLE_DATA += FRAMEWORK_HEADERS
134#! [17]
135
136
137#! [18]
138CONFIG += x86 ppc
139#! [18]
140
141
142#! [19]
143qmake -spec macx-xcode project.pro
144#! [19]
145
146
147#! [20]
148qmake -tp vc
149#! [20]
150
151
152#! [21]
153qmake -tp vc -r
154#! [21]
155
156
157#! [22]
158CONFIG -= embed_manifest_exe
159#! [22]
160
161
162#! [23]
163CONFIG -= embed_manifest_dll
164#! [23]
165
166
167#! [24]
168make all
169#! [24]
170
171
172#! [25]
173build_pass:CONFIG(debug, debug|release) {
174    unix: TARGET = $$join(TARGET,,,_debug)
175    else: TARGET = $$join(TARGET,,,d)
176}
177#! [25]
178
179
180#! [26]
181CONFIG += qt console newstuff
182...
183newstuff {
184    SOURCES += new.cpp
185    HEADERS += new.h
186}
187#! [26]
188
189
190#! [27]
191DEFINES += USE_MY_STUFF QT_DLL
192#! [27]
193
194
195#! [28]
196myFiles.files = path\*.png
197DEPLOYMENT += myFiles
198#! [28]
199
200
201#! [29]
202myFiles.files = path\file1.ext1 path2\file2.ext1 path3\*
203myFiles.path = \some\path\on\device
204someother.files = C:\additional\files\*
205someother.path = \myFiles\path2
206DEPLOYMENT += myFiles someother
207#! [29]
208
209
210#! [30]
211DESTDIR = ../../lib
212#! [30]
213
214
215#! [31]
216DISTFILES += ../program.txt
217#! [31]
218
219
220#! [32]
221FORMS = mydialog.ui \
222    mywidget.ui \
223        myconfig.ui
224#! [32]
225
226
227#! [33]
228FORMS3 = my_uic3_dialog.ui \
229     my_uic3_widget.ui \
230         my_uic3_config.ui
231#! [33]
232
233
234#! [34]
235HEADERS = myclass.h \
236          login.h \
237          mainwindow.h
238#! [34]
239
240
241#! [35]
242INCLUDEPATH = c:/msdev/include d:/stl/include
243#! [35]
244
245
246#! [36]
247target.path += $$[QT_INSTALL_PLUGINS]/imageformats
248INSTALLS += target
249#! [36]
250
251
252#! [37]
253LEXSOURCES = lexer.l
254#! [37]
255
256
257#! [38]
258unix:LIBS += -L/usr/local/lib -lmath
259win32:LIBS += c:/mylibs/math.lib
260#! [38]
261
262
263#! [39]
264CONFIG += no_lflags_merge
265#! [39]
266
267
268#! [40]
269unix:MOC_DIR = ../myproject/tmp
270win32:MOC_DIR = c:/myproject/tmp
271#! [40]
272
273
274#! [41]
275unix:OBJECTS_DIR = ../myproject/tmp
276win32:OBJECTS_DIR = c:/myproject/tmp
277#! [41]
278
279
280#! [42]
281app {
282    # Conditional code for 'app' template here
283}
284#! [42]
285
286
287#! [43]
288FRAMEWORK_HEADERS.version = Versions
289FRAMEWORK_HEADERS.files = path/to/header_one.h path/to/header_two.h
290FRAMEWORK_HEADERS.path = Headers
291QMAKE_BUNDLE_DATA += FRAMEWORK_HEADERS
292#! [43]
293
294
295#! [44]
296QMAKE_BUNDLE_EXTENSION = .myframework
297#! [44]
298
299
300#! [45]
301QMAKE_RESOURCE_FLAGS += -threshold 0 -compress 9
302#! [45]
303
304
305#! [46]
306QMAKE_UIC = uic -L /path/to/plugin
307#! [46]
308
309
310#! [47]
311QT -= gui # Only the core module is used.
312#! [47]
313
314
315#! [48]
316unix:RCC_DIR = ../myproject/resources
317win32:RCC_DIR = c:/myproject/resources
318#! [48]
319
320
321#! [49]
322SOURCES = myclass.cpp \
323      login.cpp \
324      mainwindow.cpp
325#! [49]
326
327
328#! [50]
329SUBDIRS = kernel \
330          tools \
331          myapp
332#! [50]
333
334
335#! [51]
336CONFIG += ordered
337#! [51]
338
339
340#! [52]
341TEMPLATE = app
342TARGET = myapp
343SOURCES = main.cpp
344#! [52]
345
346
347#! [53]
348TEMPLATE = lib
349SOURCES = main.cpp
350TARGET = mylib
351#! [53]
352
353
354#! [54]
355unix:UI_DIR = ../myproject/ui
356win32:UI_DIR = c:/myproject/ui
357#! [54]
358
359
360#! [55]
361unix:UI_HEADERS_DIR = ../myproject/ui/include
362win32:UI_HEADERS_DIR = c:/myproject/ui/include
363#! [55]
364
365
366#! [56]
367unix:UI_SOURCES_DIR = ../myproject/ui/src
368win32:UI_SOURCES_DIR = c:/myproject/ui/src
369#! [56]
370
371
372#! [57]
373VERSION = 1.2.3
374#! [57]
375
376
377#! [58]
378YACCSOURCES = moc.y
379#! [58]
380
381
382#! [59]
383FILE = /etc/passwd
384FILENAME = $$basename(FILE) #passwd
385#! [59]
386
387
388#! [60]
389CONFIG = debug
390CONFIG += release
391CONFIG(release, debug|release):message(Release build!) #will print
392CONFIG(debug, debug|release):message(Debug build!) #no print
393#! [60]
394
395
396#! [61]
397contains( drivers, network ) {
398    # drivers contains 'network'
399    message( "Configuring for network build..." )
400    HEADERS += network.h
401    SOURCES += network.cpp
402}
403#! [61]
404
405
406#! [62]
407error(An error has occurred in the configuration process.)
408#! [62]
409
410
411#! [63]
412exists( $(QTDIR)/lib/libqt-mt* ) {
413      message( "Configuring for multi-threaded Qt..." )
414      CONFIG += thread
415}
416#! [63]
417
418
419#! [64]
420MY_VAR = one two three four
421MY_VAR2 = $$join(MY_VAR, " -L", -L) -Lfive
422MY_VAR3 = $$member(MY_VAR, 2) $$find(MY_VAR, t.*)
423#! [64]
424
425
426#! [65]
427LIST = 1 2 3
428for(a, LIST):exists(file.$${a}):message(I see a file.$${a}!)
429#! [65]
430
431
432#! [66]
433include( shared.pri )
434OPTIONS = standard custom
435!include( options.pri ) {
436    message( "No custom build options specified" )
437OPTIONS -= custom
438}
439#! [66]
440
441
442#! [67]
443isEmpty( CONFIG ) {
444CONFIG += qt warn_on debug
445}
446#! [67]
447
448
449#! [68]
450message( "This is a message" )
451#! [68]
452
453
454#! [69]
455!build_pass:message( "This is a message" )
456#! [69]
457
458
459#! [70]
460This is a test.
461#! [70]
462
463
464#! [71]
465system(ls /bin):HAS_BIN=FALSE
466#! [71]
467
468
469#! [72]
470UNAME = $$system(uname -s)
471contains( UNAME, [lL]inux ):message( This looks like Linux ($$UNAME) to me )
472#! [72]
473
474
475#! [73]
476ARGS = 1 2 3 2 5 1
477ARGS = $$unique(ARGS) #1 2 3 5
478#! [73]
479
480
481#! [74]
482qmake -set VARIABLE VALUE
483#! [74]
484
485
486#! [75]
487qmake -query VARIABLE
488qmake -query #queries all current VARIABLE/VALUE pairs..
489#! [75]
490
491
492#! [76]
493qmake -query "1.06a/VARIABLE"
494#! [76]
495
496
497#! [77]
498qmake -query "QT_INSTALL_PREFIX"
499#! [77]
500
501
502#! [78]
503QMAKE_VERS = $$[QMAKE_VERSION]
504#! [78]
505
506
507#! [79]
508documentation.path = /usr/local/program/doc
509documentation.files = docs/*
510#! [79]
511
512
513#! [80]
514INSTALLS += documentation
515#! [80]
516
517
518#! [81]
519unix:documentation.extra = create_docs; mv master.doc toc.doc
520#! [81]
521
522
523#! [82]
524target.path = /usr/local/myprogram
525INSTALLS += target
526#! [82]
527
528
529#! [83]
530CONFIG += create_prl
531#! [83]
532
533
534#! [84]
535CONFIG += link_prl
536#! [84]
537
538
539#! [85]
540QMAKE_EXT_MOC = .mymoc
541#! [85]
542
543
544#! [86]
545mytarget.target = .buildfile
546mytarget.commands = touch $$mytarget.target
547mytarget.depends = mytarget2
548
549mytarget2.commands = @echo Building $$mytarget.target
550#! [86]
551
552
553#! [87]
554QMAKE_EXTRA_TARGETS += mytarget mytarget2
555#! [87]
556
557
558#! [88]
559new_moc.output  = moc_${QMAKE_FILE_BASE}.cpp
560new_moc.commands = moc ${QMAKE_FILE_NAME} -o ${QMAKE_FILE_OUT}
561new_moc.depend_command = g++ -E -M ${QMAKE_FILE_NAME} | sed "s,^.*: ,,"
562new_moc.input = NEW_HEADERS
563QMAKE_EXTRA_COMPILERS += new_moc
564#! [88]
565
566
567#! [89]
568TARGET = myapp
569#! [89]
570
571
572#! [90]
573DEFINES += QT_DLL
574#! [90]
575
576
577#! [91]
578DEFINES -= QT_DLL
579#! [91]
580
581
582#! [92]
583DEFINES *= QT_DLL
584#! [92]
585
586
587#! [93]
588DEFINES ~= s/QT_[DT].+/QT
589#! [93]
590
591
592#! [94]
593EVERYTHING = $$SOURCES $$HEADERS
594message("The project contains the following files:")
595message($$EVERYTHING)
596#! [94]
597
598
599#! [95]
600win32:DEFINES += QT_DLL
601#! [95]
602
603
604#! [96]
605win32:xml {
606    message(Building for Windows)
607    SOURCES += xmlhandler_win.cpp
608} else:xml {
609    SOURCES += xmlhandler.cpp
610} else {
611    message("Unknown configuration")
612}
613#! [96]
614
615
616#! [97]
617MY_VARIABLE = value
618#! [97]
619
620
621#! [98]
622MY_DEFINES = $$DEFINES
623#! [98]
624
625
626#! [99]
627MY_DEFINES = $${DEFINES}
628#! [99]
629
630
631#! [100]
632TARGET = myproject_$${TEMPLATE}
633#! [100]
634
635
636#! [101]
637target.path = $$[QT_INSTALL_PLUGINS]/designer
638INSTALLS += target
639#! [101]
640
641
642#! [102]
643defineReplace(functionName){
644    #function code
645}
646#! [102]
647
648
649#! [103]
650CONFIG += myfeatures
651#! [103]
652
653
654#! [105]
655PRECOMPILED_HEADER = stable.h
656#! [105]
657
658
659#! [106]
660precompile_header:!isEmpty(PRECOMPILED_HEADER) {
661DEFINES += USING_PCH
662}
663#! [106]
664
665
666#! [107]
667PRECOMPILED_HEADER = window.h
668SOURCES            = window.cpp
669#! [107]
670
671
672#! [108]
673SOURCES += hello.cpp
674#! [108]
675
676
677#! [109]
678SOURCES += hello.cpp
679SOURCES += main.cpp
680#! [109]
681
682
683#! [110]
684SOURCES = hello.cpp \
685          main.cpp
686#! [110]
687
688
689#! [111]
690HEADERS += hello.h
691SOURCES += hello.cpp
692SOURCES += main.cpp
693#! [111]
694
695
696#! [112]
697TARGET = helloworld
698#! [112]
699
700
701#! [113]
702CONFIG += qt
703HEADERS += hello.h
704SOURCES += hello.cpp
705SOURCES += main.cpp
706#! [113]
707
708
709#! [114]
710qmake -o Makefile hello.pro
711#! [114]
712
713
714#! [115]
715qmake -tp vc hello.pro
716#! [115]
717
718
719#! [116]
720CONFIG += qt debug
721HEADERS += hello.h
722SOURCES += hello.cpp
723SOURCES += main.cpp
724#! [116]
725
726
727#! [117]
728win32 {
729    SOURCES += hellowin.cpp
730}
731#! [117]
732
733
734#! [118]
735CONFIG += qt debug
736HEADERS += hello.h
737SOURCES += hello.cpp
738SOURCES += main.cpp
739win32 {
740    SOURCES += hellowin.cpp
741}
742unix {
743    SOURCES += hellounix.cpp
744}
745#! [118]
746
747
748#! [119]
749!exists( main.cpp ) {
750    error( "No main.cpp file found" )
751}
752#! [119]
753
754
755#! [120]
756CONFIG += qt debug
757HEADERS += hello.h
758SOURCES += hello.cpp
759SOURCES += main.cpp
760win32 {
761    SOURCES += hellowin.cpp
762}
763unix {
764    SOURCES += hellounix.cpp
765}
766!exists( main.cpp ) {
767    error( "No main.cpp file found" )
768}
769#! [120]
770
771
772#! [121]
773win32 {
774    debug {
775        CONFIG += console
776    }
777}
778#! [121]
779
780
781#! [122]
782CONFIG += qt debug
783HEADERS += hello.h
784SOURCES += hello.cpp
785SOURCES += main.cpp
786win32 {
787    SOURCES += hellowin.cpp
788}
789unix {
790    SOURCES += hellounix.cpp
791}
792!exists( main.cpp ) {
793    error( "No main.cpp file found" )
794}
795win32:debug {
796    CONFIG += console
797}
798#! [122]
799
800
801#! [123]
802TEMPLATE = app
803DESTDIR  = c:/helloapp
804HEADERS += hello.h
805SOURCES += hello.cpp
806SOURCES += main.cpp
807DEFINES += QT_DLL
808CONFIG  += qt warn_on release
809#! [123]
810
811
812#! [124]
813make all
814#! [124]
815
816
817#! [125]
818make
819#! [125]
820
821
822#! [126]
823make install
824#! [126]
825
826
827#! [127]
828CONFIG(debug, debug|release) {
829    mac: TARGET = $$join(TARGET,,,_debug)
830    win32: TARGET = $$join(TARGET,,d)
831}
832#! [127]
833
834#! [128]
835customplugin.files = customimageplugin.dll
836customplugin.files += c:\myplugins\othercustomimageplugin.dll
837customplugin.path = imageformats
838dynamiclibrary.files = mylib.dll helper.exe
839dynamiclibrary.path = \sys\bin
840globalplugin.files = someglobalimageplugin.dll
841globalplugin.path = \resource\qt\plugins\imageformats
842DEPLOYMENT += customplugin dynamiclibrary globalplugin
843#! [128]
844
845#! [129]
846TARGET.EPOCALLOWDLLDATA = 1
847#! [129]
848
849#! [130]
850TARGET.EPOCHEAPSIZE = 10000 10000000
851TARGET.EPOCSTACKSIZE = 0x8000
852#! [130]
853
854#! [131]
855QMAKE_CXXFLAGS.CW += -O2
856QMAKE_CXXFLAGS.ARMCC += -O0
857#! [131]
858
859#! [132]
860TARGET.UID2 = 0x00000001
861TARGET.UID3 = 0x00000002
862TARGET.SID = 0x00000003
863TARGET.VID = 0x00000004
864#! [132]
865
866#! [133]
867TARGET.CAPABILITY += AllFiles
868#! [133]
869
870#! [134]
871TARGET.CAPABILITY = ALL -TCB -DRM -AllFiles
872#! [134]
873
874#! [135]
875TARGET.EPOCHEAPSIZE = 10000 10000000
876#! [135]
877
878#! [136]
879TARGET.EPOCSTACKSIZE = 0x8000
880#! [136]
881
882#! [137]
883MMP_RULES += "DEFFILE hello.def"
884#! [137]
885
886#! [138]
887myBlock = \
888"START RESOURCE foo.rss" \
889"TARGET bar" \
890"TARGETPATH private\10001234" \
891"HEADER" \
892"LANG 01" \
893"UID 0x10002345 0x10003456" \
894"END"
895
896MMP_RULES += myBlock
897#! [138]
898
899#! [139]
900myIfdefBlock = \
901"$${LITERAL_HASH}ifdef WINSCW" \
902"DEFFILE hello_winscw.def" \
903"$${LITERAL_HASH}endif"
904
905MMP_RULES += myIfdefBlock
906#! [139]
907
908#! [140]
909somelib.files = somelib.dll
910somelib.path = \sys\bin
911somelib.pkg_prerules = "(0x12345678), 2, 2, 0, {\"Some Package\"}" \
912                  "(0x87654321), 1, *, * ~ 2, 2, 0, {\"Some Other Package\"}"
913justdep.pkg_prerules = "(0xAAAABBBB), 0, 2, 0, {\"My Framework\"}"
914DEPLOYMENT += somelib justdep
915#! [140]
916
917#! [141]
918default_deployment.pkg_prerules -= pkg_platform_dependencies
919my_deployment.pkg_prerules = "[0x11223344],0,0,0,{\"SomeSpecificDeviceID\"}"
920DEPLOYMENT += my_deployment
921#! [141]
922
923#! [142]
924DEPLOYMENT_PLUGIN += qjpeg
925#! [142]
926
927#! [143]
928myextension = \
929    "start extension myextension" \
930    "$${LITERAL_HASH}if defined(WINSCW)" \
931    "option MYOPTION foo" \
932    "$${LITERAL_HASH}endif" \
933    "option MYOPTION bar" \
934    "end"
935BLD_INF_RULES.prj_extensions += myextension
936#! [143]
937
938#! [144]
939RSS_RULES += "hidden = KAppIsHidden;"
940#! [144]
941
942#! [145]
943myrssrules = \
944    "hidden = KAppIsHidden;" \
945    "launch = KAppLaunchInBackground;" \
946RSS_RULES += myrssrules
947#! [145]
948
949#! [146]
950DEPLOYMENT.installer_header = 0x12345678
951#! [146]
952
953#! [147]
954DEPLOYMENT.installer_header = "$${LITERAL_HASH}{\"My Application Installer\"},(0x12345678),1,0,0"
955#! [147]
956
957#! [148]
958# Set conditional libraries
959LIB.MARM = "LIBRARY myarm.lib"
960LIB.WINSCW = "LIBRARY mywinscw.lib"
961LIB.default = "LIBRARY mydefault.lib"
962
963# Add the conditional MMP rules
964MYCONDITIONS = MARM WINSCW
965MYVARIABLES = LIB
966
967addMMPRules(MYCONDITIONS, MYVARIABLES)
968#! [148]
969
970#! [149]
971SUBDIRS += my_executable my_library
972my_executable.subdir = app
973my_executable.depends = my_library
974my_library.subdir = lib
975#! [149]
976
977#! [150]
978symbian {
979    SUBDIRS += emulator_dll
980    emulator_dll.condition = WINSCW
981}
982#! [150]
983
984#! [151]
985RSS_RULES.service_list += "uid = 0x12345678; datatype_list = \{\}; opaque_data = r_my_icon;"
986RSS_RULES.footer +="RESOURCE CAPTION_AND_ICON_INFO r_my_icon \{ icon_file =\"$$PWD/my_icon.svg\"; \}"
987#! [151]
988
989#! [152]
990my_exports = \
991    "foo.h /epoc32/include/mylib/foo.h" \
992    "bar.h /epoc32/include/mylib/bar.h"
993BLD_INF_RULES.prj_exports += my_exports
994#! [152]
995
996#! [153]
997my_note.pkg_postrules.installer = "\"myinstallnote.txt\" - \"\", FILETEXT, TEXTCONTINUE"
998DEPLOYMENT += my_note
999#! [153]
1000
1001#! [154]
1002DEPLOYMENT -= default_bin_deployment default_resource_deployment default_reg_deployment
1003#! [154]
1004
1005#! [155]
1006default_bin_deployment.flags += FILERUN RUNINSTALL
1007dep_note.files = install_note.txt
1008dep_note.flags = FILETEXT TEXTEXIT
1009DEPLOYMENT += dep_note
1010#! [155]
1011
1012#! [156]
1013DEPLOYMENT.display_name = My Qt App
1014#! [156]
1015
1016#! [157]
1017packagesExist(sqlite3 QtNetwork QtDeclarative) {
1018    DEFINES += USE_FANCY_UI
1019}
1020#! [157]
1021
1022#! [158]
1023#ifdef USE_FANCY_UI
1024    // Use the fancy UI, as we have extra packages available
1025#endif
1026#! [158]
1027
1028#! [159]
1029RSS_RULES += "graphics_memory=12288;"
1030#! [159]
1031