QMake本身就提供了在pro下可判断平台的变量参数,如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
macx {
# mac only
}
ios{
# ios only
}
android{
# android only
}
unix:!macx{
# linux only
}
win32 {
# windows only
}

linux(也可以作为android平台)并没有单独的参数判断,但是可以通过是否是unix并且不是mac os x来判断是在linux系统底下。

若根据某些宏是否存在来执行不同的配置则可以:

添加宏定义:

DEFINES += TEST

判断宏定义是否存在:

1
2
3
4
5
contains(DEFINES, TEST) {
message('-->>(DEFINES, TEST)')
} else {
message('-->>not contains (DEFINES, TEST)')
}