Search code examples
linuxqtubuntuqt-creatorqmake

Qmake - doesn't copy file in linux


That code

defineTest(deployFiles) {
    win32 {
        to = $$shell_path($$3)
        for(entry,1){
            from = $$shell_path($$2/$$entry)
            QMAKE_POST_LINK += $$quote(cmd /c copy /y $$from $$to $$escape_expand(\n\t))
            PRE_TARGETDEPS += $$from
        }
        export(QMAKE_POST_LINK)
        export(PRE_TARGETDEPS)
    } else {
        to = $$shell_path($$3)
        for(entry,1){
            from = $$shell_path($$2/$$entry)
            QMAKE_POST_LINK += $$quote(cp $$from $$to $$escape_expand(\n\t))
            PRE_TARGETDEPS += $$from
        }
        export(QMAKE_POST_LINK)
        export(PRE_TARGETDEPS)
    }
}

works only on Windows OS. Where $$from - file; $$to - directory.

And I unfortunately tried that:

QMAKE_POST_LINK += $$quote(xterm -e cp $$from $$to $$escape_expand(\n\t))

And unix instead else

If I put message($$QMAKE_POST_LINK) before export in linux block, in output I have message like that:

cp /home/user/QtProject/projects/Tools/qmldir /home/user/QtProject/qml/Tools/
cp /home/user/QtProject/projects/Tools/Tools.qml /home/user/QtProject/qml/Tools/

And output of grep "qmldir" -C 5 <my_build_dir>/Makefile (same as grep "Tools\.qml" -C 5 <my_build_dir>/Makefile) like that:

.c.o:
    $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"

####### Build rules

$(TARGET): /home/user/QtProject/projects/Tools/qmldir /home/user/QtProject/projects/Tools/Tools.qml $(OBJECTS)  


Makefile: ../../../projects/Tools/Tools.pro /home/user/Qt/5.4/gcc_64/mkspecs/linux-g++/qmake.conf /home/user/Qt/5.4/gcc_64/mkspecs/features/spec_pre.prf \
        /home/user/Qt/5.4/gcc_64/mkspecs/common/shell-unix.conf \
        /home/user/Qt/5.4/gcc_64/mkspecs/common/unix.conf \

Solution

  • The project which does not work is of TEMPLATE type "aux", which is used when no compiler and no linker is involved. Thus the link command is empty.

    Looks like QMAKE_POST_LINK is written only if there is a link command.

    Makefile from app_sandbox.pro (TEMPLATE = app):

    ####### Build rules
    
    $(TARGET):  $(OBJECTS)  
        @test -d ../../bin/ || mkdir -p ../../bin/
        $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
    
    Makefile: ../../projects/app_sandbox/app_sandbox.pro ../../../Qt/5.4/gcc_64/mkspecs/linux-g++/qmake.conf ../../../Qt/5.4/gcc_64/mkspecs/features/spec_pre.prf \
    

    Makefile from Controls.pro (TEMPLATE = aux):

    ####### Build rules
    
    $(TARGET): /home/simon/nobackup/app_sandbox/projects/Design/Controls/qmldir /home/simon/nobackup/app_sandbox/projects/Design/Controls/TreeView.qml $(OBJECTS)  
    
    
    Makefile: ../../../projects/Design/Controls/Controls.pro ../../../../Qt/5.4/gcc_64/mkspecs/linux-g++/qmake.conf ../../../../Qt/5.4/gcc_64/mkspecs/features/spec_pre.prf \
    

    As you can see, both specify dependencies for the target (after $(TARGET):) but there is no link command in the seconds Makefile.