2013-03-28 42 views

回答

3

这里是我使用什么额外的复制运行时文件到构建路径和安装destinitation:

  1. 定义文件的youre这里。

    ## === define copy files for installation and build === 
    
    copytarget.path = /path/to/installation 
    copytarget.files += $$files(example/filename*) 
    ## wildcard for filename1 filename2 filename3 ... 
    
    message("found files for copytarget: "$$copytarget.files) 
    
  2. 必须添加的qmake编译:

    ## === os specific dir separator === 
    
    win32: copytarget.files ~= s,/,\\,g 
    
    
    ## === copy compiler for makefile === 
    
    DirSep =/
    win32: DirSep = \\ 
    
    for(f,copytarget.files) tmp += $$PWD$$DirSep$${f} ## make absolute paths 
    copycompiler.input  = tmp 
    
    isEmpty(DESTDIR):DESTDIR=. 
    copycompiler.output  = $$DESTDIR$$DirSep${QMAKE_FILE_BASE}${QMAKE_FILE_EXT} 
    
    copycompiler.commands  = $(COPY_FILE) ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT} 
    
    copycompiler.CONFIG  = no_link no_clean 
    ## other CONFIG options are: depends explicit_dependencies target_predeps 
    
    copycompiler.variable_out = QMAKE_DISTCLEAN 
    QMAKE_EXTRA_COMPILERS += copycompiler 
    
  3. 一个单独的makefile目标:

    ## == makefile copy target === 
    copyfiles.recurse_target = compiler_copycompiler_make_all 
    copyfiles.depends  = $$copyfiles.recurse_target 
    copyfiles.CONFIG  += recursive 
    
  4. 追加目标源生成步骤之后:

    QMAKE_EXTRA_TARGETS += copyfiles 
    POST_TARGETDEPS  += copyfiles ## copy files after source compilation 
    
  5. 包括运行时文件安装目的地

    INSTALLS += copytarget 
    
+0

感谢您的回答,将检查能够当。 – 2013-11-08 16:51:56

+0

你好,你如何适应这个解决方案来复制目标生成的文件?对于这个例子,假设我想在库构建完成后复制库目标的dll文件。 – 2016-06-01 17:36:55

相关问题