Qt .pro文件 qmake常用参数

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_temp
UI_DIR = $$OBJDIR/ui
	RCC_DIR = $$OBJDIR/rcc
MOC_DIR = $$OBJDIR/moc
	OBJECTS_DIR = $$OBJDIR/obj
国际化翻译
# For autocompiling qm-files.

TRANSLATIONS = translations/zh.ts \
            translations/uk.ts


#rules to generate ts
QMAKE_LUPDATE = $$[QT_INSTALL_BINS]/lupdate.exe


#limitation: only on ts can be generated
updatets.name = Creating or updating ts-files...
updatets.input = _PRO_FILE_
updatets.output = $$TRANSLATIONS
	updatets.commands = $$QMAKE_LUPDATE ${QMAKE_FILE_IN}
updatets.CONFIG += no_link no_clean
QMAKE_EXTRA_COMPILERS += updatets

#rules for ts->qm
isEmpty(QMAKE_LRELEASE) {
    win32: QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease.exe
	    else:  QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease
}
updateqm.name = Compiling qm-files...
updateqm.input = TRANSLATIONS
updateqm.output = ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}.qm
updateqm.commands = $$QMAKE_LRELEASE ${QMAKE_FILE_IN} -qm ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}.qm
updateqm.CONFIG += no_link  no_clean target_predeps
QMAKE_EXTRA_COMPILERS += updateqm

# Release all the .ts files at once
updateallqm = $$QMAKE_LRELEASE -silent $$TRANSLATIONS
调用文件中的命令
# Rules for creating/updating {ts|qm}-files
include(translations/i18n.pri)
 # Build all the qm files now, to make RCC happy
system($$fromfile(translations/i18n.pri, updateallqm))   

pkgconfig

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

使用静态和动态链接

LIBS += -Wl,-Bstatic 
LIBS += -Wl,-Bdynamic 
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值