[CMake] Issue with check_include_file() and GL/glxproto.h
GOUJON Alexandre
ale.goujon at gmail.com
Thu Nov 10 16:49:44 EST 2011
Hi,
It all started when I tried compiling Piglit [1] : cmake checked all the
dependencies, didn't complain and generated Makefiles but doing 'make'
caused an error because a header was missing.
So I proposed myself to write a patch and add the check.
But the following didn't work :
check_include_file(GL/glxproto.h HAVE_GL_GLXPROTO_H)
if (NOT HAVE_GL_GLXPROTO_H)
message(FATAL_ERROR "GL/glxproto.h required. On Ubuntu, you need
the x11proto-gl-dev package.")
endif (NOT HAVE_GL_GLXPROTO_H)
I modified CheckIncludeFile.cmake to see what happened :
$ diff ~/Downloads/CheckIncludeFile.cmake
/usr/share/cmake-2.8/Modules/CheckIncludeFile.cmake
32c32
< IF("${VARIABLE}" MATCHES "^${VARIABLE}$")
---
> # IF("${VARIABLE}" MATCHES "^${VARIABLE}$")
74a75
> message(STATUS "output::${OUTPUT}")
76c77
< ENDIF("${VARIABLE}" MATCHES "^${VARIABLE}$")
---
> # ENDIF("${VARIABLE}" MATCHES "^${VARIABLE}$")
My debugging output :
-- Looking for GL/glxproto.h
-- Looking for GL/glxproto.h - not found
-- output::Change Dir: /home/alex/Projects/piglit/CMakeFiles/CMakeTmp
Run Build Command:/usr/bin/make "cmTryCompileExec/fast"
/usr/bin/make -f CMakeFiles/cmTryCompileExec.dir/build.make
CMakeFiles/cmTryCompileExec.dir/build
make[1]: Entering directory `/home/alex/Projects/piglit/CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report
/home/alex/Projects/piglit/CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object CMakeFiles/cmTryCompileExec.dir/CheckIncludeFile.c.o
/usr/bin/gcc -Wall -o
CMakeFiles/cmTryCompileExec.dir/CheckIncludeFile.c.o -c
/home/alex/Projects/piglit/CMakeFiles/CMakeTmp/CheckIncludeFile.c
In file included from
/home/alex/Projects/piglit/CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:0:
/usr/include/GL/glxproto.h:103:16: error: expected ‘=’, ‘,’, ‘;’, ‘asm’
or ‘__attribute__’ before ‘GLXContextTag’
/usr/include/GL/glxproto.h:128:5: error: expected
specifier-qualifier-list before ‘CARD8’
[<snip>]
/usr/include/GL/glxproto.h:563:5: error: expected
specifier-qualifier-list before ‘BYTE’
[<snip>]
/usr/include/GL/glxproto.h:1416:5: error: expected
specifier-qualifier-list before ‘CARD16’
/usr/include/GL/glxproto.h:1426:5: error: expected
specifier-qualifier-list before ‘CARD32’
/usr/include/GL/glxproto.h:1448:5: error: expected
specifier-qualifier-list before ‘BOOL’
[<snip>]
make[1]: *** [CMakeFiles/cmTryCompileExec.dir/CheckIncludeFile.c.o] Error 1
make[1]: Leaving directory `/home/alex/Projects/piglit/CMakeFiles/CMakeTmp'
make: *** [cmTryCompileExec/fast] Error 2
CMake Error at CMakeLists.txt:117 (message):
GL/glxproto.h required. On Ubuntu, you need the x11proto-gl-dev package.
I'm not really familiar with CMake so I may have missed something.
What I understand is that check_include_file() tries to compile a test
which includes GL/glxproto.h.
It seems another header is needed prior to using GL/glxproto.h.
From my "user" point of view, this approach is quite strange because
the header is present but "not found".
If you want to check the usability of the file, I think a comment or a
better macro name would help.
And, could you add a check like
IF(${VARIABLE}) message(FATAL_ERROR "${VARIABLE} already defined :
aborting") ENDIF(${VARIABLE})
?
That is, explicitly abort the macro instead of letting the user testing
a variable previously defined and not modified by check_include_file.
IF("${VARIABLE}" MATCHES "^${VARIABLE}$") fails : is it intended ?
Thanks in advance.
---
[1] : http://lists.freedesktop.org/archives/piglit/2011-October/001134.html
More information about the CMake
mailing list