Important: Please read the Qt Code of Conduct -

how to add line break in qmake function

  • Hi, everyone.

    I'm busy recently, so that no time to login the forum. my god.

    I have a problem about line break in qmake function, because of the error for command too long.

    The function:

            src_dir = $$1 #first argument
            dst_dir = $$2 #second argument
                    cmd +=  xcopy $$name $$dst_dir\ /y /c &&
                    curFile =$$name
                cmd +=  xcopy $$curFile $$dst_dir\ /y /c

    The result of cmd is in one line, it causes the error of command to long. so, I needs insert line break. how to do, thanks.

  • Lifetime Qt Champion

    Hi @spobit,

    maybe you can explain what you really want to do? Why do you put all these xcopy commands in one variable?

    You could run xcopy directly in the for loop, but even better would be to use xcopy's possibility to copy a whole directory: xcopy $$src_dir $$dst_dir\ /y /c


  • @aha_1980 Thank you very much, first. I got a way by my team:

        for(file, src_files) {
            # replace slashes in source path for Windows
            win32:file ~= s,/,\\,g
            QMAKE_PRE_LINK += $$QMAKE_COPY_DIR $$shell_quote($$file) $$shell_quote($$dst_dir) $$escape_expand(\\n\\t)

Log in to reply