锘??xml version="1.0" encoding="utf-8" standalone="yes"?>国产一区av在线,亚洲欧美日韩国产综合在线 ,中文亚洲免费http://www.shnenglu.com/Error/category/19669.htmlzh-cnWed, 05 Dec 2012 20:14:57 GMTWed, 05 Dec 2012 20:14:57 GMT60cmake緙栬瘧qt宸ョ▼http://www.shnenglu.com/Error/archive/2012/07/16/183712.htmlEnicEnicMon, 16 Jul 2012 04:24:00 GMThttp://www.shnenglu.com/Error/archive/2012/07/16/183712.htmlhttp://www.shnenglu.com/Error/comments/183712.htmlhttp://www.shnenglu.com/Error/archive/2012/07/16/183712.html#Feedback0http://www.shnenglu.com/Error/comments/commentRss/183712.htmlhttp://www.shnenglu.com/Error/services/trackbacks/183712.html

#瀹為檯涓婃槸璋冪敤cmake瀹夎鐩綍\share\cmake-2.8\Modules\FindQt4.cmake
#璁劇疆濂戒竴鎵歸瀹氫箟鐨勪笢涓?/span>
FIND_PACKAGE(Qt4 REQUIRED)

# 涓嶈В閲?/span>
SET(helloworld_SOURCES main.cpp hellowindow.cpp)
SET(helloworld_HEADERS hellowindow.h)

#澶勭悊helloworld_HEADERS涓殑MOC瀹忥紝澶勭悊緇撴灉鐢熸垚鍦╤elloworld_HEADERS_MOC
QT4_WRAP_CPP(helloworld_HEADERS_MOC ${helloworld_HEADERS})

#娣誨姞QT澶存枃浠跺拰瀹?/span>
INCLUDE(${QT_USE_FILE})
ADD_DEFINITIONS(${QT_DEFINITIONS})






**********************************************

Using CMake to Build Qt Projects

Written by: Johan Thelin

Qt comes with the QMake tool for handling cross platform building issues. However, there are other build systems available such as autotools, SCons and CMake. These tools meet different criterias, for example external dependencies.

When the KDE project shifted from Qt 3 to Qt 4 the project changed build tool from autotools to CMake. This has given CMake a special position in the Qt world &emdash; both from the number of users point and from a feature support and quality point. Seen from a workflow point of view, Qt Creator supports CMake since version 1.1 (1.3 if you want to use a Microsoft toolchain).

A Basic Example

In this article we will focus on CMake itself, and how to use it in conjunction with Qt. To do this, let's start with an overview of a simple, but typical CMake-based project. As you can tell from the listing below, the project consists of some source files and a text file.

$ ls CMakeLists.txt hellowindow.cpp hellowindow.h main.cpp 

Basically, the CMakeLists.txt file replaces the projectfile used by QMake. To build the project, create a build directory and run cmake and then make from there. The reason for creating a build directory is that CMake has been built with out-of-source building in mind from the very start. It is possible to configure QMake to place intermediate files outside the source, but it requires extra steps. With CMake, it is the default.

$ mkdir build $ cd build $ cmake .. && make 


CMake building a basic project.

The argument given to CMake refers to the directory where the CMakeLists.txt file resides. This file controls the whole build process. In order to fully understand it, it is important to recognize how the build process looks. The figure below shows how the user files: sources, headers, forms and resource files are processed by the various Qt code generators before joining the standard C++ compilation flow. Since QMake was designed to handle this flow, it hides all the details of this flow.


The Qt build system.

When using CMake, the intermediate steps must be handled explicitly. This means that headers with Q_OBJECT macros must be run through moc, user interface forms must be processed by uic and resource files must pass through rcc.

In the example that we started with the world is slightly easier, though. It is limited to a single header file that needs to meet moc. But first, the CMakeLists.txt defines a project name and includes the Qt4 package as a required component.

PROJECT(helloworld) FIND_PACKAGE(Qt4 REQUIRED) 

