In fact, you did not associate OpenGL with your project, so you get undefined links to OpenGL functions. Try replacing
target_link_libraries(texture_mapping libfreeglut.a libfreeglut_static.a)
with
target_link_libraries(texture_mapping libfreeglut.a libfreeglut_static.a GL)
I reproduced your problem using CMakeLists.txt and the following program:
#include <GL/gl.h> int main() { glClear(GL_COLOR_BUFFER_BIT); return 0; }
and decided it with a replacement above. The solution automatically links the GL library from my library path:
$ ls -1 /usr/lib64/libGL.* /usr/lib64/libGL.la /usr/lib64/libGL.so /usr/lib64/libGL.so.1 /usr/lib64/libGL.so.1.0.0
UPDATE
According to this , you have some variables to access your actual OpenGL libraries. For example, you can specify the files (files) of the OpenGL library as follows:
target_link_libraries(texture_mapping libfreeglut.a libfreeglut_static.a ${OPENGL_gl_LIBRARY})
You can also add the OpenGL library directory to the search path (do this before target_link_libraries ):
link_directories(${OPENGL_gl_LIBRARY})
source share