Qmake - 不会在linux

时间:2015-05-28 14:06:05

标签: linux qt ubuntu qt-creator qmake

该代码

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)
    }
}

仅适用于Windows操作系统。 $$from - 文件; $$to - 目录。

我不幸地尝试过:

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

unix代替else

如果我在导出之前将message($$QMAKE_POST_LINK)放在linux块中,在输出中我会有这样的消息:

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/

grep "qmldir" -C 5 <my_build_dir>/Makefile的输出(与grep "Tools\.qml" -C 5 <my_build_dir>/Makefile相同)就像那样:

.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 \

1 个答案:

答案 0 :(得分:0)

不起作用的项目是TEMPLATE类型&#34; aux&#34;,在没有编译器和链接器时使用。因此链接命令为空。

只有在有链接命令时才会显示QMAKE_POST_LINK

来自app_sandbox.pro的Makefile(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 \

来自Controls.pro的Makefile(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 \

如您所见,两者都指定了目标的依赖关系(在$(TARGET):之后)但在秒Makefile中没有链接命令。