Search code examples
xcodemacosqtqmake

qmake Projects and Mac OS X SDKs


What is the most sensible way to use Mac OS SDKs from a Qt project? You need to have a path to the base SDK (MacOSX10.X.sdk), paths to the headers you need, and to indicate the frameworks you are using.

At the moment I am doing this in my pro file (with help from here; Qt, Qmake and Mac Os X SDKs):

MAC_SDK  = /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk
if( !exists( $$MAC_SDK) ) {
  error("The selected Mac OSX SDK does not exist at $$MAC_SDK!")
}
QMAKE_MAC_SDK = $$MAC_SDK

INCLUDEPATH += $$QMAKE_MAC_SDK/System/Library/Frameworks/CoreFoundation.framework/Versions/A/Headers

DEPENDPATH  += $$QMAKE_MAC_SDK/System/Library/Frameworks/CoreFoundation.framework/Versions/A/Headers

LIBS += -framework CoreFoundation

The SDKs are in the Xcode app bundle, what the hell? I was wondering if there is an environment variable which stores the path to the SDKs. Also, switching SDK versions, I have to go the the MAC_SDK path and change 10.7 to something else, is that the best way?


Solution

  • Recent versions of Xcode (4.4 onwards I think) now keep everything inside the Xcode bundle itself, instead of say /Developer previously. Miscellaneous tools and apps are a separate download.

    Not aware of any environment variable, outside of using Xcode (and specifically xcodebuild) to query the SDK?

    I've used the same approach you have to select and use the SDK in qmake projects. Typically you develop with the most recent SDK which will not change that often. You might want or need to require a minimum version of the OS (=> SDK) and would therefore use the -mmacosx-version-min=10.X compiler option to assert this.