Then all sources involved in the build process are assigned to two variables. The SET command assigns the variable listed first with the values that follow. The names, helloworld_SOURCES and helloworld_HEADERS, is by convention. You can name them either way you like.

SET(helloworld_SOURCES main.cpp hellowindow.cpp) SET(helloworld_HEADERS hellowindow.h) 

Notice that the headers only include the headers that needs to be processed by moc. All other headers can be left out of the CMakeLists.txt file. This also implicates that if you add a Q_OBJECT macro to any of your classes you must ensure that it is listed here.

To invoke moc, the macro QT4_WRAP_CPP is used. It assigns the names of the resulting files to the variable listed first. In this case the line looks as follows.

QT4_WRAP_CPP(helloworld_HEADERS_MOC ${helloworld_HEADERS}) 

What happens is that all headers are processed by moc and the names of the resulting source files are listed in the helloworld_HEADERS_MOC variable. Again, the variable name is by convention rather than forced.

In order to build a Qt application, the Qt include directories needs to be added as well as a range of defines need to be set. This is handled through the commands INCLUDE and ADD_DEFINITIONS.

INCLUDE(${QT_USE_FILE}) ADD_DEFINITIONS(${QT_DEFINITIONS}) 

Finally, CMake needs to know the name of the resulting executable and what to link it to. This is conveniently handled by by the commands ADD_EXECUTABLE and TARGET_LINK_LIBRARIES. Now CMake knows what to build, from what and through which steps.

ADD_EXECUTABLE(helloworld ${helloworld_SOURCES}      ${helloworld_HEADERS_MOC}) TARGET_LINK_LIBRARIES(helloworld ${QT_LIBRARIES}) 

When reviewing the listing above, it relies on a number of variables starting with QT_. These are generated by the Qt4 package. However, as a developer, you must explicitly refer to them as CMake is not build as tightly to suite Qt as QMake.

Adding More Qt

Moving beyond the initial example, we now look at a project with both resources and user interface forms. The resulting application will look quite similar to its predecessor, but all the magic takes place under the hood.

The CMakeLists.txt file start by naming the project and including the Qt4 package - the complete file can be downloaded as a source code package accompanying this article. Then all the input files are listed and assigned to their corresponding variables.

SET(helloworld_SOURCES main.cpp hellowindow.cpp) SET(helloworld_HEADERS hellowindow.h) SET(helloworld_FORMS hellowindow.ui) SET(helloworld_RESOURCES images.qrc) 

The new file types are then handled by QT4_WRAP_UI and QT4_ADD_RESOURCES. These macros operate in the same ways as QT4_WRAP_CPP. This means that the resulting files are assigned to variable given as the left-most argument. Notice that the header files generated by uic are needed as we need to build a dependency relationship between them and the final executable. Otherwise they will not be created.

QT4_WRAP_CPP(helloworld_HEADERS_MOC ${helloworld_HEADERS}) QT4_WRAP_UI(helloworld_FORMS_HEADERS ${helloworld_FORMS}) QT4_ADD_RESOURCES(helloworld_RESOURCES_RCC ${helloworld_RESOURCES}) 

All the resulting files are then added as dependencies to the ADD_EXECUTABLE macro. This includes the uic generated headerfiles. This establishes the dependency from the executable to the hellowindow.ui file through the intermediary ui_hellowindow.h header.

ADD_EXECUTABLE(helloworld ${helloworld_SOURCES}      ${helloworld_HEADERS_MOC}      ${helloworld_FORMS_HEADERS}      ${helloworld_RESOURCES_RCC}) 

Before this file can be used to build the project there is a small caveat to handle. As all intermediate files are generated outside the source tree, the header file generated by uic will not be located by the compiler. In order to handle this, the build directory needs to be added to the list of include directories.

INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) 

With this line, all intermediary files will be available in the include path.

Qt Modules

Until now we have relied on the QtCore and QtGui modules. To be able to use more modules, the CMake environment must be tuned to enable them. By setting them to TRUE using the SET command, the included modules can be controlled.

For instance, to enable OpenGL support add the following line to your CMakeLists.txt.

SET(QT_USE_QTOPENGL TRUE) 

The most commonly used modules are controlled using the following variables.

  • QT_USE_QTNETWORK
  • QT_USE_QTOPENGL
  • QT_USE_QTSQL
  • QT_USE_QTXML
  • QT_USE_QTSVG
  • QT_USE_QTTEST
  • QT_USE_QTDBUS
  • QT_USE_QTSCRIPT
  • QT_USE_QTWEBKIT
  • QT_USE_QTXMLPATTERNS
  • QT_USE_PHONON

In addition to these, the variable QT_DONT_USE_QTGUI can be used to disable the use to QtGui. There is a similar variable to disable QtCore, but that is more to be feature complete than to actually add much useful value.

Added Value and Complexity

It is not as trivial to use CMake as QMake, but the rewards are more features. The most notable point when moving from QMake is CMake's built in support for out-of-source builds. It can really change habits, and thus make versioning code much easier.

It is also possible to add conditionals for various platforms and build scenarios. For instance, use different libraries for different platforms, as well as tuning the same project differently for different situations.

Other powerful features are the ability to generate multiple executables and libraries in one build as well as using said executables and libraries in the same build. This, in combination with the QtTest module can handle complex build situations from a single configuration.

The choice between CMake and QMake is really quite easy. For straight forward Qt projects, QMake is the obvious choice. When the build requirements passes the complexity threshold for QMake, CMake can take its place. With Qt Creator's support for CMake, the same tools can still be used.



Enic 2012-07-16 12:24 鍙戣〃璇勮
]]>
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            亚洲一区二区三区乱码aⅴ蜜桃女| 亚洲视频碰碰| 六十路精品视频| 久久午夜精品一区二区| 在线成人av网站| 欧美刺激午夜性久久久久久久| 久久一区亚洲| 亚洲日产国产精品| 亚洲剧情一区二区| 国产精品极品美女粉嫩高清在线 | 欧美日韩播放| 亚洲私人影院在线观看| 亚洲男女毛片无遮挡| 国产视频一区三区| 欧美成人一区二区三区片免费| 欧美国产精品日韩| 亚洲欧美久久久| 久久三级福利| 亚洲一区二区伦理| 久久av资源网站| 亚洲日本在线观看| 亚洲小说春色综合另类电影| 国产真实乱偷精品视频免| 欧美a一区二区| 欧美三日本三级少妇三99 | 一区二区亚洲| 亚洲精品国产精品乱码不99按摩| 欧美三区视频| 久久久在线视频| 欧美三级电影大全| 麻豆精品一区二区综合av| 欧美精品在线播放| 久久久久久亚洲精品杨幂换脸| 欧美成人精品福利| 久久久久久91香蕉国产| 欧美日韩一二区| 欧美成人三级在线| 国产精品五区| 99精品欧美一区二区蜜桃免费| 韩国v欧美v日本v亚洲v| 一区二区三区欧美日韩| 亚洲激情视频在线播放| 久久国产毛片| 久久精品国产99国产精品澳门| 欧美极品影院| 欧美激情视频网站| 激情欧美日韩| 欧美在线观看视频一区二区| 亚洲一区二区三区在线看| 蜜桃伊人久久| 免费一级欧美在线大片| 国产专区欧美精品| 亚洲欧美日韩第一区| 亚洲自拍偷拍色片视频| 欧美伦理影院| 亚洲欧洲日韩女同| 亚洲精品日产精品乱码不卡| 久久一二三四| 蜜桃av一区二区| 在线观看日韩一区| 久久裸体艺术| 蜜桃av噜噜一区| 亚洲大胆女人| 噜噜噜久久亚洲精品国产品小说| 久久亚洲不卡| 樱桃成人精品视频在线播放| 久久理论片午夜琪琪电影网| 另类亚洲自拍| 亚洲成人自拍视频| 免费视频亚洲| 亚洲三级网站| 亚洲在线日韩| 国产麻豆精品视频| 欧美在线关看| 欧美xx视频| 99re视频这里只有精品| 欧美精品国产| 亚洲一区二区三区乱码aⅴ蜜桃女 亚洲一区二区三区乱码aⅴ | 免费成人高清视频| 亚洲国产网站| 亚洲一区二区成人| 国产精品女人网站| 欧美在线观看你懂的| 美女久久一区| 夜夜躁日日躁狠狠久久88av| 欧美日韩国产精品专区| 一区二区三区四区五区视频| 亚洲一区二区三区视频| 国产人妖伪娘一区91| 久久久xxx| 亚洲日本中文| 午夜精品久久久久久久蜜桃app| 国产欧美日韩麻豆91| 久久乐国产精品| 99视频一区二区三区| 久久激情一区| 亚洲精品美女久久7777777| 欧美视频福利| 久久久久久日产精品| 亚洲欧洲久久| 久久久噜久噜久久综合| 一本色道久久综合狠狠躁篇怎么玩| 国产精品高清一区二区三区| 久久久久这里只有精品| 99国产精品久久| 蜜月aⅴ免费一区二区三区| 亚洲视频狠狠| 亚洲欧洲精品一区二区三区| 国产精品国产馆在线真实露脸 | 欧美韩日亚洲| 先锋影音网一区二区| 亚洲精品欧洲精品| 国产精品自拍视频| 欧美激情综合五月色丁香小说 | 亚洲国产精品专区久久| 午夜欧美不卡精品aaaaa| 亚洲精品日韩激情在线电影| 国内精品美女av在线播放| 欧美日韩国产综合网| 久久美女性网| 欧美亚洲一区二区在线| 一区二区三区四区五区视频| 欧美韩国日本综合| 久久永久免费| 欧美专区一区二区三区| 亚洲香蕉视频| 正在播放欧美一区| 亚洲精品午夜| 91久久中文| 亚洲二区三区四区| 有坂深雪在线一区| 国产综合色一区二区三区| 国产精品永久免费在线| 国产精品国产一区二区| 欧美日韩成人激情| 欧美激情亚洲另类| 欧美国产免费| 欧美精品二区三区四区免费看视频| 久久综合九色欧美综合狠狠| 久久精品国产综合| 久久精品久久99精品久久| 欧美一级在线播放| 欧美一级专区| 久久久91精品国产| 久久精品女人的天堂av| 久久精品国产免费| 久久资源在线| 欧美a级片一区| 欧美人妖在线观看| 欧美日韩一二三四五区| 国产精品久久久久久久久免费| 欧美四级电影网站| 国产精品丝袜91| 国内精品免费在线观看| 在线播放亚洲| 亚洲日本一区二区三区| 亚洲免费福利视频| 亚洲一区综合| 久久成人免费网| 欧美高清视频在线观看| 亚洲毛片一区二区| 亚洲午夜精品久久| 久久精品综合| 欧美激情精品久久久久久久变态| 欧美日韩另类综合| 国产欧美在线观看| 亚洲第一福利视频| 一区二区毛片| 久久精品在线免费观看| 欧美大片在线观看| 一区二区三区 在线观看视频| 午夜视频一区| 免费h精品视频在线播放| 欧美午夜片在线免费观看| 国产一区二区三区观看| 亚洲片在线观看| 欧美在现视频| 亚洲国产精品女人久久久| 在线天堂一区av电影| 久久精品日韩欧美| 欧美日韩视频在线一区二区观看视频| 国产在线高清精品| 欧美电影免费观看大全| 欧美jizz19性欧美| 欧美91大片| 国产精品有限公司| 亚洲国产一区二区三区在线播| 亚洲视频网在线直播| 久久国产精品久久久久久电车| 欧美激情中文字幕一区二区| 一本色道88久久加勒比精品| 久久精品一区二区| 欧美亚洲第一页| 亚洲激情在线播放| 久久久久久穴| 亚洲视频在线观看免费| 欧美成人一品| 激情av一区| 久久激情五月丁香伊人| 99re热这里只有精品视频|