Qmake "target" variable



  • I have to deploy the binaries of a Qt library project twice - in /usr/lib and in other folder accessed by other clients of the library.

    I use the "make install" for deploying the binaries of the library in /usr/lib by:
    @
    target.path = /usr/lib
    INSTALLS += target
    @

    Now, to make the binaries deploy in another folder I tried the following options, none of which worked:
    Tryout 1:
    @
    target.path = /usr/lib
    INSTALLS += target

    add the "target" variable twice

    target.path = /home/<user>/common/lib
    INSTALLS += target
    @

    Tryout 2:
    @
    #tried to tell qmake to deploy the "target.files" to both folders
    target.path = /usr/lib /home/<user>/common/lib
    INSTALLS += target
    @

    One interesting thing to note is that one sets the "target.path":http://qt-project.org/doc/qt-4.8/qmake-variable-reference.html#installs but the target.files is empty. It seems that qmake "implicitly" knows what to copy to the provided "path". One interesting thing to note in the link provided above is that the sample code there:
    @
    target.path += $$[QT_INSTALL_PLUGINS]/imageformats
    INSTALLS += target
    @

    ... uses "target.path += ..." not "target.path = ..." statement. It seems logically correct to be able to specify multiple destination folders, since you are able to specify multiple source ones.

    The question: how to distribute the target.files to more than one directory?


  • Moderators

    Create 2 target variables:
    @
    target.path += bla/
    second.path += secondBla/
    INSTALLS += target second
    @

    I don't know if that would work, though. You can also add custom script to QMAKE_POST_LINK and copy the target inside the script.



    1. How to create second target? Isn't it quite a workaround solution (having side effects)?
    2. Adding a script that copies the binaries inside the QMAKE_POST_LINK will require to run "make", so that to build the project, as sudo. I want to run only "make install" as sudo, so that to redistribute the already built binaries.
    3. Is there a way to get all "installable" binaries that "target" knows of?

  • Moderators

    Ad. 1. See my snippet. As I've said, it might be wrong, qmake can be nasty at times.
    Ad. 2. OK then, that can be a problem. You can investigate usage of other build systems here: cmake, scons, qbs.
    Ad. 3. AFAIK, target.path is a simple variable, it does not know about anything. That is why I proposed to create another one ("second.path") in my snippet above.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.