Compiler scope values in qmake

那年仲夏 提交于 2020-01-01 09:23:14

问题


qmake provides several built-in platform scopes, allowing a project file to perform different operations depending on the current platform:

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

All platform specifications in the mkspecs directory can also be used to test various platform/compiler combination, e.g.

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

However, I can't seem to find a way to test only the compiler (without the os)

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

Is there a way to do this without having to list all combinations (linux-g++ | win32-g++ | cygwin-g++ | ... {})? If this is not possible, is there a good reason?


回答1:


You can do it like this:

*-g++ {
    ...
}
win32-msvc* {
    ...
}



回答2:


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.



来源:https://stackoverflow.com/questions/14523148/compiler-scope-values-in-qmake

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!