Macos – How to specify Mac platform in qmake (QtCreator)

macosqmakeqtqt4qt5

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

Best Answer

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
}