[CMake] Re: Compiling VTK-5.0.2 with Cygwin make
smr at sumost.ca
Thu Oct 19 11:32:05 EDT 2006
This thread begins at
Quoting Steve Robbins <smr at sumost.ca>:
> I'm having the same problem as Patrick D. Emond
> [http://public.kitware.com/pipermail/vtkusers/2006-September/086953.html] in
> building VTK under cygwin.
To recap: I am building VTK 5 sources on cygwin under windows XP. The initial
build failed with link errors. Cygwin provides two different OpenGL
implementations: one that runs on top of X11 and one that doesn't.
The cause of
the link errors is that the compilation used gl.h from X11 but linked against
the non-X11 GL library.
I configured with VTK_USE_X set to OFF. However, CMake saw fit to add
-I/usr/X11R6/include to the compile command line and therefore brought
In a series of emails with helpful folks like David Cole and Brad King
I learned the following:
0. A workaround exists: after configuring, edit CMakeCache.txt to set
the OPENGL_* variables correctly, reconfigure, and build.
1. The only way to debug CMake's actions is to sprinkle MESSAGE() throughout
its input files, including those in /usr/share/cmake-2.4.3.
2. The symbol WIN32 *is* defined on cygwin, contrary to my initial
3. The file /usr/share/cmake-2.4.3/Modules/FindOpenGL.cmake has the following
Despite the existence of /usr/include/w32api/GL/gl.h, the variable
OPENGL_INCLUDE_DIR is set to /usr/X11R6/include by this code. This is
*not* an effect of CMake caching, nor have I defined the environment
What is happening is that FIND_PATH() searches an internal, hard-coded set
of paths *before* the paths specified in the arguments. This set of
paths happens to include /usr/X11R6/include, so if that directory contains
GL/gl.h, there's no way /usr/include/w32api/GL/gl.h (the correct, non-X11
header) will be found.
At this point, deep in a private email thread, the speculation became
that the internal set of include paths was in the wrong order. In fact,
however, there is no possible correct ordering if one wants to support
building with both versions of OpenGL, based on a build-time configuration
variable (VTK_USE_X). Rather, I think, the code in FindOpenGL.cmake should
resemble the following:
FIND_PATH( OPENGL_INCLUDE_DIR GL/gl.h /usr/X11R6/include NO_DEFAULT_PATH )
FIND_PATH( OPENGL_INCLUDE_DIR GL/gl.h /usr/include/w32api NO_DEFAULT_PATH )
The trouble is, of course, that FindOpenGL.cmake has no knowledge of
It's clear that there's a bug: building on cygwin should work out-of-the-box
for both settings of VTK_USE_X. It's less clear (to me) whether the
be fixed in VTK or in CMake.
More information about the CMake