问题描述
我在两个开发机器之间共享一个Qt代码库。一种是OSX 10.8.5,一种是OSX 10.9.5。
I have a Qt codebase shared between two development machines. One is OSX 10.8.5 and one is OSX 10.9.5.
除非包含以下内容,否则该项目不会在10.9.5上编译:
The project won't compile on 10.9.5 unless I include:
QMAKE_MAC_SDK = macosx10.9
QMAKE_MAC_SDK = macosx10.9
因此,我有两个.pro文件,一个带有/不带有该行。
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?
推荐答案
我最近如何找到.pro文件,如何根据检测到的Mac OSX版本有条件地包括该行? ,它似乎是可行的(已应用
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?
正在回答Tay2510,出于某种原因,只有完整的字符串在Linux上有效:
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
这篇关于Qt .pro文件-如何在OSX版本上添加条件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!