[Cmake] IF logic (was: Multiple OPTION choices)

Chris Scharver scharver at evl.uic.edu
Wed Apr 23 14:46:02 EDT 2003


At 1:40 PM -0400 04/23/2003, Andy Cedilnik wrote:
>This is a good idea and I added it to the list for CMake 1.8. We also
>have some idea on how to do it, but it depends on some other features of
>1.8 that we are discussing.

Great!

I think I may have found another issue with how the IF command handles the defines passed to it as arguments. I've been trying to rearrange FindOpenGL.cmake to more cleanly handle whether or not to use X11 on MacOS X. I have it working, but there's a bit of a kludge. The logic should work something like this:

IF (USE_APPLE_X11 OR (NOT APPLE))

However, this creates an error with the number of arguments (I tried several different combinations.) The documentation states that (def1 OR def2) can be used. Neither of those appear to be something that can be evaluated like above. The kludge I have is to set a NOT_APPLE variable:

IF (APPLE)
  OPTION(USE_APPLE_X11 OFF "Use X11 on OSX?")
  IF (USE_APPLE_X11)
    ... stuff to locate the OpenGL framework--a whole other discussion ;) ...
  ENDIF (USE_APPLE_X11)
ELSE (APPLE)
  SET (NOT_APPLE ON)
ENDIF (APPLE)

IF (USE_APPLE_X11 OR NOT_APPLE)
  ... do the normal Mesa/OpenGL X11 searches ...
ENDIF (USE_APPLE_X11 OR NOT_APPLE)

It's ugly, but it's a little cleaner from the CMake GUI because the use of X11 can be toggled easily. This approach prevents accidentally picking up X11 headers when the native headers should be used. If requested, it will grab the X11 headers on OS X. I have to give it some more testing, but let me know if it would be worthwhile to pass along.

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



More information about the CMake mailing list