Qmake 获取目标输出文件路径

Qmake get the target output file path

我有一个如下所示的 qmake 项目:

TEMPLATE = lib
CONFIG += dll
TARGET = mydll

SOURCES += ...
HEADERS += ....

现在我想添加一个 INSTALLS 部分,所以我有:

target.path = /path/to/somedir/
target.files =./$$TARGET

INSTALLS+= target

不幸的是,这不起作用,因为 $$TARGET 包含目标名称,而不是输出文件名。有没有portable方式获取输出文件名? (请不要依赖于平台的字符串连接,如 lib + $$TARGET + .so

您不必指定 target.filestarget 是一种特殊情况,它已在 qmake 中预定义。

http://qt-project.org/doc/qt-4.8/qmake-environment-reference.html#installs

If you append a built-in install set to the INSTALLS variable and do not specify files or extra members, qmake will decide what needs to be copied for you. Currently, the only supported built-in install set is target:

target.path = /usr/local/myprogram
INSTALLS += target

In the above lines, qmake knows what needs to be copied, and will handle the installation process automatically.