Does anyone know how to do specify the Mac OS X SDK to build against with CMake? I have searched for cmake mac "base sdk" but this turned up nothing.
I am using CMake to generate Unix makefiles.
Update
On my 10.6 install, I see that /Developer/SDKs has the following:
- MacOSX10.4u.sdk
- MacOSX10.5.sdk
- MacOSX10.6.sdk
Perhaps I can get CMake to pass one of these paths to the compiler somehow?
Also, my 10.7 install only has:
- MacOSX10.6.sdk
- MacOSX10.7.sdk
Does this mean that it can only build for these platforms?
Update 2
Damn, I just realised that actually I’m not using Xcode — so this may affect some answers. Also, I am now trying with Mac OS X 10.8 developer preview (with some weird results, see my answer).
After trying sakra’s valid answer (valid as far as CMake is suposed to behave) unsucessfully, I had a dig around and found that if I specify the
--sysrootflag to the compiler, it seems to use the correct SDK!However, I now see this error when I compile against 10.7 (which I don’t see with 10.8):
Note:
CArchDaemonUnixis a class in Synergy (an open source project I’m working on).Update:
Just tried this on my 10.6 install, and I was getting a linker error when trying to compile for 10.5 — turns out you also need to specify the
MACOSX_DEPLOYMENT_TARGETenvironment variable!Anyway, here’s what I’m doing when running on Mountain Lion (OSX 10.8) to compile for 10.7:
Command line:
CMakeLists.txt:
I hope this helps someone! 🙂