title: How to include QGLVIEWER in CMAKE for Qt5
body: <p>I am setting CMAKE to include QGLViewer for a Qt5 project. However as soon as I try to compile the project CMAKE stops with the following error: </p>
  
  <p><strong>CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
  Please set them or make sure they are set and tested correctly in the CMake files:
  QGLVIEWER_LIBRARY
  linked by target "sfm" in directory /home/emanuele/sfm</strong></p>
  
  <p>QGLViewer is present on the following path: <code>usr/include/QGLViewer</code> as it is possible to see from this print screen:</p>
  
  <p><img src="https://imgur.com/MYj79HZ" alt="Print Screen of the File Path">
  <img src="https://imgur.com/MYj79HZ.png" alt="This is the file path"></p>
  
  <p>And here is how I set the path on CMAKE:</p>
  
  <p><img src="https://imgur.com/LMsC2V0" alt="CMAKE File Path">
  <img src="https://imgur.com/LMsC2V0.png" alt="This is the file path in CMAKE"></p>
  
  <p>Additionally I found <a href="https://github.com/KumarRobotics/kr_utils/blob/master/kr_cmake_modules/cmake/Modules/FindQGLViewer.cmake" rel="nofollow noreferrer">this source</a> that was helpful for understanding how to declare the lib. Also <a href="https://stackoverflow.com/questions/39369464/qglviewer-simpleviewer-example-built-with-cmake-not-running">this post</a> was useful to point me in the correct route, but still not working.</p>
  
  <p>Below the most important CMAKE part that is causing the issue:</p>
  
  <pre><code>cmake_minimum_required(VERSION 3.11)
  project(sfm)
  
  ########### options ###############
  SET(USE_QT TRUE CACHE BOOL)
  ########### END options ###########
  
  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -g")
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -g")
  set(CMAKE_INCLUDE_CURRENT_DIR ON)
  
  ########### OpenMP ################
  find_package(OpenMP)
  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
  ########### END OpenMP ############
  
  ########### OpenCV ################
  set (OpenCV_DIR /home/emanuele/opencv/build)
  find_package(OpenCV REQUIRED)
  include_directories(${OpenCV_INCLUDE_DIRS})
  list(APPEND LINK_LIBRARIES ${OpenCV_LIBS})
  ########### END OpenCV ############
  
  ########### Qt 5 ##################
  IF (USE_QT)
    ADD_DEFINITIONS("-DUSE_QT")
    find_package(Qt5Widgets REQUIRED)
    find_package(Qt5Xml REQUIRED)
    find_package(Qt5OpenGL REQUIRED)
  
    include_directories(${Qt5Widgets_INCLUDE_DIRS}
        ${Qt5Xml_INCLUDE_DIRS}
        ${Qt5OpenGL_INCLUDE_DIRS}
    )
    list(APPEND LINK_LIBRARIES Qt5::Widgets Qt5::Xml Qt5::OpenGL)
    set(CMAKE_AUTOMOC ON)
    set(CMAKE_AUTOUIC ON)
  
    include_directories(src/ui/mainwindow src/ui/widgets)
  
    find_package(OpenGL REQUIRED)
    find_library(QGLVIEWER_LIBRARY
        NAMES qglviewer-qt5 qglviewer QGLViewer QGLViewer2)
    list(APPEND LINK_LIBRARIES ${QGLVIEWER_LIBRARY}  ${OPENGL_LIBRARIES})
  ENDIF (USE_QT)
  ########### END Qt 5 ##############
  
  ########### sources ###############
  file(GLOB_RECURSE SOURCE_FILES "src/*.cpp")
  add_executable(sfm ${SOURCE_FILES})
  ########### END sources ###########
  
  ########### headers ###############
  include_directories(src)
  ########### END headers ###########
  
  ########### link libraries ########
  target_link_libraries(sfm ${LINK_LIBRARIES})
  ########### END link libraries ####
  </code></pre>
  
  <p>I expect CMAKE to compile but the actual result I have is shown in the print screen below keeping me from moving ahead:</p>
  
  <p><img src="https://imgur.com/uqXKEEg" alt="Print Screen of the Error">
  <img src="https://imgur.com/uqXKEEg.png" alt="This is the file path"></p>