Closed Tloe closed 5 years ago
At first glance I agree that fixing cmake to use ${X11_INCLUDE_DIR}
is the way to go.
The logic for find_package(X11)
probably ought to ignore BUILD_UTILS
too.
On Linux it appears that -lX11
linking is transitive via OpenGL:
cc -DGLEW_NO_GLU -DGLEW_BUILD -O2 -Wall -W -Iinclude -fPIC -Wcast-qual -ansi -pedantic -fno-stack-protector -o tmp/linux/default/shared/glew.o -c src/glew.c
cc -shared -Wl,-soname=libGLEW.so.2.2 -o lib/libGLEW.so.2.2.0 tmp/linux/default/shared/glew.o -L/usr/X11R6/lib64 -L/usr/lib64 -lGL -lX11
Oh, I stand corrected.
The Linux cmake build is linking -lX11
(and others) for the tools, but not the shared library target:
[ 50%] Linking C shared library lib/libGLEW.so
/usr/bin/cmake -E cmake_link_script CMakeFiles/glew.dir/link.txt --verbose=1
/usr/bin/cc -fPIC -O3 -DNDEBUG -shared -Wl,-soname,libGLEW.so.2.2 -o lib/libGLEW.so.2.2.0 CMakeFiles/glew.dir/home/nigels/dev/glew/src/glew.c.o -lGL -lGLU
...
[ 75%] Linking C executable bin/glewinfo
/usr/bin/cmake -E cmake_link_script CMakeFiles/glewinfo.dir/link.txt --verbose=1
/usr/bin/cc -O3 -DNDEBUG -rdynamic CMakeFiles/glewinfo.dir/home/nigels/dev/glew/src/glewinfo.c.o -o bin/glewinfo -Wl,-rpath,/home/nigels/dev/glew/build/cmake/lib: lib/libGLEW.so.2.2.0 -lSM -lICE -lX11 -lXext -lGL -lGLU
Generally speaking I accept cmake patches, but I tend not to use or test cmake since it is in addition to the traditional Makefile build that is more maintainer-oriented.
Hmm.. I tried using the Makefile directly too and get the include error there as well, but it seems to be another issue.
➜ glew-2.1.0 gmake
cc -DGLEW_NO_GLU -DGLEW_BUILD -O2 -Wall -W -Iinclude -I/usr/X11R6/include -fPIC -o tmp/freebsd/default/shared/glew.o -c src/glew.c
In file included from src/glew.c:55:
include/GL/glxew.h:98:10: fatal error: 'X11/Xlib.h' file not found
#include <X11/Xlib.h>
^~~~~~~~~~~~
1 error generated.
gmake: *** [Makefile:137: tmp/freebsd/default/shared/glew.o] Error 1
➜ glew-2.1.0
The /usr/X11r6/include folder doesn't exist on FreeBSD.. The X11 files are in /usr/local/include/X11 so this line works:
cc -DGLEW_NO_GLU -DGLEW_BUILD -O2 -Wall -W -Iinclude -I/usr/local/include -fPIC -o tmp/freebsd/default/shared/glew.o -c src/glew.c
I pushed a git branch that seems to be building fine for FreeBSD12 (in a virtual box) https://github.com/nigels-com/glew/tree/freebsd
Hum.. do I need to run some script to get the files in src and include/ when checking out the github repo? What am I missing.. can't find any info on that in the README.md
gmake -C auto
ought to do it.
Getting an error.. From google search it seems like it would be better to have #!/bin/sh instead of bash.
Freebsd has bash, but not in /bin/bash
rm -rf extensions/gl
cp -r glfixes/gl/specs/ANGLE OpenGL-Registry/extensions
cp -r glfixes/gl/specs/REGAL OpenGL-Registry/extensions
bin/update_ext.sh extensions/gl OpenGL-Registry/extensions blacklist
bash: bin/update_ext.sh: /bin/bash: bad interpreter: No such file or directory
gmake: *** [Makefile:108: extensions/gl/.dummy] Error 126
gmake: Leaving directory '/usr/home/T/coding/glew/auto'
This ought to be fixed in the FreeBSD branch I pushed: freebsd (not yet merged) PR: https://github.com/nigels-com/glew/pull/212
There is a Travis build available here also, that ought to work for FreeBSD https://glew.s3.amazonaws.com/nigels-com/glew/293/293.1/glew-2.2.0.tgz
Been traveling to the other side of the planet so been offline for a bit :)
Thought I had checked out the freebsd branch.. my git/github is a bit rusty.. Checked out the freebsd branch now and it builds with no errors. Also tried the Travis build and it works as well
Perfect :)
Great, thanks for the confirmation.
Thanks for fixing it :)
I'm trying to build glew-2.1.0 on FreeBSD.
I can fix this by changing line 142 in CMakeLists.txt to: target_include_directories(${t} PUBLIC $ ${X11_INCLUDE_DIR})
And add a find_package(X11) just before that.
But as I am using conan.io for my dependencies I would love to see a more permanent fix for this. And I am not sure if this is the correct fix? It seems like the glew and glew_s target isn't supposed to include the X11 files?