Qt .pro文件 qmake常用参数

来源:互联网 发布:js 执行上下文 编辑:程序博客网 时间:2024/05/16 15:40

Configuration Features

qmake can be set up with extra configuration features that are specified in feature (.prf) files. These extra features often provide support for custom tools that are used during the build process. To add a feature to the build process, append the feature name (the stem of the feature filename) to the CONFIG variable.

For example, qmake can configure the build process to take advantage of external libraries that are supported by pkg-config, such as the D-Bus and ogg libraries, with the following lines:

CONFIG += link_pkgconfig
PKGCONFIG += ogg dbus-1

常用命令参数

HEADERS += hello.h      //工程包含头文件SOURCES += hello.cpp    //工程包含的源文件  qmake -o Makefile hello.pro  //生成makefile文件qmake -tp vc hello.pro       //生成vs文件QMAKE_CXXFLAGS += -Wno-unused-parameter -Wno-unused-variable   //取消没有使用参数警告QMAKE_CXXFLAGS += -fno-exceptions                              //设置没有异常QMAKE_RESOURCE_FLAGS += -compress 9 -threshold 0               //设置资源文件的压缩等级

编译文件存放位置

OBJDIR = obj_tempUI_DIR = $$OBJDIR/uiRCC_DIR = $$OBJDIR/rccMOC_DIR = $$OBJDIR/mocOBJECTS_DIR = $$OBJDIR/obj

国际化翻译

# For autocompiling qm-files.TRANSLATIONS = translations/zh.ts \            translations/uk.ts#rules to generate tsQMAKE_LUPDATE = $$[QT_INSTALL_BINS]/lupdate.exe#limitation: only on ts can be generatedupdatets.name = Creating or updating ts-files...updatets.input = _PRO_FILE_updatets.output = $$TRANSLATIONSupdatets.commands = $$QMAKE_LUPDATE ${QMAKE_FILE_IN}updatets.CONFIG += no_link no_cleanQMAKE_EXTRA_COMPILERS += updatets#rules for ts->qmisEmpty(QMAKE_LRELEASE) {    win32: QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease.exe    else:  QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease}updateqm.name = Compiling qm-files...updateqm.input = TRANSLATIONSupdateqm.output = ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}.qmupdateqm.commands = $$QMAKE_LRELEASE ${QMAKE_FILE_IN} -qm ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}.qmupdateqm.CONFIG += no_link  no_clean target_predepsQMAKE_EXTRA_COMPILERS += updateqm# Release all the .ts files at onceupdateallqm = $$QMAKE_LRELEASE -silent $$TRANSLATIONS

调用文件中的命令

# Rules for creating/updating {ts|qm}-filesinclude(translations/i18n.pri) # Build all the qm files now, to make RCC happysystem($$fromfile(translations/i18n.pri, updateallqm))   

pkgconfig

CONFIG += link_pkgconfigPKGCONFIG += ogg dbus-1  (/usr/lib/x86_64-linux-gnu/pkgconfig)

使用静态和动态链接

LIBS += -Wl,-Bstatic LIBS += -Wl,-Bdynamic