qmake — 循环不分割线

qmake — loop doesn't split line

这是按预期工作的(删除文件):

defineTest(removeFiles) {
    FILES_TO_DEL = $$shell_path($) # full paths
    RETURN = $$escape_expand(\n\t)
    for(FILE, FILES_TO_DEL){
        QMAKE_POST_LINK += $$RETURN $$QMAKE_DEL_FILE $$quote($$FILE)
    }
    export(QMAKE_POST_LINK)
}


FILES_TO_DEL = $$DESTDIR/imageformats/qicns.dll \
               $$DESTDIR/imageformats/qico.dll \
               $$DESTDIR/imageformats/qtga.dll \
               $$DESTDIR/imageformats/qtiff.dll \
               $$DESTDIR/imageformats/qwbmp.dll \
               $$DESTDIR/imageformats/qwebp.dll
removeFiles($$FILES_TO_DEL)

但更好的方法是不删除任何东西:

defineTest(removeFilesInDir) {
    PATH_TO_DEL = $$shell_path($)
    FILES_TO_DEL = $$shell_path($)
    message($$PATH_TO_DEL)
    message($$FILES_TO_DEL)
    RETURN = $$escape_expand(\n\t)
    for(FILE, FILES_TO_DEL){
        message($$FILE)
        QMAKE_POST_LINK += $$RETURN $$QMAKE_DEL_FILE $$quote($${PATH_TO_DEL}$${FILE})
    }
    export(QMAKE_POST_LINK)
}


FDIR = $$DESTDIR/imageformats/
FFILES = qicns.dll qico.dll qtga.dll qtiff.dll qwbmp.dll qwebp.dll
removeFilesInDir($${FDIR}, $${FFILES})

message($$PATH_TO_DEL) 显示正确路径,
message($$FILES_TO_DEL) 显示 "qicns.dll qico.dll qtga.dll qtiff.dll qwbmp.dll qwebp.dll"(如预期),
但是 message($$FILE) 显示相同的 "qicns.dll qico.dll qtga.dll qtiff.dll qwbmp.dll qwebp.dll" (只有一个)。

为什么 removeFilesInDir 中的循环与 removeFiles 中的分割线不同?如何修复 removeFilesInDir ?


Windows、Qt 5.9、QtCreator、.pro 和 .pri 文件中的 qmake。

它的作品。我从 FILENAMES 中删除 $$shell_path():

# Remove some files from directory (directory_path and file_names)
defineTest(removeFilesInDir) {
    PATH = $$shell_path($) # full path to directory
    FILENAMES = $          # filenames inside directory for remove
    RETURN = $$escape_expand(\n\t)
    for(FILENAME, FILENAMES){
        QMAKE_POST_LINK += $$RETURN $$QMAKE_DEL_FILE $$quote($${PATH}$${FILENAME})
    }
    export(QMAKE_POST_LINK)
}

来自 doc.qt:

shell_path(path)
Converts all directory separators within path to separators that are compatible with the shell that is used while building the project (that is, the shell that is invoked by the make tool). For example, slashes are converted to backslashes when the Windows shell is used.

不知道为什么是break loop