zoukankan      html  css  js  c++  java
  • Qt 如何自动安装常用依赖?

    使用 *.prf 文件自动安装依赖

    QtQt5.9.55.9.5msvc2015mkspecsfeatures 路径中添加 auto_install.prf 文件

    然后在程序配置文件(*.pro)中添加
    CONFIG += auto_install

    程序编译完成时,则会自动执行 auto_install.prf 文件中的内容,这样避免了每次都要写配置文件的麻烦

    auto_install.prf 文件内容如下:

    # 自动复制依赖
    
    CONFIG(debug,debug | release){
        QT_BIN_FILES += 
        $$[QT_INSTALL_BINS]/Qt5Cored.dll 
        $$[QT_INSTALL_BINS]/Qt5Guid.dll 
        $$[QT_INSTALL_BINS]/Qt5Widgetsd.dll 
        $$[QT_INSTALL_BINS]/Qt5Networkd.dll 
        $$[QT_INSTALL_BINS]/Qt5Sqld.dll
        QT_BIN_PATH = $$OUT_PWD/debug/
        win32 {
            for(var, QT_BIN_FILES) {
                QMAKE_POST_LINK += $$quote(cmd /c copy /y $$shell_path($$var) $$shell_path($$QT_BIN_PATH) $$escape_expand(\n\t))
            }
        }
        unix {
            for(var, QT_BIN_FILES) {
                QMAKE_POST_LINK += $$quote(cp $$var $$QT_BIN_PATH $$escape_expand(\n\t))
            }
        }
        QT_PLATFORMS_BIN_FILES += 
        $$[QT_INSTALL_PLUGINS]/platforms/qwindowsd.dll
        QT_PLATFORMS_BIN_PATH = $$OUT_PWD/debug/platforms/
        win32 {
            for(var, QT_PLATFORMS_BIN_FILES) {
                QMAKE_POST_LINK += $$quote(cmd /c xcopy /y $$shell_path($$var) $$shell_path($$QT_PLATFORMS_BIN_PATH) $$escape_expand(\n\t))
            }
        }
        unix {
            for(var, QT_PLATFORMS_BIN_FILES) {
                QMAKE_POST_LINK += $$quote(cp $$var $$QT_PLATFORMS_BIN_PATH $$escape_expand(\n\t))
            }
        }
    }else{
        QT_BIN_FILES += 
        $$[QT_INSTALL_BINS]/Qt5Core.dll 
        $$[QT_INSTALL_BINS]/Qt5Gui.dll 
        $$[QT_INSTALL_BINS]/Qt5Widgets.dll 
        $$[QT_INSTALL_BINS]/Qt5Network.dll 
        $$[QT_INSTALL_BINS]/Qt5Sql.dll
        QT_BIN_PATH = $$OUT_PWD/release/
        win32 {
            for(var, QT_BIN_FILES) {
                QMAKE_POST_LINK += $$quote(cmd /c copy /y $$shell_path($$var) $$shell_path($$QT_BIN_PATH) $$escape_expand(\n\t))
            }
        }
        unix {
            for(var, QT_BIN_FILES) {
                QMAKE_POST_LINK += $$quote(cp $$var $$QT_BIN_PATH $$escape_expand(\n\t))
            }
        }
        QT_PLATFORMS_BIN_FILES += 
        $$[QT_INSTALL_PLUGINS]/platforms/qwindows.dll
        QT_PLATFORMS_BIN_PATH = $$OUT_PWD/release/platforms/
        win32 {
            for(var, QT_PLATFORMS_BIN_FILES) {
                QMAKE_POST_LINK += $$quote(cmd /c xcopy /y $$shell_path($$var) $$shell_path($$QT_PLATFORMS_BIN_PATH) $$escape_expand(\n\t))
            }
        }
        unix {
            for(var, QT_PLATFORMS_BIN_FILES) {
                QMAKE_POST_LINK += $$quote(cp $$var $$QT_PLATFORMS_BIN_PATH $$escape_expand(\n\t))
            }
        }
    }
    
    #export(QMAKE_POST_LINK)
    

    jom.exe INSTALL

        CONFIG(debug,debug | release){
        QT_CORE.path  = $$OUT_PWD/debug/
        QT_CORE.files = $$[QT_INSTALL_BINS]/Qt5Cored.dll
    
        QT_GUI.path  = $$OUT_PWD/debug/
        QT_GUI.files = $$[QT_INSTALL_BINS]/Qt5Guid.dll
    
        QT_WIDGETS.path  = $$OUT_PWD/debug/
        QT_WIDGETS.files = $$[QT_INSTALL_BINS]/Qt5Widgetsd.dll
    
        QT_NETWORK.path  = $$OUT_PWD/debug/
        QT_NETWORK.files = $$[QT_INSTALL_BINS]/Qt5Networkd.dll
    
        QT_PLATFORMS.path  = $$OUT_PWD/debug/platforms/
        QT_PLATFORMS.files = $$[QT_INSTALL_PLUGINS]/platforms/qwindowsd.dll
    }else{
        QT_CORE.path  = $$OUT_PWD/release/
        QT_CORE.files = $$[QT_INSTALL_BINS]/Qt5Core.dll
    
        QT_GUI.path  = $$OUT_PWD/release/
        QT_GUI.files = $$[QT_INSTALL_BINS]/Qt5Gui.dll
    
        QT_WIDGETS.path  = $$OUT_PWD/release/
        QT_WIDGETS.files = $$[QT_INSTALL_BINS]/Qt5Widgets.dll
    
        QT_NETWORK.path  = $$OUT_PWD/release/
        QT_NETWORK.files = $$[QT_INSTALL_BINS]/Qt5Networkd.dll
    
        QT_PLATFORMS.path  = $$OUT_PWD/release/platforms/
        QT_PLATFORMS.files = $$[QT_INSTALL_PLUGINS]/platforms/qwindows.dll
    }
    INSTALLS += QT_CORE QT_GUI QT_WIDGETS QT_NETWORK QT_PLATFORMS
    
    win32 {
    CONFIG(debug,debug | release){
        QT_BIN_FILES += 
        $$[QT_INSTALL_BINS]/Qt5Cored.dll 
        $$[QT_INSTALL_BINS]/Qt5Guid.dll 
        $$[QT_INSTALL_BINS]/Qt5Widgetsd.dll 
        $$[QT_INSTALL_BINS]/Qt5Networkd.dll
        QT_BIN_PATH = $$OUT_PWD/debug/
        for(var, QT_BIN_FILES) {
            QMAKE_POST_LINK += $$quote(cmd /c copy /y $$shell_path($$var) $$shell_path($$QT_BIN_PATH) $$escape_expand(\n\t))
        }
    
        QT_PLATFORMS_BIN_FILES += 
        $$[QT_INSTALL_PLUGINS]/platforms/qwindowsd.dll
        QT_PLATFORMS_BIN_PATH = $$OUT_PWD/debug/platforms/
        for(var, QT_PLATFORMS_BIN_FILES) {
            QMAKE_POST_LINK += $$quote(cmd /c xcopy /y $$shell_path($$var) $$shell_path($$QT_PLATFORMS_BIN_PATH) $$escape_expand(\n\t))
        }
    }else{
        QT_BIN_FILES += 
        $$[QT_INSTALL_BINS]/Qt5Core.dll 
        $$[QT_INSTALL_BINS]/Qt5Gui.dll 
        $$[QT_INSTALL_BINS]/Qt5Widgets.dll 
        $$[QT_INSTALL_BINS]/Qt5Network.dll
        QT_BIN_PATH = $$OUT_PWD/release
        for(var, QT_BIN_FILES) {
            QMAKE_POST_LINK += $$quote(cmd /c copy /y $$shell_path($$var) $$shell_path($$QT_BIN_PATH) $$escape_expand(\n\t))
        }
    
        QT_PLATFORMS_BIN_FILES += 
        $$[QT_INSTALL_PLUGINS]/platforms/qwindows.dll
        QT_PLATFORMS_BIN_PATH = $$OUT_PWD/release/platforms
        for(var, QT_PLATFORMS_BIN_FILES) {
            QMAKE_POST_LINK += $$quote(cmd /c xcopy /y $$shell_path($$var) $$shell_path($$QT_PLATFORMS_BIN_PATH) $$escape_expand(\n\t))
        }
    }
    
    # 详细使用请查看 qt file_copies.prf 文件
    #CONFIG *= file_copies
    
    #创建名称以描述要复制的文件:
    #COPIES += DocCopyDemo
    
    #在.files成员中列出要复制的文件:
    #DocCopyDemo.files = $$files($$PWD/*.pro)
    
    #在.path成员中指定目标路径:
    #DocCopyDemo.path = $$OUT_PWD/debug
    
    #(可选)指定要从源路径修剪的基本路径:
    #DocCopyDemo.base = $$PWD/
    
  • 相关阅读:
    【BZOJ4236】JOIOJI(前缀和)
    【BZOJ3351】[IOI2009] regions(设阈值+分块)
    【BZOJ3992】[SDOI2015] 序列统计(原根+NTT+倍增)
    【洛谷5070】[Ynoi2015] 即便看不到未来(树状数组)
    【BZOJ4908】[BeiJing2017] 开车(分块)
    【BZOJ3730】震波(点分树)
    【洛谷4075】[SDOI2016] 模式字符串(点分治+哈希)
    【BZOJ4402】Claris的剑(组合数学)
    【BZOJ4767】两双手(容斥+DP)
    【BZOJ3601】一个人的数论(莫比乌斯反演+高斯消元)
  • 原文地址:https://www.cnblogs.com/cheungxiongwei/p/10449436.html
Copyright © 2011-2022 走看看