[Cmake] Re: Carbon, Cocoa, X

Chris Scharver scharver at evl.uic.edu
Fri, 2 Apr 2004 11:35:48 -0600


On Apr 2, 2004, at 10:40 AM, Bill Hoffman wrote:

> Here is cvs cmake:
>   IF (OPENGL_gl_LIBRARY)
>     INCLUDE( ${CMAKE_ROOT}/Modules/FindX11.cmake )
>     IF (X11_FOUND)
>       IF (NOT APPLE)
>         SET (OPENGL_LIBRARIES ${X11_LIBRARIES})
>       ENDIF (NOT APPLE)
>     ENDIF (X11_FOUND)
>   ENDIF (OPENGL_gl_LIBRARY)

This does prevent X11 libraries from linking even if they're found. 
However, this also presents a problem when I DO want to link with X11. 
I like to choose whether to use X11 or not via CMake without having to 
manually edit the CMakeCache.txt file. When working with windowing 
code, I routinely build both x11 and Cocoa versions. Leave it to us Mac 
users to make everything screwy. ;)

> However, a more consistent approach to the multi-platform platform is 
> needed.
> It is almost like  cygwin on windows, but that requires a different 
> cmake.
> We could have an environment variable, but I really hate them...

It is a little uglier with cygwin since that can qualify as a 
completely different environment. X11 on MacOS X isn't the same since 
it can be considered part of the OS. I find that having a simple CMake 
option that I can toggle whether I want to use X11 or not works pretty 
well. This still requires the user to do something extra, but I think 
that's a lot better than resorting to environment variables. It's 
cleaner than digging into CMakeCache.txt too.

> Any ideas on how to best do this are welcome...

A while ago there was some mention of future support for 
multiple-choice OPTIONs. Rather than setting USE_CARBON, USE_COCOA, and 
USE_X11 variables exclusively, it would be great to have just a single 
option that can only be set to one of a specific set of values. Any 
CMake modules that require drawing into a GUI could then reference some 
kind of WINDOW_GUI variable. Available values could be X11, Win32, 
Carbon, or Cocoa. This would make it easy for modules to check the 
current build type. FindTclTk could thus make sure that Carbon is being 
used rather than Cocoa. Cygwin builds could check whether to use X11 or 
mingw.

In summary, I think that the flexibility available on current systems 
makes it reasonable to separate the choice of windowing API from the 
platform since several platforms can target multiple APIs. CMake and 
any modules could then follow a uniform process for checking the 
current target's windowing system.

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/>