#    GL/glew.h X11/Xlib.h X11/Xutil.h GL/gl.h GL/glx.h
IF(WIN32)
  SET(GL_INCLUDE_DIR "")
ELSEIF(NOT APPLE)
  FIND_PATH(GL_INCLUDE_DIR
    NAMES
      GL/gl.h
    PATHS
      /usr/include
  )
ENDIF(WIN32)

IF(USE_SYSTEM_GLEW)
  FIND_PATH(GLEW_INCLUDE_DIR
    NAMES
      GL/glew.h
    PATHS
      src/3rdparty/glew-1.10.0/include
  )
ELSE(USE_SYSTEM_GLEW)
  SET(GLEW_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/3rdparty/glew-1.10.0/include")
ENDIF(USE_SYSTEM_GLEW)

IF(WIN32)
  SET(GL_LIBRARIES Opengl32)
ELSEIF(APPLE)
  FIND_LIBRARY(GL_LIBRARIES OpenGL)
ELSEIF(UNIX)
  FIND_LIBRARY(GL_LIBRARY GL)
  FIND_LIBRARY(X11_LIBRARY X11)
  IF(GL_LIBRARY AND X11_LIBRARY)
    SET(GL_LIBRARIES ${GL_LIBRARY} ${X11_LIBRARY})
  ENDIF(GL_LIBRARY AND X11_LIBRARY)
ENDIF(WIN32)

SET(GL_FOUND FALSE)
IF(WIN32 OR (GL_LIBRARIES AND GL_INCLUDE_DIR AND GLEW_INCLUDE_DIR))
  SET(GL_FOUND TRUE)
  SET(GL_INCLUDE_DIRS ${GL_INCLUDE_DIR} ${GLEW_INCLUDE_DIR})
ENDIF(WIN32 OR (GL_LIBRARIES AND GL_INCLUDE_DIR AND GLEW_INCLUDE_DIR))

IF(NOT GL_FOUND)
   MESSAGE(STATUS "OpenGL libraries not found")
ENDIF(NOT GL_FOUND)
