cmake: Fix libpiglitutil on systems without X11

If there's no X11, then don't link to libX11.

Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
egl_khr_create_context: Fix X11 and GL requirements in CMake

Fixes the build on systems without X11 or without libGL.

The EGL_KHR_create_context tests use XOpenDisplay() to create the
EGLDisplay. So don't build the tests unless PIGLIT_HAS_X11.

The tests use GLES2. So stop linking to libGLES1 and libGL. Also
don't link to libGLES2, because it's better to transitively get libGLES2
through libpiglitutil_gles2.

Stop adding misc GL header directories to the include path. The tests
don't use them but instead use piglit-dispatch.

CC: Daniel Kurtz <djkurtz@chromium.org>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
CMakeLists: Only set HAS_GBM if pkgconfig finds gbm

[chadv] Tested on systems with and without GBM.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
CMakeLists: GLX is not always present on Linux (v2)

Believe it or not, it is possible to have Linux without GLX.

This patch sets PIGLIT_HAS_GLX on Linux only if X11 and libGL is found.
Otherwise, an EGL-only Linux system would fail to build
piglit_x11_framework, since it could not find <GL/glx.h>.

v1: djkurtz
v2: chadv
    - The GLX protocol headers (glproto.pc) are required to build the
      GLX tests but are not required to build OpenGL tests that use
      simply use (rather than test) GLX.  So remove dependency of
      PIGLIT_HAS_GLX on glproto.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
cmake: Set PIGLIT_HAS_WAYLAND only if Wayland is present

Require wayland-client and wayland-egl in pkgconfig.

Reported-by: Daniel Kurtz <djkurtz@chromium.org>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
piglit-dispatch: only use glXGetProcAddressARB if PIGLIT_HAS_GLX

If there is no GLX, then there is no glXGetProcAddressARB to call and the
library can't link.

Returning NULL for the proc address might cause some tests to crash,
but shouldn't they be using waffle or eglGetProcAddress anyway for EGL
dispatch?

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
piglit-dispatch: Use eglGetProcAddress if PIGLIT_HAS_EGL but not GLX (v2)

If EGL is defined, we could use the eglGetProcAddress to lookup extension
proc addresses.

Note, however, that eglGetProcAddress may not work for core procs,
unless the driver also supports EGL_KHR_get_all_proc_addresses. For core
procs, eglGetProcAddress may return NULL which will cause the process to
crash.

With Mesa, tough, eglGetProcAddress *does* work for core procs.  Mesa
effectively supports EGL_KHR_get_all_proc_addresses even though it
doesn't yet advertise the extension string).

v2: chadv
  - Expand commit message to explain that this patch is safe for Mesa.
    It will not cause EGL tests to crash.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>