Important: Please read the Qt Code of Conduct -

Limitations of qmake / Qt Creator make install

  • OK, I'm new here but I think I understand some of what is going on...!

    It is possible I am confusing/confounding but looking at "qmake - Advance Usage" sections on "Adding Custom Targets" and "Install sets" I've cobbled something together but am not sure what is possible and what is not.

    I'm working on a cross-platform project and I am trying to construct a workable qmake project file to install (copy, possibly with owner/group changes) two groups of "other" not (cc) compilable files in two directories, one of which is the parent to the other, core-lua & sub-lua e.g. I've abstracted the setup to the following:
    @Project root (say /home/me/src/project)
    | +---(core-lua files)
    | | +---(sub-lua files)
    | +---(doc)
    | +---(various project header + c/c++ files)
    | +---(ui files)
    I've got the following as a starting point as (part of) my project file:
    @INSTALLS = main
    unix {
    OWNER = root
    GROUP = users
    core-lua.path = "/usr/local/share/myProject/lua"
    sub-lua.path = $${core-lua.path}/submodule
    core-lua.files =
    sub-lua.files =
    core-lua.extra = sudo -A sh -c " chown $${OWNER}:$${GROUP} $${core-lua.files} && chown $${OWNER}:$${GROUP} $${core-lua.path} "
    sub-lua.extra = sudo -A sh -c " chown $${OWNER}:$${GROUP} $${sub-lua.files} && chown $${OWNER}:$${GROUP} $${sub-lua.path} "
    INSTALL += core-lua sub-lua
    core-lua.depends = main
    sub-lua.depends = main
    This results in the following (part of!) Makefile:
    COPY_DIR =cp -f -R
    INSTALL_FILE = install -m 644 -p
    INSTALL_PROGRAM = install -m 755 -p
    DEL_FILE = rm -f
    DEL_DIR = rmdir
    CHK_DIR_EXISTS = test -d
    MKDIR = mkdir -p
    install_sub-lua: first main FORCE
    @test -d $(INSTALL_ROOT)/usr/local/share/myProject/lua/submodule || mkdir -p $(INSTALL_ROOT)/usr/local/share/myProject/lua/submodule
    sudo -A sh -c " chown root:users /home/me/src/project/src/core-lua/sub-lua/sub-lua-file1 ... /home/me/src/project/src/core-lua/sub-lua/sub-lua-fileN && chown root:users /usr/local/share/myProject/lua/submodule "
    -$(INSTALL_FILE) /home/me/src/project/src/core-lua/sub-lua/sub-lua-file1 $(INSTALL_ROOT)/usr/local/share/myProject/lua/submodule/
    -$(INSTALL_FILE) /home/me/src/project/src/core-lua/sub-lua/sub-lua-fileN $(INSTALL_ROOT)/usr/local/share/myProject/lua/submodule/

    uninstall_sub-lua: FORCE
    -$(DEL_FILE) -r $(INSTALL_ROOT)/usr/local/share/myProject/lua/submodule/sub-lua-fileN
    -$(DEL_FILE) -r $(INSTALL_ROOT)/usr/local/share/myProject/lua/submodule/sub-lua-file1
    -${DEL_DIR) ${INSTALL_ROOT)/usr/local/share/myProject/lua/submodule/

    install_core-lua: first main FORCE
    @test -d $(INSTALL_ROOT)/usr/local/share/myProject/lua || mkdir -p $(INSTALL_ROOT)/usr/local/share/myProject/lua
    sudo -A sh -c " chown root:users /home/me/src/project/src/core-lua/core-lua-file1 ... /home/me/src/project/src/core-lua/core-lua-fileN && chown root:users /usr/local/share/myProject/lua "
    -$(INSTALL_FILE) /home/me/src/project/src/core-lua/core-lua-file1 $(INSTALL_ROOT)/usr/local/share/myProject/lua/
    -$(INSTALL_FILE) /home/me/src/project/src/core-lua/core-lua-fileN $(INSTALL_ROOT)/usr/local/share/myProject/lua/

    uninstall_sub-lua: FORCE
    -$(DEL_FILE) -r $(INSTALL_ROOT)/usr/local/share/myProject/lua/core-lua-fileN
    -$(DEL_FILE) -r $(INSTALL_ROOT)/usr/local/share/myProject/lua/core-lua-file1
    -${DEL_DIR) ${INSTALL_ROOT)/usr/local/share/myProject/lua/

    install: install_sub-lua install_core-lue FORCE

    uninstall: uninstall_sub-lua uninstall_core FORCE

    I seem to have several issue:
    @ Qt Creator / qmake does not seem to recognise that some of the commands it wants to use are privileged or write to possible privileged directories or files. As a matter of good practice the "make" software part of most build processes should be done as a "normal" user but the "make install" may need to be done as "root" or other elevated user.@
    @ In practice the built in makefile processing insists on doing a "make uninstall" before a "make install" - which is probably not a bad idea, but though the uninstall step does remove files in the reverse order to which it installed them within a group (e.g. "core-lua" and "sub-lua" are two such groups) it DOES NOT REVERSE THE ORDER IN WHICH IT DOES THOSE GROUPS. e.g. it installs groups in the order that they are in the "INSTALL" qmake variables but it uninstalls in the exact same order which I feel, in the absence of a corresponding "UNINSTALL" qmake variable is a problem.@
    @ Although I can provide commands to be done before the actual install of files is done with an .extra command (seen in the lines beginning "sudo" in the makefile extract) there does not seem to be provision to do anything AFTER the files have been "installed" and there is no capability for either before or after uninstall operations. It strikes me that .preinstall, .postinstall, .preuninstall, and .postuninstall, members for the "install set" qmake facility in the project file would be a "Good Idea". The possibility to override the actual install operation with a .commands redefinition would probably be inadequate so one would also want .installpath, .installfile, .uninstallpath and .uninstallfile.@
    I am only worried about *nix systems at this time.

    Thoughts anyone? (Apologise for the poor layout I'm having to learn a new markup language to write stuff here.)

Log in to reply