Perlmint / glew-cmake

GLEW(https://github.com/nigels-com/glew, source updated nightly) with Cmake and pre-generated sources
Other
234 stars 95 forks source link

Error including OpenGL/X11 libraries on CMake when USE_NAMESPACED_LIB not defined #40

Closed rilpires closed 3 years ago

rilpires commented 3 years ago

When building on my older laptop (Ubuntu 18.04, cmake version 3.10.2, master branch), I got an error when linking my executable target:

[build] /usr/bin/ld: não foi possível localizar -lOPENGL_opengl_LIBRARY
[build] /usr/bin/ld: não foi possível localizar -lX11_X11_LIB
[build] /usr/bin/ld: não foi possível localizar -lX11_Xext_LIB

It is saying it can't find these libraries. I found out that was because these libraries are added as:

list(APPEND LIBRARIES OPENGL_opengl_LIBRARY)
list(APPEND LIBRARIES X11_X11_LIB X11_Xext_LIB)

Now, I only have being learning cmake recently, but I think these variables should be evaluated with ${}, since they aren't targets, am I right? I got it working correctly after changing them to:

list(APPEND LIBRARIES ${OPENGL_opengl_LIBRARY} )
list(APPEND LIBRARIES ${X11_X11_LIB} ${X11_Xext_LIB} )
Perlmint commented 3 years ago

I'm sorry I didn't test with old cmake. You're right, old - non-namespaced find package/library results are not a target; they are just string variables.

I created PR fixing this. It'll work with cmake 3.10. If you don't mind can you test it works?

rilpires commented 3 years ago

Running perfectly. Also, I don't get exactly what is about this GLVND thing to link libOpenGL or libGL, but it was another change I had to make that was solved in this commit too (was linking libOpenGL, only worked if was libGL)