Aleksey Kontsevich
Aleksey Kontsevich

Reputation: 5011

Copy some file to the build directory after compiling project with Qt

Done as mentioned here: https://stackoverflow.com/a/7810877/630169 However make says me:

make: Nothing to be done for `install'.

And nothing copied to build dir. Pro file contains following lines:

wav_files.path = %{buildDir}
wav_files.files += %{sourceDir}/hurray.wav

INSTALLS += wav_files

Upvotes: 4

Views: 2383

Answers (1)

tomy
tomy

Reputation: 464

here is what i am using for copying additional runtime files to build path and install destinitation:

  1. define youre files here.

    ## === 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. you must add a qmake compiler:

    ## === 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. a separate makefile target:

    ## == makefile copy target ===
    copyfiles.recurse_target = compiler_copycompiler_make_all
    copyfiles.depends        = $$copyfiles.recurse_target
    copyfiles.CONFIG        += recursive
    
  4. append the target after source build step:

    QMAKE_EXTRA_TARGETS += copyfiles
    POST_TARGETDEPS     += copyfiles ## copy files after source compilation
    
  5. to include runtime files to install destination

    INSTALLS += copytarget
    

Upvotes: 3

Related Questions