[Cmake] CMake always links X11 OpenGL on MacOS X

William A. Hoffman billlist at nycap.rr.com
Tue, 10 Feb 2004 08:43:51 -0500


I am not sure what is wrong, but the FindOpenGL.cmake from 1.8.3 should
look like this:


# On OSX default to using the framework version of opengl
# People will have to change the cache values of OPENGL_glu_LIBRARY 
# and OPENGL_gl_LIBRARY to use OpenGL with X11 on OSX
IF (APPLE)
  SET (OPENGL_gl_LIBRARY "-framework OpenGL" CACHE STRING "OpenGL lib for OSX")
  SET (OPENGL_glu_LIBRARY "-framework AGL" CACHE STRING "AGL lib for OSX")
ENDIF (APPLE)

It should prefer the Cocoa over X11.  

Where did you get this CMake 1.8.3-1?

-Bill

At 07:52 PM 2/9/2004, Chris Scharver wrote:
>Hello,
>
>I'm using CMake 1.8.3-1, and X11 libraries are linked into applications on MacOS X whether on not they're being used. I'm compiling with Cocoa, but I don't want the X11 libraries (which are present on my system) linked with my executable except for X11 builds. I modified FindOpenGL.cmake to provide an option OPENGL_USE_APPLE_X11 for choosing whether to use X11 or not, with a default value OFF. I have tested it with 10.3.2, and it rightly does not grab X11 libraries when linking.
>
>The problem comes when I try to change that variable to ON. The OPENGL_gl_LIBRARY and OPENGL_glu_LIBRARY variables are not reset to search for the X11 versions. Since they're already in the cache (and also set as strings rather than files), they cannot use the GUI widgets. I suppose this issue is related to previous mails about removing cache entries, but there wasn't a clear solution. Since FindOpenGL.cmake is pretty important, I would like to keep things as straight-forward as possible. One approach could completely clear all cache entries that depend on a particular variable if that variable changes. That would take a lot more work and could be dangerous, so I'm trying to figure out something less drastic.
>
>I know I can manually set the values, but I would like to fix FindOpenGL.cmake to do automatic searches based on the value of OPENGL_USE_APPLE_X11. I've attached my FindOpenGL.cmake file, so please offer any suggestions. :)
>
>Thanks,
>Chris
>
>--
>Chris Scharver
>Electronic Visualization Laboratory
>The University of Illinois at Chicago
>Ph: 312-996-3002   FAX: 312-413-7585
><http://www.evl.uic.edu/scharver/>
>
>
>