[CMake] Detecting Mac OS X Version

James Bigler bigler at cs.utah.edu
Wed Oct 31 13:26:17 EDT 2007


Sean McBride wrote:
> On 10/31/07 9:28 AM, Mike Jackson said:
> 
>> Would someone have an example of detecting the specific version of OS  
>> X that cmake is running on? I would like add values based on OS X  
>> version.
>>
>> IF (OS_X_VERSION matches "10.5")
>>   ......
>> ENDIF (OS_X_VERSION matches "10.5")
>>
>> or something to that effect..
> 
> Mike,
> 
> I'm curious... in what situation does it matter which version of the OS
> is being run?  Wouldn't it be better to check which SDK is being used? 
> Or the deployment version?

Is there an easy way to determine the deployment version of the integrated X 
environment?

OSX 10.5 changed to using Xorg instead of XFree86 and some of the paths have 
changed.  As well there is some confusion with the linker when trying to link 
the X version of libGL.  Here's what one of our developers said about it:

"The main issue is linkpaths, OSX has two GL libraries that seem to conflict and 
with the default CMake settings it picks up the wrong library. Basically CMake 
does not write out the proper linking instructions. To fix this for Leopard, a 
hack is added that adds the OpenGL libraries to the LINK_FLAGS variables, which 
circumvents the parsing of filenames in -Lpath -llibname, the latter will cause 
OSX to find the OpenGL version in the frameworks. Currently CMake does not have 
an option to include paths directly, hence we hacked it to make it work."

738··IF·(APPLE_LEOPARD) 

739····SET·(GL_LIBRARY·""·CACHE·INTERNAL·"OpenGL·Libs"·FORCE) 

740····SET·(GL_LINK·"·/usr/X11R6/lib/libGL.dylib·/usr/X11R6/lib/libGLU.dylib·-framework·AGL"·CACHE·INTERNAL·"Link·options·for·OpenGL·libs"·FORCE) 

741····SET·(X_LIBRARY·""·CACHE·INTERNAL·"OpenGL·Libs"·FORCE) 

742····SET·(X_LINK·"·/usr/X11R6/lib/libX11.dylib·/usr/X11R6/lib/libXext.dylib·-framework·Carbon"·CACHE·INTERNAL·"Link·options·for·X11·libs"·FORCE)
743 

744··ELSE·(APPLE_LEOPARD) 

745····SET·(GL_LIBRARY·/usr/X11R6/lib/libGL.dylib·/usr/X11R6/lib/libGLU.dylib·"-framework·AGL"·CACHE·INTERNAL·"OpenGL·Libs") 

746····SET·(GL_LINK·""·CACHE·INTERNAL·"Link·options·for·OpenGL·libs"·FORCE) 

747····SET·(X_LINK·""·CACHE·INTERNAL·"Link·options·for·X·libs"·FORCE) 

748····SET·(SCIRUN_INCLUDE_ADDITIONAL·${SCIRUN_INCLUDE_ADDITIONAL}·${GL_INCLUDE})···· 

749··ENDIF·(APPLE_LEOPARD) 


87··IF(APPLE_LEOPARD) 

88····SET_TARGET_PROPERTIES(Core_Events·PROPERTIES·LINK_FLAGS··"${GL_LINK}·${X_LINK}")
89··ENDIF(APPLE_LEOPARD)

James


More information about the CMake mailing list