How to specify Mac platform in qmake (QtCreator)

CCC picture CCC · Aug 27, 2013 · Viewed 17.6k times · Source

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

Answer

Dmitry picture Dmitry · Aug 27, 2013

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
}