1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation (qt-info@nokia.com)
|
---|
6 | **
|
---|
7 | ** This file is part of the documentation of the Qt Toolkit.
|
---|
8 | **
|
---|
9 | ** $QT_BEGIN_LICENSE:FDL$
|
---|
10 | ** Commercial Usage
|
---|
11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
13 | ** Software or, alternatively, in accordance with the terms contained in a
|
---|
14 | ** written agreement between you and Nokia.
|
---|
15 | **
|
---|
16 | ** GNU Free Documentation License
|
---|
17 | ** Alternatively, this file may be used under the terms of the GNU Free
|
---|
18 | ** Documentation License version 1.3 as published by the Free Software
|
---|
19 | ** Foundation and appearing in the file included in the packaging of this
|
---|
20 | ** file.
|
---|
21 | **
|
---|
22 | ** If you have questions regarding the use of this file, please contact
|
---|
23 | ** Nokia at qt-info@nokia.com.
|
---|
24 | ** $QT_END_LICENSE$
|
---|
25 | **
|
---|
26 | ****************************************************************************/
|
---|
27 |
|
---|
28 | /*!
|
---|
29 | \page qmake-tutorial.html
|
---|
30 | \title qmake ãã¥ãŒããªã¢ã«
|
---|
31 |
|
---|
32 | ãã®ãã¥ãŒããªã¢ã«ã§ã¯ \c qmake ã®äœ¿ãæ¹ã説æããŸãã
|
---|
33 | ãã®ãã¥ãŒããªã¢ã«ãèªã¿çµãã£ãã \c qmake
|
---|
34 | ã®ãŠãŒã¶ã¬ã€ããèªãããšããå§ãããŸãã
|
---|
35 |
|
---|
36 | \section1 ç°¡åãªäŸ
|
---|
37 |
|
---|
38 | ã¢ããªã±ãŒã·ã§ã³ã®åºæ¬çãªå®è£
|
---|
39 | ã¯æ¢ã«å®äºããŠããŠã
|
---|
40 | 次ã®ãã¡ã€ã«ãäœæãããŠãããšä»®å®ããŸãã
|
---|
41 |
|
---|
42 | \list
|
---|
43 | \o hello.cpp
|
---|
44 | \o hello.h
|
---|
45 | \o main.cpp
|
---|
46 | \endlist
|
---|
47 |
|
---|
48 | ãããã®ãã¡ã€ã«ã¯ Qt ãã£ã¹ããªãã¥ãŒã·ã§ã³ã®
|
---|
49 | \c{examples/qmake/tutorial} ãã£ã¬ã¯ããªã«ãããŸãã
|
---|
50 | ã¢ããªã±ãŒã·ã§ã³ã®èšå®ã«ã€ããŠç¥ã£ãŠããã¹ãããšã¯ã
|
---|
51 | ããã Qt ã§æžãããŠãããšããããšã ãã§ãã
|
---|
52 | ãŸããããã¹ããšãã£ã¿ã§ \c{examples/qmake/tutorial} ã«
|
---|
53 | \c hello.pro ãšãããã¡ã€ã«ãäœæããŸãã
|
---|
54 | æåã«ããããšã¯ãéçºãããžã§ã¯ãã«å«ãŸãããœãŒã¹ãã¡ã€ã«ãšããããã¡ã€ã«ã
|
---|
55 | \c qmake ã«æããè¡ã远å ããããšã§ãã
|
---|
56 |
|
---|
57 | ãœãŒã¹ãã¡ã€ã«ããããžã§ã¯ããã¡ã€ã«ã«è¿œå ããŸãã
|
---|
58 | ããã«ã¯ \l{qmake Variable Reference#SOURCES}{SOURCES} 倿°ã䜿ããŸãã
|
---|
59 | æ°ããè¡ãäœãã\c{SOURCES +=}ãç¶ã㊠hello.cpp ãå
|
---|
60 | ¥åããŸãã
|
---|
61 | ã€ãŸãã以äžã®ããã«ãªããŸã:
|
---|
62 |
|
---|
63 | \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 108
|
---|
64 |
|
---|
65 | ããã以äžã®ããã«ãªããŸã§ãããžã§ã¯ãã®åãœãŒã¹ãã¡ã€ã«ã«å¯ŸããŠè¡ããŸã:
|
---|
66 |
|
---|
67 | \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 109
|
---|
68 |
|
---|
69 | make ã«äŒŒãã·ã³ã¿ãã¯ã¹ã䜿ãããå Žåã¯ã
|
---|
70 | 以äžã®ããã«æ¹è¡ããšã¹ã±ãŒãããŠãã¹ãŠã®ãã¡ã€ã«ã 1 è¡ã«æžããŸã:
|
---|
71 |
|
---|
72 | \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 110
|
---|
73 |
|
---|
74 | ãœãŒã¹ãã¡ã€ã«ã®äžèЧããããžã§ã¯ããã¡ã€ã«ã«è¿œå ããŸããã
|
---|
75 | 次ã«ããããã¡ã€ã«ã远å ããŸãã
|
---|
76 | ããããã¡ã€ã«ã¯ãœãŒã¹ãã¡ã€ã«ãšå
|
---|
77 | šãåãæ¹æ³ã§è¿œå ããããšãã§ããŸãã
|
---|
78 | ãã ã倿°ã¯ \l{qmake Variable Reference#HEADERS}{HEADERS}
|
---|
79 | ã䜿ããŸãã
|
---|
80 |
|
---|
81 | ãããçµãããšããããžã§ã¯ããã¡ã€ã«ã¯ä»¥äžã®ããã«ãªãã§ããã:
|
---|
82 |
|
---|
83 | \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 111
|
---|
84 |
|
---|
85 | ã¿ãŒã²ããã®ååã¯èªåçã«èšå®ããã
|
---|
86 | ãããžã§ã¯ããã¡ã€ã«ãšåãååã«ãªããŸãã
|
---|
87 | ãã ããã©ãããã©ãŒã ã«åããããµãã£ãã¯ã¹ãã€ããããŸãã
|
---|
88 | äŸãã°ããããžã§ã¯ããã¡ã€ã«ã \c hello.pro ã§ããå Žåã
|
---|
89 | ã¿ãŒã²ãã㯠Windows ã§ã¯ \c hello.exe ãUnix ã§ã¯ \c hello ã«ãªããŸãã
|
---|
90 | ãããžã§ã¯ããã¡ã€ã«ã§å¥ã®ååãæå®ããããšãã§ããŸã:
|
---|
91 |
|
---|
92 | \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 112
|
---|
93 |
|
---|
94 | æåŸã« \l{qmake Variable Reference#CONFIG}{CONFIG} 倿°ãèšå®ããŸãã
|
---|
95 | ãã®ã¢ããªã±ãŒã·ã§ã³ã¯ Qt ã¢ããªã±ãŒã·ã§ã³ãªã®ã§ \c CONFIG ã«
|
---|
96 | \c qt ã远å ããå¿
|
---|
97 | èŠããããŸãã
|
---|
98 | \c qmake 㯠ãªã³ã¯ã®å¿
|
---|
99 | èŠãããã©ã€ãã©ãªã远å ãã
|
---|
100 | \c moc ãš \c uic ã®å®è¡ã³ãã³ãã Makefile ã«å«ãŸããããã«ããŸãã
|
---|
101 |
|
---|
102 | æçµçãªãããžã§ã¯ããã¡ã€ã«ã¯ä»¥äžã®ããã«ãªããŸã:
|
---|
103 |
|
---|
104 | \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 113
|
---|
105 |
|
---|
106 | \c qmake ã䜿ã£ãŠããã®ã¢ããªã±ãŒã·ã§ã³ã®ããã® Makefile ãçæããŸãã
|
---|
107 | ãããžã§ã¯ãã®ãã£ã¬ã¯ããªã§ã³ãã³ãã©ã€ã³ã«æ¬¡ã®ããã«å
|
---|
108 | ¥åããŸã:
|
---|
109 |
|
---|
110 | \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 114
|
---|
111 |
|
---|
112 | ãããŠã䜿çšããã³ã³ãã€ã©ã«ãã£ãŠ \c make ãŸã㯠\c nmake ãå
|
---|
113 | ¥åããŸãã
|
---|
114 |
|
---|
115 | Visual Studio ãŠãŒã¶ã®å Žåã\c qmake ã¯ã以äžã®ããã«
|
---|
116 | \c .dsp ãã¡ã€ã«ãŸã㯠\c .vcproj ãã¡ã€ã«ãäœæã§ããŸã:
|
---|
117 |
|
---|
118 | \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 115
|
---|
119 |
|
---|
120 | \section1 ã¢ããªã±ãŒã·ã§ã³ããããã°ã§ããããã«ãã
|
---|
121 |
|
---|
122 | ã¢ããªã±ãŒã·ã§ã³ã®ãªãªãŒã¹ããŒãžã§ã³ã¯ãããã°ã·ã³ãã«ãªã©ã®ãããã°æ
|
---|
123 | å ±ãå«ã¿ãŸããã
|
---|
124 | éçºäžã¯ãé¢é£æ
|
---|
125 | å ±ãå«ãã¢ããªã±ãŒã·ã§ã³ã®ãããã°ããŒãžã§ã³ãäœæããã®ã䟿å©ã§ãã
|
---|
126 | ããã¯ããããžã§ã¯ããã¡ã€ã«ã® \c CONFIG 倿°ã« \c debug
|
---|
127 | ã远å ããããšã§ç°¡åã«å®çŸã§ããŸãã
|
---|
128 |
|
---|
129 | ããšãã°:
|
---|
130 |
|
---|
131 | \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 116
|
---|
132 |
|
---|
133 | çŽåã®äŸãšåæ§ã«ãMakefile ãçæããã«ã¯ \c qmake ã䜿ããŸãã
|
---|
134 | ã¢ããªã±ãŒã·ã§ã³ããããã°ç°å¢ã§å®è¡ããéã«åœ¹ã«ç«ã€æ
|
---|
135 | å ±ãåŸãããããã«ãªããŸãã
|
---|
136 |
|
---|
137 | \section1 ãã©ãããã©ãŒã åºæã®ãœãŒã¹ãã¡ã€ã«ã远å ãã
|
---|
138 |
|
---|
139 | æ°æéã³ãŒãã£ã³ã°ãããŠãããšã
|
---|
140 | ã¢ããªã±ãŒã·ã§ã³ã«ãã©ãããã©ãŒã åºæãªéšåãåºãŠããŠ
|
---|
141 | ãã©ãããã©ãŒã åºæã®ã³ãŒããå¥ã®ãã¡ã€ã«ã«åãããå ŽåããããããããŸããã
|
---|
142 | ããã§ã¯ 2 ã€ã®ãã¡ã€ã« \c hellowin.cpp ãš \c hellounix.cpp ããããšããŠã
|
---|
143 | ããããããžã§ã¯ããã¡ã€ã«ã«è¿œå ããŸãã
|
---|
144 | ãããã®ãã¡ã€ã«ããã®ãŸãŸ \c SOURCES 倿°ã«è¿œå ããããšã¯ã§ããŸããã
|
---|
145 | ãªããªããäž¡æ¹ã®ãã¡ã€ã«ã Makefile ã«è¿œå ãããŠããŸãããã§ãã
|
---|
146 | \c qmake ãå®è¡ããããã©ãããã©ãŒã ã«ãããã£ãŠåŠçãããã¹ã³ãŒãã䜿ãå¿
|
---|
147 | èŠããããŸãã
|
---|
148 |
|
---|
149 | Windows çšã®ãã¡ã€ã«ã远å ããã·ã³ãã«ãªã¹ã³ãŒãã¯ä»¥äžã®ããã«ãªããŸã:
|
---|
150 |
|
---|
151 | \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 117
|
---|
152 |
|
---|
153 | \c qmake ã Windows äžã§å®è¡ããããšããœãŒã¹ãã¡ã€ã«ã®ãªã¹ãã«
|
---|
154 | \c hellowin.cpp ã远å ãããŸãã
|
---|
155 | \c qmake ãä»ã®ãã©ãããã©ãŒã ã§å®è¡ãããå Žåããã®éšåã¯ç¡èŠãããŸãã
|
---|
156 | 次㫠Unix çšãã¡ã€ã«ã®ã¹ã³ãŒããäœæããŸãã
|
---|
157 |
|
---|
158 | ãããçµãããšããããžã§ã¯ããã¡ã€ã«ã¯ä»¥äžã®ããã«ãªããŸã:
|
---|
159 |
|
---|
160 | \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 118
|
---|
161 |
|
---|
162 | ãããŸã§ãšåæ§ã«ãMakefile ãçæããã«ã¯ \c qmake ã䜿ããŸãã
|
---|
163 |
|
---|
164 | \section1 ãã¡ã€ã«ãååšããªãå Žåã« qmake ãäžæ¢ãã
|
---|
165 |
|
---|
166 | ç¹å®ã®ãã¡ã€ã«ãååšããªãå Žåã« Makefile ãäœæããããªãå Žåã
|
---|
167 | exists() 颿°ã䜿ã£ãŠãã¡ã€ã«ãååšãããã©ããã確èªããããšãã§ããŸãã
|
---|
168 | ãŸã error() 颿°ã䜿ã£ãŠ \c qmake ã®åŠçãäžæ¢ãããããšãã§ããŸãã
|
---|
169 | ãããã®é¢æ°ã¯ã¹ã³ãŒããšããŠåäœããŸãã
|
---|
170 | äœ¿ãæ¹ã¯ã¹ã³ãŒãã®æ¡ä»¶ããããã®é¢æ°ã§çœ®ãæããã ãã§ãã
|
---|
171 | \c main.cpp ãã¡ã€ã«ã®ç¢ºèªã¯ä»¥äžã®ããã«ãªããŸã :
|
---|
172 |
|
---|
173 | \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 119
|
---|
174 |
|
---|
175 | èšå· \c{!} ã¯ãã¹ããåŠå®ããŸãã
|
---|
176 | ã€ãŸã \c{exists( main.cpp )} ã¯ãã¡ã€ã«ãååšããå Žåã«çã«ãªãã
|
---|
177 | \c{!exists( main.cpp )} ã¯ãã¡ã€ã«ãååšããªãå Žåã«çã«ãªããŸãã
|
---|
178 |
|
---|
179 | \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 120
|
---|
180 |
|
---|
181 | åãšåæ§ã«ã\c qmake ãå®è¡ã㊠Makefile ãçæããŸãã
|
---|
182 | 仮㫠\c main.cpp ã®ååã倿Žãããšãäžèšã®ã¡ãã»ãŒãžã衚瀺ããã
|
---|
183 | \c qmake ã¯åŠçãäžæ¢ããŸãã
|
---|
184 |
|
---|
185 | \section1 è€æ°ã®æ¡ä»¶ããã§ãã¯ãã
|
---|
186 |
|
---|
187 | Windows ã䜿ã£ãŠããŠã
|
---|
188 | ã³ãã³ãã©ã€ã³ãããã®ã¢ããªã±ãŒã·ã§ã³ãå®è¡ãããšãã«
|
---|
189 | qDebug() ã®åºåãèŠãããšãã§ããããã«ãããå Žåã
|
---|
190 | ã¢ããªã±ãŒã·ã§ã³ãã³ã³ãœãŒã«ã®èšå®ã远å ããŠãã«ãããå¿
|
---|
191 | èŠããããŸãã
|
---|
192 | Windows ã§ Makefile ããã®èšå®ã«ããã«ã¯ã
|
---|
193 | \c CONFIG ã« \c console ã远å ããŸãã
|
---|
194 | Windows ã§å®è¡ãããŠããŠã\e{ãã€} \c CONFIG ã«ãã§ã« \c debug
|
---|
195 | ãããå Žåã«ã®ã¿ \c CONFIG ã远å ãããå ŽåããããããããŸããã
|
---|
196 | ãã®ãããªå Žåã2 ã€ã®ã¹ã³ãŒãããã¹ããããŠäœ¿ããŸãã
|
---|
197 | ãŸã 1 ã€ã®ã¹ã³ãŒããäœæãããã®äžã«ãã 1 ã€ã¹ã³ãŒããäœæããŸãã
|
---|
198 | ãã㊠2 ã€ã®ã¹ã³ãŒãã®äžã«èšå®ãæžããŸããäŸãã°:
|
---|
199 |
|
---|
200 | \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 121
|
---|
201 |
|
---|
202 | ãã¹ããããã¹ã³ãŒãã¯ã³ãã³ã䜿ã£ãŠã€ãªãããšãã§ããŸãã
|
---|
203 | æçµçãªãããžã§ã¯ããã¡ã€ã«ã¯ä»¥äžã®ããã«ãªããŸã:
|
---|
204 |
|
---|
205 | \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 122
|
---|
206 |
|
---|
207 | 以äžã§ãã\c qmake ã®ãã¥ãŒããªã¢ã«ãçµäºããŸããã
|
---|
208 | ããã§ã¯ãããªãã®éçºãããžã§ã¯ãã®ãããžã§ã¯ããã¡ã€ã«ãäœæããŠã¿ãŸãããã
|
---|
209 | */
|
---|
210 |
|
---|