Adding glfw to Qt via cmake

Viewed 126

I am using qt6, win10, mingw.

I have dowloaded GLFW 64bit windows binary from the official site.

I know how to add it via qmake, but how could I add it via cmake.

.dll file location: linking\GLFW

.h file location: include\GLFW

I knwo that there is an integrate qt opengl, but I do not want to use that.

1 Answers

These are things which I did to make OpenGL work using CMake (This is on a Ubuntu system, it should be similar on Windows):

find_package(OpenGL REQUIRED)
find_package(GLUT REQUIRED)
find_package(Threads REQUIRED)

link_libraries(
   ${CMAKE_SOURCE_DIR}/libs/build_glfw/src/libglfw3.a
   ${CMAKE_SOURCE_DIR}/libs/glew-2.1.0/build/lib/libGLEW.a
   ${OPENGL_LIBRARIES} 
   ${GLUT_LIBRARY}
   ${CMAKE_THREAD_LIBS_INIT}
   ${CMAKE_DL_LIBS}
)  

include_directories( 
   ${CMAKE_SOURCE_DIR}/libs/glew-2.1.0/include 
   ${CMAKE_SOURCE_DIR}/libs/glfw/include
   ${OPENGL_INCLUDE_DIRS}  
   ${GLUT_INCLUDE_DIRS}
)

This path you have to change according to your dll location:

${CMAKE_SOURCE_DIR}/libs/build_glfw/src/libglfw3.a
${CMAKE_SOURCE_DIR}/libs/glew-2.1.0/build/lib/libGLEW.a

These variables are provided by CMake:

${OPENGL_LIBRARIES}
${GLUT_LIBRARY}
${CMAKE_THREAD_LIBS_INIT}
${CMAKE_DL_LIBS}
Related