Qt Qml Application Deploy (部署Qt程序以便发布到平台上执行)

QMake: (Add this in .pro)

isEmpty(TARGET_EXT) {
    win32 {
        TARGET_CUSTOM_EXT = .exe
    }
    macx {
        TARGET_CUSTOM_EXT = .app
    }
} else {
    TARGET_CUSTOM_EXT = $${TARGET_EXT}
}

DEPLOY_COMMAND = $$(QTDIR)/bin/windeployqt

CONFIG( debug, debug|release ) {
    # debug
    DEPLOY_TARGET = $$shell_quote($$shell_path($${OUT_PWD}/debug/$${TARGET}$${TARGET_CUSTOM_EXT}))
} else {
    # release
    DEPLOY_TARGET = $$shell_quote($$shell_path($${OUT_PWD}/release/$${TARGET}$${TARGET_CUSTOM_EXT}))
}

QMAKE_POST_LINK = $${DEPLOY_COMMAND} $${DEPLOY_TARGET}     --qmldir $${PWD}     --no-translations     --no-system-d3d-compiler     --no-webkit2     --no-angle     --no-opengl-sw     --no-virtualkeyboard
message($${QMAKE_POST_LINK})

CMake:

string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_LOWER)
get_target_property(_qmake_executable Qt5::qmake IMPORTED_LOCATION)
get_filename_component(_qt_bin_dir "${_qmake_executable}" DIRECTORY)
find_program(DEPLOYQT_EXECUTABLE NAMES windeployqt HINTS "${_qt_bin_dir}")
add_custom_command(TARGET PROJECT_NAME
        POST_BUILD
        COMMAND ${DEPLOYQT_EXECUTABLE} "$<TARGET_FILE:PROJECT_NAME>"
        --force
        --${CMAKE_BUILD_TYPE_LOWER}
        --qmldir ${CMAKE_SOURCE_DIR}/qml
        --no-translations
        --no-system-d3d-compiler
        --no-webkit2
        --no-angle
        --no-opengl-sw
        --no-virtualkeyboard
    )

Qt Qml Application Deploy (部署Qt程序以便发布到平台上执行)

上一篇:关于Access中文函数名引用的说明


下一篇:AcWing 3485. 最大异或和 异或字典树的删除