2017-10-06 144 views
0

我嘗試使用這個doc部署我的自定義部件,但是當我只編譯的.h和dll被複制,並.LIB .PDB不是:部署自定義Qt控件

這是我的.pro當我配置者的複製指示

message(Building...) 
QT   += widgets designer 

PLUGIN_CLASS_NAME = QKWidgets 

QTDIR_build { 
    message(Qt Build) 
    # This is only for the Qt build. Do not use externally. We mean it. 
    PLUGIN_TYPE = designer 
    load(qt_plugin) 
    CONFIG += install_ok 
} else { 
    message(Public Build) 
    # Public example: 

    TARGET  = $$qtLibraryTarget($$TARGET) 
    CONFIG  += plugin debug_and_release 
    TEMPLATE = lib 

    target.path = $$[QT_INSTALL_PLUGINS]/designer 
    #INSTALLS += target 


    headersDataFiles.path = $$[QT_INSTALL_HEADERS]/$$PLUGIN_CLASS_NAME/ 
    headersDataFiles.files = $$PWD/*.h 
    #INSTALLS += headersDataFiles 

    libraryFiles.path = $$[QT_INSTALL_LIBS] 
    CONFIG(debug, debug|release): libraryFiles.files = $$OUT_PWD/debug/*.lib $$OUT_PWD/release/*.pdb 
    CONFIG(release, debug|release): libraryFiles.files = $$OUT_PWD/release/*.lib 

    INSTALLS += target headersDataFiles libraryFiles 

    message(Lib dest: $$[QT_INSTALL_LIBS]) 
    message(Lib src: $$libraryFiles.files) 

} 

message(General Build) 

編輯: install_libraryFiles不會出現在Makefile中

EDIT2:

輸出:

Project MESSAGE: Building... 
Project MESSAGE: Public Build 
Project MESSAGE: Lib dest: C:/Qt/Qt5.9.0/5.9.1/msvc2017_64/lib 
Project MESSAGE: Lib src: C:/Users/SD/Documents/Studio/MyProject/Widgets/Build/Release/release/*.lib 
Project MESSAGE: General Build 
Project MESSAGE: Building... 
Project MESSAGE: Public Build 
Project MESSAGE: Lib dest: C:/Qt/Qt5.9.0/5.9.1/msvc2017_64/lib 
Project MESSAGE: Lib src: C:/Users/SD/Documents/Studio/MyProject/Widgets/Build/Release/release/*.lib 
Project MESSAGE: General Build 
Project MESSAGE: Building... 
Project MESSAGE: Public Build 
Project MESSAGE: Lib dest: C:/Qt/Qt5.9.0/5.9.1/msvc2017_64/lib 
Project MESSAGE: Lib src: C:/Users/SD/Documents/Studio/MyProject/Widgets/Build/Release/debug/*.lib C:/Users/SD/Documents/Studio/MyProject/Widgets/Build/Release/release/*.pdb 
Project MESSAGE: General Build 
+0

什麼是 「消息(庫源:$$ libraryFiles.files)」 打印?你能顯示生成的Makefile嗎? – Xplatforms

+0

我編輯我的帖子。我明白爲什麼.lib不會被複制。這是因爲lib不是在好時刻創建的。當我第二次啓動qmake時,'libraryFiles'出現在我的Makefile中。解決方案是:QMAKE_POST_LINK,但我不喜歡這樣。 – Sebastien247

回答

0

使用QMAKE_POST_LINK解決我的問題:

message(Building...) 

QT   += widgets designer 

PLUGIN_CLASS_NAME = QKWidgets 

QTDIR_build { 
    message(Qt Build) 
    # This is only for the Qt build. Do not use externally. We mean it. 
    PLUGIN_TYPE = designer 
    load(qt_plugin) 
    CONFIG += install_ok 
} else { 
    message(Public Build) 
    # Public example: 

    TARGET  = $$qtLibraryTarget($$TARGET) 
    CONFIG  += plugin debug_and_release 
    TEMPLATE = lib 

    target.path = $$[QT_INSTALL_PLUGINS]/designer 
    INSTALLS += target # headersDataFiles libraryFiles 


    headersDataFiles.path = $$[QT_INSTALL_HEADERS]/$$PLUGIN_CLASS_NAME/ 
    headersDataFiles.files = $$PWD/*.h 

    libraryFiles.path = $$[QT_INSTALL_LIBS] 
    CONFIG(debug, debug|release): libraryFiles.files = $$OUT_PWD/debug/*.lib $$OUT_PWD/debug/*.pdb 
    CONFIG(release, debug|release): libraryFiles.files = $$OUT_PWD/release/*.lib 

    win32 { 
     # Copy *.lib 
     DESTDIR_WIN = $$libraryFiles.path 
     DESTDIR_WIN ~= s,/,\\,g 
     FILES = $$libraryFiles.files 
     FILES ~= s,/,\\,g 

     for(FILE, FILES){ 
      QMAKE_POST_LINK += $$quote(cmd /c copy /y $${FILE} $${DESTDIR_WIN}$$escape_expand(\\n\\t)) 
     } 

     # Copy *.h 
     DESTDIR_WIN = $$headersDataFiles.path 
     DESTDIR_WIN ~= s,/,\\,g 
     FILES = $$headersDataFiles.files 
     FILES ~= s,/,\\,g 

     for(FILE, FILES){ 
      QMAKE_POST_LINK += $$quote(cmd /c copy /y $${FILE} $${DESTDIR_WIN}$$escape_expand(\\n\\t)) 
     } 
    } 
}