24

In my Qt project I'm trying to copy libraries as part of the build process. The goal is to have a ready made distribution after the build with all necessary dynamic libraries.

This seems acheivable with the INSTALLS variable, but I find the documentation a bit thin: qmake Variable Reference: INSTALLS

In the example given:

  • Is target already defined, or is defined by writing target.path =?
  • Where is the documentation for possible members? .path and ...?
feedc0de
  • 3,646
  • 8
  • 30
  • 55
Eirik M
  • 726
  • 1
  • 6
  • 12
  • Looks like `target` is defined in the example. The output in the makefile is a definition of `install_target`. There were some errors related to the referencing variables. – Eirik M Feb 21 '12 at 13:24

2 Answers2

24

Yeah, the docs have much to be desired here.

target is already defined, but that is a special case. You can define your own additional deployment sets. Here is how we specify the image format plugins:

imageformats.path = /opt/some/path/bin/imageformats
imageformats.files += $$[QT_INSTALL_DATA]/plugins/imageformats/*.so
INSTALLS += imageformats

Here is the minimal documentation about the three commands: http://doc.qt.io/qt-4.8/qmake-environment-reference.html#installs

yourset.path = /path/in/which/to/install/files
yourset.files = /files/to/install
yourset.extra = custom commands to run, eg. `touch somefile.txt`
INSTALLS += yourset
pajlada
  • 7
  • 1
  • 4
Dave Mateer
  • 17,608
  • 15
  • 96
  • 149
10

target is whatever string you want to use. It is your own identifier.

target.files defines what you want to install.

target.path is the location (directory) you want to put the target.files in.

For example, let's say I have a file called "config.xml" that I want to copy to the directory "xyzzy". I would use the following in my qmake .pro file to specify that.

my_file.files = config.xml
my_file.path = xyzzy

INSTALLS += my_file

BTW, to actually make the file copy, you will have to execute make install.

You may also find the answer helpful in understanding: Copy a file to build directory.

Community
  • 1
  • 1
jwernerny
  • 6,978
  • 2
  • 31
  • 32
  • Thanks for the link. Is `%{buildDir}` valid syntax or just to illustrate. I tried it, but in Qt Creator the expression is never evaluated :( – Eirik M Feb 21 '12 at 13:53
  • @eriktheblond The example in the link assumes `buildDir` has already been defined somewhere in the qmake .pro file (i.e. `buildDir = a/b/c`). – jwernerny Feb 21 '12 at 14:41
  • @jwernerny Good answer except target is actually a "built-in" and a bit special, not whatever you want to use. It correlates to the TARGET. See - https://qt-project.org/doc/qt-4.8/qmake-environment-reference.html#installs. – spinkus Jul 05 '14 at 03:02
  • @EirikM *Maybe* in an older version, in Qt 5.5 onwards, you may do the following (an example). Somewhere in your `Project.pro` file `LIB_DIR = ../libs` and later, `MY_LIB = $$LIB_DIR/my_lib/` – CybeX Feb 03 '18 at 06:47