QtNX on Mac OS X - nearly there
Posted by George Wright Tue, 08 Jan 2008 07:41:00 GMT
I must say that I’m very impressed with Trolltech’s attention to detail for their cross platform work; qtnx compiled (almost) without a hitch on OS X. After hacking around a few build system problems and linking issues, I managed to get qtnx to compile and link (it took ~5 minutes!), producing this particularly nice result:
I’m having a bit of trouble with working out how to create a sensible buildsystem for the Mac. If anyone’s got any experience with qmake on OS X then please drop me a line; in particular, I’m looking out for ways in which qmake can define what platform I’m on so I can have #ifdef’d sections of code for each platform, as well as using things like pkg-config on platforms where it exists and whatever equivalent there is on OS X. In fact, hooking qmake into Xcode for this could be ideal.
I haven’t tested if this actually connects yet; I haven’t got round to compiling the open source NoMachine dependencies (nxproxy, nxssh, nxcompsh) but it shouldn’t be too hard to get it all working nicely (I hope!).


You can always use the name of the current mkspec (for QMake) as a conditioner for your build, e.g:
mac-g++ { something; } !mac-g++ { something else; }
Note! The mkspec is probably not called mac-g++, you have to check for the real name in the $QTDIR/mkspecs directory.
See QMake’s scope feature
http://doc.trolltech.com/4.3/qmake-advanced-usage.html#scopes
Us here at Last.fm must be the kings of cross platform qmake usage. Feel free to send me a mail.
Pardon me for asking, but are you determined to use QMake? I just ask because everything you list (#ifdefed sections for different platforms, pkg-config, and XCode integration) all work with CMake (including the KDE build). I can understand, and totally respect, if you want to stay with QMake and not make CMake a requirement, but I just wanted to mention it because it could easily do all of that.
The correct target names are macx-* (there’s macx-g++, macx-icc, macx-pbuilder, macx-xcode and macx-xlc, you can use macx-* to match them all). There’s also darwin-* for X11 on OS X, this is not officially supported by Trolltech (but projects like Fink have patches to support that target).
But to #ifdef code in your source code, the best is probably to use the compiler predefines (i.e. APPLE) or the macros Qt defines for you (e.g. QWS_MAC, QOSMAC). Using QWS_MAC is probably the best solution if you want the code to be used only with native Qt/Mac, not Qt/X11.
Arrgh, my underscores got mangled. That’ll teach me not to preview and not to read the markup help. ;-)
But to #ifdef code in your source code, the best is probably to use the compiler predefines (i.e.
__APPLE__) or the macros Qt defines for you (e.g.Q_WS_MAC,Q_OS_MAC). UsingQ_WS_MACis probably the best solution if you want the code to be used only with native Qt/Mac, not Qt/X11.You can also do that:
Do you know about EPM?
With EPM you maintain one source file to control the building of native packages for Linux (.deb, .rpm, .tgz) as well as Mac OS X (.dmg), IRIX, *BSD, AIX, and what have you.
See also EPM docu.