8

qmake 提供了几个内置的平台范围,允许项目文件根据当前平台执行不同的操作:

win32 {
    ...
}
unix {
    ...
}

目录中的所有平台规范mkspecs也可用于测试各种平台/编译器组合,例如

linux-g++ {
    ...
}
win32-g++ {
    ...
}
win32-msvc2003 {
    ...
}

但是,我似乎找不到只测试编译器的方法(没有操作系统)

#This does not work
g++ {
    ...
}
msvc {
    ...
}

有没有办法做到这一点而不必列出所有组合(linux-g++ | win32-g++ | cygwin-g++ | ... {})?如果这不可能,是否有充分的理由?

4

2 回答 2

9

你可以这样做:

*-g++ {
    ...
}
win32-msvc* {
    ...
}
于 2013-01-25T14:13:15.340 回答
3

These build in platform scopes are based on the qmake spec in Qt installation directory. The way platform scopes are resolved is not documented, but it seems that qmake internally use regexes to determine if the scope apply to the current mkspecs.

Only wildcard matching is enabled (ie ?, *, [])

Note that inside qmake unix,win32, macx have several meanings, both as magic keywords, and as a regular expressions to match.

于 2013-01-25T14:33:41.980 回答