作者:运儿0315 | 来源:互联网 | 2023-07-16 23:43
引用:https:blog.csdn.netwkr2005articledetails93711321qt的pro配置文件中也可添加各种编译前后的操作及配置,主要通过 QMAKE_
引用:https://blog.csdn.net/wkr2005/article/details/93711321
qt的pro配置文件中也可添加各种编译前后的操作及配置,主要通过 QMAKE_POST_LINK和QMAKE_PRE_LINK;
QMAKE_POST_LINK表示编译后执行内容
QMAKE_PRE_LINK表示编译前执行内容
举例如下:
#-------------------------------------------------
#
# Project created by QtCreator 2020-11-13T10:30:08
#
#-------------------------------------------------
QT -= gui
TARGET = ComuPCIe
TEMPLATE = lib
DEFINES += COMUPCIE_LIBRARY
# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
DESTDIR += ../bin
SOURCES += \
comupcie.cpp
HEADERS += \
comupcie.h
unix {
target.path = /usr/lib
INSTALLS += target
}
win32 {
binDstPath = C:/radsim/bin
libDstPath = C:/radsim/lib
headerDstPath = "C:\\radsim\\include\\"
libSrcName = $$DESTDIR/*.lib
binSrcName = $$DESTDIR/*.dll
headerSrcName = $$PWD/comupcie.h
exists($$headerSrcName){
message($$headerSrcName)
message($$headerDstPath)
message($$replace(headerSrcName, /, \\))
}
QMAKE_POST_LINK += copy /Y $$replace(headerSrcName, /, \\) $$headerDstPath
}
就是说, QMAKE_POST_LINK 后面可以追加要执行的命令,这些命令必须可以再命令行运行,当然,这就运行你写脚本了。
补充:
在windows系统下面,由于命令行中大部分命令不支持“/”,所以把“/”替换成“\”。
多条命令语句之间可以用&&隔开,自动连续执行;
定义的宏变量,在非首位置使用时,需要带{}, 如
PWD/">PWD/
PWD/{DESTDIR}/$${TARGET}.dll中的DESTDIR和TARGET。