qmake

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


I have a file "settings.ini" which needs to reside next to the Qt executable.

I can add a custom build step for this in Qt Creator which calls something like this:

copy %{sourceDir}/settings.ini %{buildDir}/settings.ini

This works great so far, but I'd like to include this in the *.pro file so I can put this up in our SVN too.

How can I do this using qmake/.pro-files only?


Solution

  • You probably want to use the INSTALLS keyword in QMake. It will require you to run make install after your build, but it does work cross-platform.

    install_it.path = %{buildDir}
    install_it.files += %{sourceDir}/settings.ini
    
    INSTALLS += install_it