I would like to set some configurations for Mac OS in pro
file via QtCreator. I read the document, and found it supports Windows and Unix, like the following,
win32 {
SOURCES += hellowin.cpp
}
unix {
SOURCES += hellounix.cpp
}
I understand Mac OS is *nix-like OS, however, I still want to make difference with Linux. Is there a way to do this?
Ubuntu + Qt5.1
You can detect Mac OS X this way:
macx {
SOURCES += hellomac.cpp
}
But to make the difference with Linux you would rather like to specify
unix:!macx {
SOURCES += hellolinux.cpp
}
macx: {
SOURCES += hellomac.cpp
}
'mac': it applies both on Mac OS X and iOS
'macx': it is specific to Mac OS X.
So, if you wanna include iOS support later, or simply be flexible (and why not?), you will better use 'mac'. Otherwise go for the latter. So you will need either of those.
Here you can find the official documentation:
http://qt-project.org/doc/qt-5.1/qmake/qmake-language.html#platform-scope-values
Here are the variants you may need based on your specific use case.
win32 {
SOURCES += hellolinux.cpp
} mac {
SOURCES += hellomac.cpp
}
win32 {
SOURCES += hellolinux.cpp
} macx {
SOURCES += hellomacx.cpp
}
Here you can find the source code to seek more information about undocumented scopes:
http://qt.gitorious.org/qt/qtbase/source/730bc064a070e886e10950ccfd59780e8976f5fd:mkspecs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With