如何获取PRO文件中的目标目录

How to get the target directory in PRO file

我正在调试模式下构建应用程序,如何在 pro 文件中获取目标目录。 我没有使用 "DESTDIR"

明确提及目标目录
    CORE_API_PATH = $$PWD/../Bin
    SEPARATOR = "/"

    QT       += core gui xml widgets printsupport svg

    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

    TARGET = Cinemas
    TEMPLATE = app

    RC_ICONS += cinemas-icon.ico

    qtHaveModule(opengl) {
        DEFINES += QT_OPENGL_SUPPORT
        QT += opengl
    }

    LIBS += -lQt5Concurrent -lglu32 -lopengl32 -lglut32 -LC:\Qt\Qt5.3.2\Tools\mingw482_32\i686-w64-mingw32\lib\glut -LC:\Qt\Qt5.3.2\Tools\mingw482_32\i686-w64-mingw32\lib\glu32


    win32:CONFIG(release, debug|release): LIBS += "$$quote($${CORE_API_PATH}/Release/CoreApi.dll)"
    else:win32:CONFIG(debug, debug|release):  LIBS += "$$quote($${CORE_API_PATH}/Debug/CoreApiD.dll)"

    win32:CONFIG(release, debug|release): LIBS += -L$$PWD/SSH/lib/ -lssh2
    else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/SSH/lib/ -lssh2
    else:unix: LIBS += -L$$PWD/SSH/lib/ -lssh2

    win32:CONFIG(release, debug|release): LIBS += -L$$PWD/3rdparty/qwt/lib/ -lqwt
    else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/3rdparty/qwt/lib/ -lqwtd
    else:unix: LIBS += -L$$PWD/qwt/lib/ -libqwt


    QT += concurrent network

    CONFIG += c++11

    RESOURCES += \
        cinemasresource.qrc

    FORMS += \

我想将 app.exe 从当前文件夹复制到其他文件夹

在 Windows 上,您可以使用 DLLDESTDIR 变量指定复制目标 dll 或 exe 的位置。只需将其添加到您的 .pro 中即可:

CONFIG(release, debug|release): DLLDESTDIR +=  $$PWD/../exec

在 Linux 上,您可以使用 QMAKE_POST_LINK 变量,其中包含将 TARGET 链接在一起后要执行的命令。所以就像:

CONFIG(release, debug|release): QMAKE_POST_LINK += $$quote(cp project $$PWD/../exec)

这里project是您通过TARGET = project

提供的目标文件名

这些会将可执行二进制文件复制到名为 exec 的目录,该目录比程序工作目录高一级。你可以有你的任意路径。