Qt .pro file - how to add conditioning on OSX version?

牧云@^-^@ 提交于 2019-12-11 12:27:40

问题


I have a Qt codebase shared between two development machines. One is OSX 10.8.5 and one is OSX 10.9.5.

The project won't compile on 10.9.5 unless I include:

QMAKE_MAC_SDK = macosx10.9

and thus I have two .pro files, one with/without that line. How can I have the .pro file conditionally include that line depending on the version of Mac OSX detected?


回答1:


I recently found some info on that and it appears to be doable (applied once) with:

OS_VERSION = $$system(uname -r)                             # common to Unix
contains(OS_VERSION, VersionTag):SOURCES += example.c       # can apply to different options
contains(OS_VERSION, VersionTag):QMAKE_MAC_SDK = macosx10.9 # like that?

Answering Tay2510, for some reason only full string worked on Linux:

OS_VERSION = $$system(uname -r)
message($$OS_VERSION)
contains( OS_VERSION, 3.13.0-39-generic ) {
    message(Generic)
}

#Output:

Project MESSAGE: 3.13.0-39-generic
Project MESSAGE: Generic


来源:https://stackoverflow.com/questions/26835557/qt-pro-file-how-to-add-conditioning-on-osx-version

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