When I try to compile my program I get this error
C:\...\CLionProjects\Radix\vendors\glew-2.1.0\src\glew.c:34:10: fatal error: GL/glew.h: No such file or directory
#include <GL/glew.h>
^~~~~~~~~~~
The error is in the library code, what am I doing wrong here?
My project structure looks like this:
Radix
|- Radix-core
|- cpp code..
|- vendors
|- CMakeLists.txt
|- glew-2.1.0
|- Other libs..
- CMakeLists.txt
CMakeLists.txt (Just glew parts)
add_subdirectory(vendors)
add_definitions(-DTW_STATIC -DTW_NO_LIB_PRAGMA -DTW_NO_DIRECT3D -DGLEW_STATIC -D_CRT_SECURE_NO_WARNINGS)
# Including GLEW
include_directories(vendors/glew-2.1.0/include)
set(ALL_LIBS opengl32 glfw GLEW_210)
target_link_libraries(Radix ${ALL_LIBS})
vendors/CMakeLists.txt (Just glew parts)
add_definitions(-DTW_STATIC -DTW_NO_LIB_PRAGMA -DTW_NO_DIRECT3D -DGLEW_STATIC -D_CRT_SECURE_NO_WARNINGS)
### GLEW ###
set(GLEW_HEADERS)
set(GLEW_SOURCE glew-2.1.0/src/glew.c)
set(GLEW_INCLUDE glew-2.1.0/include)
add_library(GLEW_210 ${GLEW_SOURCE} ${GLEW_INCLUDE})
target_link_libraries(GLEW_210 ${OPENGL_LIBRARY} ${EXTRA_LIBS})
Adding your include directory to the source files for GLEW_210 does nothing. Add it as a PUBLIC include directory instead, so the compilation of glew.c
also has access to glew headers:
target_include_directories(GLEW_210 PUBLIC glew-2.1.0/include)
This also propagates the include directory to any targets that link with GLEW_210, so you can then drop the include_directories
statement in your main CMakeLists.txt