4

I have a Qt-based application that uses a number of dlls that are built outside of the project. These dlls are checked into source because we will not be rebuilding them very frequently (they take on the order of hours to build, I don't want those to be in the main project). I want to copy those dlls into the appropriate directories (release, debug) once building has occurred. Is there a way to incorporate that copy step into the .pro file, so that the copying is propagated to each machine that uses the code? The suggestion I've found in places like this is to use a post-build step and build a batch file, but post-build steps are not shared between machines (they are stored in the .pro.user file, which is machine specific).

I've tried using something like:

Debug:POST_TARGETDEPS = ../../Dir1/Dir2/bin/mylib.dll

But that doesn't copy the file into the debug directory nor into the DESTDIR directory.

Community
  • 1
  • 1
mmr
  • 14,781
  • 29
  • 95
  • 145

1 Answers1

5

You will want to use the INSTALLS keyword and then make sure when you build you do a make install.

dlls_to_move.path = $$DESTDIR
dlls_to_move.files += ../../Dir1/Dir2/bin/mylib.dll
INSTALLS += dlls_to_move

You can find more information on INSTALLS in the QMake documentation.

TheDarkKnight
  • 27,181
  • 6
  • 55
  • 85
jwernerny
  • 6,978
  • 2
  • 31
  • 32
  • I'm on windows and am not using mingw or cygwin. Will this work, given that I have no 'make install'? – mmr Jun 09 '11 at 14:55
  • How are you invoking the build? There should be something similar to a makefile created and a builder invoked. If the builder is nmake, then you just need to invoke "nmake install". – jwernerny Jun 10 '11 at 14:25
  • I'm using the creator, but I think I can see why this is not possible using Qt. I want a build directive that means that different computers can use the same .pro file without any local changes. I suspect that because Qt's build directory is set on a machine-by-machine basis, so specifying something that something goes into the build directory is not doable. But hey, I'll say you answered the question :) – mmr Jun 14 '11 at 05:13
  • The project I am working on currently does use this across different machines (and OSs). The key enablers for us are that (1) the location of stuff to move is in the source tree (2) the destination is either defined relatively or based off an environment variable. – jwernerny Jun 14 '11 at 17:34
  • In QtCreator, I usually just go to the Build Settings for the project and add a new "Make" target to the Build Steps. In that target I use the defaults except for setting "Make arguments:" to "install" – jwernerny Jun 14 '11 at 17:36
  • I got stuck on the same problem, I am wondering how you are defining your `dlls_to_move` variable though, could you past more details about that part? Regards – ForceMagic Oct 25 '12 at 06:43
  • @ForceMagic `dlls_to_move` is defined as above. The `.path` describes the destination. The `.files` describes what to copy. By adding `dlls_to_move` to INSTALLS, it cause QMake to add moving the `.files` to `.path` to the make file for when `make installs` is run. – jwernerny Oct 25 '12 at 15:12