Qt Creator 中 INSTALLS 用法

在前文《Qt5 + VS2015 的命令行编译和安装》介绍了命令行的编译和安装,然而在Creator 使用中,却没有安装这一步骤。其实,是可以的。

例如

TEMPLATE = lib
TARGET = $$qtLibraryTarget($$TARGET)
target.path = $$[QT_INSTALL_PLUGINS]/designer
INSTALLS += target

需要在 Creator 中定义 “Build Step” 添加 “Custom Process Step”

  • Command: nmake
  • Arguments: install

其他保持默认即可。这样,build后,会自动将生成的文件按照 pro文件中 INSTALLS 配置进行拷贝操作。

参考

  • Qt Creator 中 INSTALLS 变量 如何起作用
    https://www.jianshu.com/p/c0f581945457

    TEMPLATE = lib
    TARGET = material
    
    CONFIG += c++11
    QT += qml quick
    
    android {
        QT += androidextras svg xml
    }
    
    HEADERS += plugin.h \
               core/device.h \
               core/units.h
    
    SOURCES += plugin.cpp \
               core/device.cpp \
               core/units.cpp
    
    RESOURCES += ../icons/core_icons.qrc
    
    target.path = $$[QT_INSTALL_QML]/Material
    
    material.files +=  \
                        components/* \
                        controls/* \
                        core/* \
                        popups/* \
                        window/*
    material.path = $$[QT_INSTALL_QML]/Material
    
    extras.files += extras/*
    extras.path = $$[QT_INSTALL_QML]/Material/Extras
    
    listitems.files += listitems/*
    listitems.path = $$[QT_INSTALL_QML]/Material/ListItems
    
    styles.files += styles/*
    styles.path = $$[QT_INSTALL_QML]/QtQuick/Controls/Styles/Material
    
    #qmldir.target = $$OUT_PWD/out/qmldir
    #qmldir.commands = mkdir -p $$OUT_PWD/out;
    #qmldir.commands += sed \"s/$$LITERAL_HASH plugin material/plugin material/\" $$PWD/qmldir > $$qmldir.target
    #qmldir.depends = $$PWD/qmldir
    qmldir.path = $$[QT_INSTALL_QML]/Material
    qmldir.files = $$PWD/qmldir
    qmldir.CONFIG += no_check_exist
    
    INSTALLS += target material extras listitems styles qmldir
    
    OTHER_FILES += $$material.files $$extras.files $$listitems.files $$styles.files
    

     

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.