if / else如果等效于qmake / pro Qt文件

问题描述 投票:1回答:1

我有时不得不像这样写qmake pro文件:

QMAKE_EXTRA_TARGETS += activate

macos {
    clear_cache.commands += defaults write io.delille.$$TARGET activated 1;
}

win32 {
    clear_cache.commands += another working command;
}


linux {
    clear_cache.commands += echo unsupported;
}

ios {
    clear_cache.commands += echo unsupported;
}

[是否有一种方法可以避免像大多数语言在if / else if语句中所允许的那样以更简单的方式列出所有不受支持的平台?

qt if-statement qmake
1个回答
1
投票

qmake关于if / else的已知信息:https://doc.qt.io/qt-5/qmake-language.html#scopes

win32:xml {
    message(Building for Windows)
    SOURCES += xmlhandler_win.cpp
} else:xml {
    SOURCES += xmlhandler.cpp
} else {
    message("Unknown configuration")
}
© www.soinside.com 2019 - 2024. All rights reserved.