⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qmake-manual-7.html

📁 qtopiaphone英文帮助,用于初学者和开发人员,初学者可以用来学习,开发人员可以用来资料查询.
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<h5><a name="4-2-112"></a>YACCIMPLS</h5><p>This variable contains a list of yacc source files. The value of this variable is typically handled by <em>qmake</em> or <a href="qmake-manual-7.html#QMAKESPEC">qmake.conf</a> and rarely needs to be modified.</p><h5><a name="4-2-113"></a>YACCOBJECTS</h5><p>This variable contains a list of yacc object files. The value of this variable is typically handled by <em>qmake</em> or <a href="qmake-manual-7.html#QMAKESPEC">qmake.conf</a> and rarely needs to be modified.</p><a name="Functions"></a><h3><a name="5"></a>Functions</h3><p><em>qmake</em> recognizes the following functions:</p><h4><a name="5-1"></a>include( filename )</h4><p>This function will include the contents of <em>filename</em> into the current project at the point where was included. The function succeeds if <em>filename</em> was included, otherwise it fails. You can check the return value of this function using a scope.</p><p>For example:</p><pre>include( shared.pri )OPTIONS = standard custom!include( options.pri ) {	message( "No custom build options specified" )	OPTIONS -= custom}</pre><h4><a name="5-2"></a>exists( file )</h4><p>This function will test if <em>file</em> exists. If the file exists, then it will succeed; otherwise it will fail. You can specify a regular expression in file and it will succeed if any file matches the regular expression specified.</p><p>For example:</p><pre>exists( $(QTDIR)/lib/libqt-mt* ) {      message( "Configuring for multi-threaded Qt..." )      CONFIG += thread}</pre><h4><a name="5-3"></a>contains( variablename, value )</h4><p>This function will succeed if the variable <em>variablename</em> contains the value <em>value</em>. You can check the return value of this function using a scope.</p><p>For example:</p><pre>contains( drivers, network ) {	# drivers contains 'network'	message( "Configuring for network build..." )	HEADERS += network.h	SOURCES += network.cpp}</pre><h4><a name="5-4"></a>count( variablename, number )</h4><p>This function will succeed if the variable <em>variablename</em> contains <em>number</em> elements, otherwise it will fail. You can check the return value of this function using a scope.</p><p>For example:</p><pre>MYVAR = one two threecount( MYVAR, 3 ) {	# always true}</pre><h4><a name="5-5"></a>infile( filename, var, val )</h4><p>This function will succeed if the file <em>filename</em> (when parsed by qmake itself) contains the variable <em>var</em> with a value of <em>val</em>. You may also not pass in a third argument (<em>val</em>) and the function will only test if <em>var</em> has been assigned to in the file.</p><h4><a name="5-6"></a>isEmpty( variablename )</h4><p>This function will succeed if the variable <em>variablename</em> is empty (same as <tt>count(variable, 0)</tt>).</p><h4><a name="5-7"></a>system( command )</h4><p>This function will execute <tt>command</tt> in a secondary shell and will succeed if the command exits with an exit status of 1. You can check the return value of this function using a scope.</p><p>For example:</p><pre>  system(ls /bin):HAS_BIN=FALSE</pre><h4><a name="5-8"></a>message( string )</h4><p>This function will always succeed, and will display the given <em>string</em> to the user.</p><h4><a name="5-9"></a>error( string )</h4><p>This function will never return a value. It will display the given <em>string</em> to the user, and then exit <em>qmake</em>. This function should only be used for very fatal configurations.</p><p>For example:</p><pre>  release:debug:error(You can't have release and debug at the same time!)</pre><a name="Properties"></a><h3><a name="6"></a>Properties</h3><p><em>qmake</em> has a system of persistant information, this allows you to 'set' a variable in qmake once, and each time qmake is invoked this value can be queried. Use the following to set a property in qmake:</p><pre>qmake -set VARIABLE VALUE</pre><p>To retrieve this information back from qmake you can do:</p><pre>qmake -query VARIABLEqmake -query #queries all current VARIABLE/VALUE pairs..</pre><p>This information will be saved into a QSettings object (meaning it will be stored in different places for different platforms). As VARIABLE is versioned as well, you can set one value in an older version of qmake, and newer versions will retrieve this value, however if you -set VARIABLE into a newer version of qmake the older version will not use this value. You can however query a specific version of a variable if you prefix that version of qmake to VARIABLE, as in:</p><pre>qmake -query "1.06a/VARIABLE"</pre><p>qmake also has the notion of 'builtin' properties, for example you can query the installation of Qt for this version of qmake with the QT_INSTALL_PREFIX property:</p><pre>qmake -query "QT_INSTALL_PREFIX"</pre><p>These builtin properties cannot have a version prefixed to them as they are not versioned and each qmake will have its own notion of these values. The list below outlines the builtin properties:</p><ul><li><p>QT_INSTALL_PREFIX - Where the version of Qt this qmake is built for resides</p><li><p>QT_INSTALL_DATA - Where data for this version of Qt resides</p><li><p>QMAKE_VERSION - The current version of qmake</p></ul><p>Finally, these values can be queried in a project file with a special notation such as:</p><pre>QMAKE_VERS = $$[QMAKE_VERSION]</pre><a name="Environment"></a><h3><a name="7"></a>Environment Variables and Configuration</h3><a name="QMAKESPEC"></a><h4><a name="7-1"></a>QMAKESPEC</h4><p><em>qmake</em> requires a platform and compiler description file which contains many default values used to generate appropriate makefiles. The standard Qt distribution comes with many of these files, located in the 'mkspecs' subdirectory of the Qt installation.</p><p>The QMAKESPEC environment variable can contain any of the following:</p><ul><li><p>A complete path to a directory containing a qmake.conf file. In this case <em>qmake</em> will open the qmake.conf file from within that directory. If the file does not exist, <em>qmake</em> will exit with an error.</p><li><p>The name of a platform-compiler combination. In this case, <em>qmake</em> will search in the directory specified by the QTDIR environment variable.</p></ul><p>Note: the QMAKESPEC path will automatically be added to the <a href="qmake-manual-7.html#INCLUDEPATH">INCLUDEPATH</a> system variable.</p><a name="INSTALLS"></a><h4><a name="7-2"></a>INSTALLS</h4><p>It is common on UNIX to be able to install from the same utility as you build with (e.g make install). For this <em>qmake</em> has introduce the concept of an install set. The notation for this is quite simple, first you fill in an "object" in qmake for example:</p><pre>  documentation.path = /usr/local/program/doc  documentation.files = docs/*</pre><p>In this way you are telling <em>qmake</em> several things about this install, first that you plan to install to /usr/local/program/doc (the path member), second that you plan to copy everything in the docs directory. Once this is done you may insert it in the install list:</p><pre>  INSTALLS += documentation</pre><p>Now <em>qmake</em> will take over making sure the correct things are copied to the specified places. If however you require greater control you may use the 'extra' member of the object:</p><pre>  unix:documentation.extra = create_docs; mv master.doc toc.doc</pre><p>Then qmake will run the things in extra (this is of course platform specific, so you may need to test for your platform first, this case we test for unix). Then it will do the normal processings of the files member. Finally if you appened a builtin install to INSTALLS <em>qmake</em> (and do not specify a files or extra member) will decide what needs to be copied for you, currently the only supported builtin is target:</p><pre>  target.path = /usr/local/myprogram  INSTALLS += target</pre><p>With this <em>qmake</em> will know what you plan need copied, and do this for you.</p><a name="cache"></a><h4><a name="7-3"></a>Cache File</h4><p>The cache file (mentioned above in the options) is a special file <em>qmake</em> will read to find settings not specified in the <tt>qmake.conf</tt> file, the .pro file, or the command line. If <tt>-nocache</tt> is not specified, <em>qmake</em> will try to find a file called <tt>.qmake.cache</tt> in parent directories. If it fails to find this file, it will silently ignore this step of processing.</p><a name="LibDepend"></a><h4><a name="7-4"></a>Library Dependencies</h4><p>Often when linking against a library <em>qmake</em> relies on the underlying platform to know what other libraries this library links against, and lets the platform pull them in. In many cases, however, this is not sufficent. For example when statically linking a library there are no libraries linked against, and therefore no dependencies to those libraries are created - however an application that later links against this library will need to know where to find the symbols that the linked in library will require. To help with this situation <em>qmake</em> will follow a library's dependencies when it feels appropriate, however this behaviour must be enabled in <em>qmake</em>. To enable requires two steps. First, you must enable it in the library - to do this you must tell <em>qmake</em> to save information about this library:</p><pre>  CONFIG += create_prl</pre><p>This is only relevant to the lib template, and will be ignored for all others. When this option is enabled <em>qmake</em> will create a file (called a .prl file) which will save some meta information about the library. This metafile is itself just a qmake project file, but with all internal variables. You are free to view this file, and if deleted <em>qmake</em> will know to recreate it when necesary (either when the .pro file is later read, or if a dependent library (described below) has changed). When installing this library (by using target in INSTALLS, above) <em>qmake</em> will automatically copy the .prl file to your install path.</p><p>The second step to enabling this processing is to turn on reading of the meta information created above:</p><pre>  CONFIG += link_prl</pre><p>When this is turned on <em>qmake</em> will process all libraries linked to, and find their meta information. With this meta information <em>qmake</em> will figure out what is relevant to linking, specifically it will add to your list of DEFINES as well as LIBS. Once <em>qmake</em> has processed this file, it will then look through the newly introduced LIBS and find their dependent .prl files, and continue until all libraries have been resolved. At this point the makefile is created as usual, and the libraries are linked explicity against your program.</p><p>The i

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -