青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

Error

C++博客 首頁 新隨筆 聯系 聚合 管理
  217 Posts :: 61 Stories :: 32 Comments :: 0 Trackbacks

CMake Manual

CMake is a tool that helps simplify the build process for development projects across different platforms. CMake automates the generation of buildsystems such as Makefiles.

CMake is a 3rd party tool with its own documentation. The rest of this manual details the specifics of how to use Qt 5 with CMake. The minimum version required to use Qt5 is CMake 2.8.3, but 2.8.9 is recommended.

Getting Started

The first requirement when using CMake is to use find_package to locate the libraries and header files shipped with Qt. These libraries and header files can then be used to build libraries and applications based on Qt.

The recommended way to use Qt libraries and headers with CMake 2.8.9 is to use the qt5_use_modules macro.

To build a helloworld executable, typical usage would be:

cmake_minimum_required(VERSION 2.8.9)

project(testproject)

# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)

# Find the QtWidgets library
find_package(Qt5Widgets)

# Tell CMake to create the helloworld executable
add_executable(helloworld main.cpp)

# Use the Widgets module from Qt 5.
qt5_use_modules(helloworld Widgets)

Note that it is necessary to use find_package to find a Qt module before using the macro. See the documentation for the CMake find_package Documentation command for the full options it supports.

In order for find_package to be successful, Qt 5 must be found below the CMAKE_PREFIX_PATH, or the Qt5<Module>_DIR must be set in the CMake cache to the location of the Qt5WidgetsConfig.cmake file. The easiest way to use CMake is to set the CMAKE_PREFIX_PATH environment variable to the install prefix of Qt 5.

The qt5_use_modules macro encapsulates all of the variable usage required to use a Qt module. It automatically finds the modules given to it on the command line if they have not already been found.

find_package(Qt5Core)

# Find the Widgets Sql and Network modules, and
# use them in helloworld.
qt5_use_modules(helloworld Widgets Sql Network)

The CMAKE_AUTOMOC setting runs moc automatically when required. For more on this feature see the CMake AUTOMOC documentation

Imported targets

Imported targets are created for each Qt module. That means that the Qt5<Module>_LIBRARIES contains a name of an imported target, rather than a path to a library. The actual path to the library can be obtained using the LOCATION property:

find_package(Qt5Core)

get_target_property(QtCore_location Qt5::Core LOCATION)

Note however that it is rare to require the full location to the library in CMake code. Most CMake APIs are aware of imported targets and can automatically use them instead of the full path.

Each module in Qt 5 has a library target with the naming convention Qt5::<Module> which can be used for this purpose.

Imported targets are created with the configurations Qt was configured with. That is, if Qt was configured with the -debug switch, an imported target with the configuration DEBUG will be created. If Qt was configured with the -release switch an imported target with the configuration RELEASE will be created. If Qt was configured with the -debug-and-release switch (the default on windows), then imported targets will be created with both RELEASE and DEBUG configurations.

If your project has custom CMake build configurations, it may be necessary to set a mapping from your custom configuration to either the debug or release Qt configuration.

find_package(Qt5Core)

set(CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_RELEASE} -fprofile-arcs -ftest-coverage")

# set up a mapping so that the Release configuration for the Qt imported target is
# used in the COVERAGE CMake configuration.
set_target_properties(Qt5::Core PROPERTIES MAP_IMPORTED_CONFIG_COVERAGE "RELEASE")
Using Qt 5 with CMake older than 2.8.9

If using CMake older than 2.8.9, the qt5_use_modules macro is not available. Attempting to use it will result in an error.

To use Qt 5 with versions of CMake older than 2.8.9, it is necessary to use the target_link_libraries, include_directories, and add_definitions commands, and to manually specify moc requirements with either qt5_generate_moc or qt5_wrap_cpp:

cmake_minimum_required(VERSION 2.8.3)

project(testproject)

# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)

# Find the QtWidgets library
find_package(Qt5Widgets)

# Add the include directories for the Qt 5 Widgets module to
# the compile lines.
include_directories(${Qt5Widgets_INCLUDE_DIRS})

# Use the compile definitions defined in the Qt 5 Widgets module
add_definitions(${Qt5Widgets_DEFINITIONS})

# Add compiler flags for building executables (-fPIE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")

qt5_generate_moc(main.cpp main.moc)

# Tell CMake to create the helloworld executable
add_executable(helloworld main.cpp main.moc)

#Link the helloworld executable to the Qt 5 widgets library.
target_link_libraries(${Qt5Widgets_LIBRARIES})

It is also necessary when using an older CMake to add Qt5<Module>_EXECUTABLE_COMPILE_FLAGS to the CMAKE_CXX_FLAGS so that the -fPIE flags are added to the compile flags if necessary (as is the default with Qt 5).

If not using the qt5_use_modules macro, and if using CMake 2.8.9 or later, the POSITION_INDEPENDENT_CODE property can be set on targets using Qt instead, or it can be set globally for all targets:

find_package(Qt5Core)

add_executable(exe1 ${exe1_SRCS})
# Set the POSITION_INDEPENDENT_CODE property for the exe1 target...
set_target_properties(exe1 PROPERTIES POSITION_INDEPENDENT_CODE ON)

# Or set it globally for all targets:
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
add_executable(exe2 ${exe2_SRCS})

add_executable(exe3 ${exe3_SRCS})

Note that it may be necessary to enable POSITION_INDEPENDENT_CODE globally in order to use try_compile with Qt code, or any wrapper macros around it such as check_cxx_source_compiles etc. As position independent code is a platform-specific and Qt-configuration-specific concept, the Qt5_POSITION_INDEPENDENT_CODE property can be used to check whether it is required.

if (Qt5_POSITION_INDEPENDENT_CODE)
  set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()

Variable Reference

Module variables

The result of a find_package call is that some variables will be populated with information required to configure the build, and macros will be made available for use. All of the package-specific variables have a consistent name with a prefix of the name of the package. For example, find_package(Qt5Widgets) will make the following variables available if successfully found:

  • Qt5Widgets_VERSION_STRING
  • Qt5Widgets_LIBRARIES List of libraries for use with the target_link_libraries command, for example.
  • Qt5Widgets_INCLUDE_DIRS List of libraries for use with the include_directories command, for example.
  • Qt5Widgets_DEFINITIONS List of definitions for use with add_definitions, for example.
  • Qt5Widgets_COMPILE_DEFINITIONS List of definitions for use with the COMPILE_DEFINITIONS target property.
  • Qt5Widgets_FOUND Boolean describing whether the module was found successfully.
  • Qt5Widgets_EXECUTABLE_COMPILE_FLAGS String of flags to be used when building executables.

Equivalents of those variables will be available for all packages found with a find_package call. Note that the variables are case-sensitive.

Installation variables

Additionally, several other variables are available which do not relate to a particular package, but to the Qt installation itself.

  • QT_VISIBILITY_AVAILABLE Boolean describing whether Qt was built with hidden visibility.
  • QT_LIBINFIX String containing the infix used in library names.

Macro Reference

Qt5Core macros

Macros available when Qt5Core is found.

Macro
Description

qt5_wrap_cpp(outfiles inputfile ... OPTIONS ...)
Create moc code from a list of files containing Qt class with the Q_OBJECT declaration. Per-direcotry preprocessor definitions are also added. Options may be given to moc, such as those found when executing "moc -help".

qt5_add_resources(outfiles inputfile ... OPTIONS ...)
Create code from a list of Qt resource files. Options may be given to rcc, such as those found when executing "rcc -help"

qt5_generate_moc(inputfile outputfile )
Creates a rule to run moc on infile and create outfile. Use this if for some reason QT5_WRAP_CPP() isn't appropriate, e.g. because you need a custom filename for the moc file or something similar.

qt5_use_modules(target [LINK_PUBLIC|LINK_PRIVATE] module ... )
Indicates that the target uses the named Qt 5 modules. The target will be linked to the specified modules, use the include directories installed by those modules, use the COMPILE_DEFINITIONS set by those modules, and use the COMPILE_FLAGS set by the modules. The LINK_PRIVATE or LINK_PUBLIC specifiers can optionally be specified. If LINK_PRIVATE is specified then the modules are not made part of the link interface of the target. See the documentation for target_link_libraries for more information.

Note that this macro is only available if using CMake 2.8.9 or later.

Qt5Widgets macros

Macros available when Qt5Widgets is found.

Macro
Description

qt5_wrap_ui(outfiles inputfile ... OPTIONS ...)
Create code from a list of Qt designer ui files. Options may be given to uic, such as those found when executing "uic -help"

Qt5DBus macros

Macros available when Qt5DBus is found.

Macro
Description

qt5_add_dbus_interface(outfiles interface basename)
Create a the interface header and implementation files with the given basename from the given interface xml file and add it to the list of sources

qt5_add_dbus_interfaces(outfiles inputfile ... )
Create the interface header and implementation files for all listed interface xml files the name will be automatically determined from the name of the xml file

qt5_add_dbus_adaptor(outfiles xmlfile parentheader parentclassname [basename] [classname])
Create a dbus adaptor (header and implementation file) from the xml file describing the interface, and add it to the list of sources. The adaptor forwards the calls to a parent class, defined in parentheader and named parentclassname. The name of the generated files will be <basename>adaptor.{cpp,h} where basename defaults to the basename of the xml file. If <classname> is provided, then it will be used as the classname of the adaptor itself.

qt5_generate_dbus_interface( header [interfacename] OPTIONS ...)
Generate the xml interface file from the given header. If the optional argument interfacename is omitted, the name of the interface file is constructed from the basename of the header with the suffix .xml appended. Options may be given to qdbuscpp2xml, such as those found when executing "qdbuscpp2xml --help"

Qt5LinguistTools macros

Macros available when Qt5LinguistTools is found.

Macro
Description

qt5_create_translation( qm_files directories ... sources ... ts_files ... OPTIONS ...)
Out: qm_files In: Directories sources ts_files Options: flags to pass to lupdate, such as -extensions to specify Extensions for a directory scan. Generates commands to create .ts (vie lupdate) and .qm (via lrelease) - files from directories and/or sources. The ts files are created and/or updated in the source tree (unless given with full paths). The qm files are generated in the build tree. Updating the translations can be done by adding the qm_files to the source list of your library/executable, so they are always updated, or by adding a custom target to control when they get updated/generated.

qt5_add_translation( qm_files ts_files ... )
Out: qm_files In: ts_files Generates commands to create .qm from .ts - files. The generated filenames can be found in qm_files. The ts_files must exists and are not updated in any way.

posted on 2013-04-13 20:42 Enic 閱讀(1041) 評論(0)  編輯 收藏 引用 所屬分類: QT
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            欧美xxx成人| 久久三级视频| 欧美激情一区二区三区 | 欧美精品少妇一区二区三区| 国内揄拍国内精品少妇国语| 午夜在线视频观看日韩17c| 欧美国产大片| 久久久久久久波多野高潮日日| 国产精品一二三四区| 亚洲一卡二卡三卡四卡五卡| 亚洲毛片在线看| 欧美日本一区二区三区| 亚洲人体大胆视频| 亚洲电影免费观看高清完整版在线观看| 亚洲欧美综合网| 国产日韩欧美a| 久久久国产精品一区二区中文 | 日韩写真视频在线观看| 亚洲大片免费看| 久久精品日韩欧美| 欧美一二三区精品| 国内揄拍国内精品久久| 久久久久久国产精品一区| 久久国产精品99久久久久久老狼| 欧美三级电影一区| 羞羞答答国产精品www一本 | 亚洲在线播放| 亚洲伦理网站| 国产精品一区毛片| 久久色中文字幕| 欧美77777| 亚洲香蕉成视频在线观看| 亚洲尤物在线视频观看| 国产一区二区高清| 亚洲电影免费观看高清完整版在线观看| 噜噜噜噜噜久久久久久91| 日韩一级免费| 亚洲欧美综合另类中字| 狠狠色噜噜狠狠色综合久| 亚洲国产精品久久| 国产精品试看| 免费不卡欧美自拍视频| 欧美日韩第一区| 欧美有码在线视频| 美女视频黄免费的久久| 亚洲永久精品国产| 久久久精品视频成人| 欧美一区2区三区4区公司二百| 欧美成人一区二区三区| 久久综合伊人77777蜜臀| 国产精品美女久久久久久久| 亚洲欧洲精品一区| 亚洲第一综合天堂另类专| 亚洲女人天堂av| 亚洲在线观看免费视频| 欧美日韩福利视频| 亚洲高清免费视频| 亚洲国产高潮在线观看| 久久国产主播精品| 久久国产精品久久久久久久久久| 国产精品成人aaaaa网站| 亚洲精品乱码久久久久久蜜桃91| 在线日韩欧美| 毛片一区二区三区| 欧美成人精品不卡视频在线观看| 国产一区日韩欧美| 欧美在线91| 久久久欧美精品| 精品成人一区二区三区四区| 欧美一级日韩一级| 久久免费视频在线| 国内久久精品| 鲁大师成人一区二区三区| 欧美国产亚洲精品久久久8v| 亚洲国产精品电影| 欧美激情国产日韩| 日韩视频在线一区二区| 亚洲一区二区三区在线观看视频| 欧美视频在线观看 亚洲欧| 一区二区三区毛片| 久久激情视频久久| 影音先锋一区| 欧美激情在线观看| 亚洲一级片在线看| 久久视频一区| 99pao成人国产永久免费视频| 欧美日本中文字幕| 亚洲视频在线看| 久久综合久久综合久久综合| 亚洲国产成人精品久久| 欧美激情导航| 亚洲综合久久久久| 欧美福利在线| 亚洲欧美经典视频| 国产真实乱偷精品视频免| 美女免费视频一区| 一区二区三区欧美在线观看| 久久久国产精品亚洲一区| 最新亚洲视频| 国产欧美一区二区三区视频| 久久婷婷一区| 亚洲一区免费在线观看| 免费日本视频一区| 亚洲欧美精品一区| 在线播放国产一区中文字幕剧情欧美 | 久久久久在线| 亚洲美女av电影| 国产亚洲精品高潮| 欧美人与禽猛交乱配| 欧美一区二区三区在线视频 | 亚洲一区二区视频在线| 国产在线视频欧美一区二区三区| 欧美精品v日韩精品v韩国精品v| 亚洲自拍偷拍一区| 亚洲人成亚洲人成在线观看图片| 欧美一区二区三区精品电影| 亚洲九九精品| 国产一区二区日韩精品欧美精品| 欧美精品粉嫩高潮一区二区| 久久不射2019中文字幕| 一区二区三区日韩| 亚洲国产小视频| 榴莲视频成人在线观看| 亚洲欧美日韩精品一区二区| 亚洲精品影视在线观看| 国产专区欧美专区| 国产精品一区亚洲| 国产精品v欧美精品v日韩精品 | 亚洲综合精品一区二区| 亚洲精品看片| 亚洲高清成人| 你懂的成人av| 蜜臀av性久久久久蜜臀aⅴ| 欧美影院午夜播放| 性色av一区二区三区在线观看| 日韩写真在线| 亚洲人久久久| 亚洲肉体裸体xxxx137| 在线日韩一区二区| 在线欧美不卡| 一区二区在线观看av| 国产一区二区三区奇米久涩| 国产欧美在线| 国产日韩高清一区二区三区在线| 欧美日韩视频在线一区二区观看视频| 久久躁日日躁aaaaxxxx| 久久久久免费| 欧美大色视频| 欧美日本一区二区视频在线观看| 欧美国产综合| 欧美亚洲成人精品| 国产精品拍天天在线| 国产欧美日韩在线视频| 国产一区二区三区观看| 国外精品视频| 亚洲欧洲在线观看| 一区二区精品在线观看| 亚洲视频免费在线| 亚洲欧美制服中文字幕| 久久高清免费观看| 欧美aⅴ一区二区三区视频| 欧美激情中文字幕一区二区| 亚洲人成网站在线观看播放| 日韩亚洲欧美一区二区三区| 亚洲一二三级电影| 欧美一区二区在线| 蜜桃久久精品一区二区| 欧美日韩视频在线一区二区观看视频| 欧美手机在线视频| 国内久久精品| 99国产精品久久久久久久久久 | 韩国视频理论视频久久| 亚洲电影第三页| 亚洲少妇自拍| 久久亚洲美女| 亚洲精选在线| 久久九九精品99国产精品| 欧美成人自拍视频| 国产伦精品一区二区三区视频黑人 | 久久久亚洲人| 国产精品第2页| 在线日韩av永久免费观看| 亚洲网站视频福利| 免费日韩视频| 亚洲尤物精选| 免费日韩av电影| 国产美女搞久久| 99精品国产在热久久下载| 欧美在线视频一区二区| 亚洲国产精品久久久久婷婷884| 亚洲视频碰碰| 欧美激情一区二区三区蜜桃视频 | 国产日韩高清一区二区三区在线| 在线观看欧美| 欧美一级视频精品观看| 亚洲精品午夜| 玖玖视频精品| 国内精品久久久久久久果冻传媒| 一本色道久久| 亚洲成人在线免费|