13

I have two sub directories docroot and config in my Qt project. Files in these directories shall be copied to the build directory whenever I build / debug the project.

As of https://stackoverflow.com/a/3991210/356726 this is possible by using INSTALLS (QtDoc), which seems to be much easier than running copy command (e.g here). A similar approach is described here.

config.path    = $${DESTDIR}/config
config.files   = config/*
docroot.path   = $${DESTDIR}/docroot
docroot.files  = docroot/*
INSTALLS       += config docroot

However, when I run a build in Qt Creator nothing happens. This here says I need to run make install . Can I somehow trigger / do this from within Qt Creator automatically whenever I build. I would need always the latest version of the files.

EDIT: Eventually I have used $$OUT_PWD instead of $$DESTDIR

Original comment from Logan here: "Just a note: I used $$OUT_PWD instead of $$DESTDIR to make it work. For reference $$OUT_PWD is the folder that the program is built to, and $$PWD is the folder that the program is Being built from -in other words it's where the .pro file is."

Community
  • 1
  • 1
Horst Walter
  • 13,663
  • 32
  • 126
  • 228

2 Answers2

17

What you need is a custom build step.

  1. Switch to Projects Mode: press Ctrl+5.
  2. On Build Settings tab under Build Steps click on Add Build Step.
  3. Choose Make from the menu.
  4. Write install into Make arguments: text input box.

(The version where I checked these is Qt Creator 2.4.1.)

Bill
  • 11,595
  • 6
  • 44
  • 52
  • 1
    Your part is correct, thanks. I still only have a problem with $${DESTDIR} not being set (thought it is automatically set to the build dir), tried %{buildDir} as well with no success. So have to figure the right var out. – Horst Walter Jul 22 '12 at 10:29
6

I was using Shadow Build on Window 7 and I ran into the same problem than you.

Moreover, after setting my INSTALLS and running make install I was having the following message :

Nothing to be done for `install'.

The reason is that you have to set $$DESTDIR yourself.

In my case I wanted to copy *.qml files, that's how I achieved it:

# if you are using Shadow build, you need to get the output folder
CONFIG(release, debug|release): DESTDIR = $$OUT_PWD/release
CONFIG(debug, debug|release): DESTDIR = $$OUT_PWD/debug

# if you are using normal build (non-shadow) that would have worked as well.
CONFIG(release, debug|release): DESTDIR = release
CONFIG(debug, debug|release): DESTDIR = debug    

QmlFiles.path = $$DESTDIR/Qml
QmlFiles.files += $$files(Qml/*.qml)

INSTALLS += QmlFiles

EDIT :

I figure out that $$OUT_PWD can be use to find the Shadow Build Output path. So, I fixed the code which finally come close to what you were using.

ForceMagic
  • 6,230
  • 12
  • 66
  • 88