CMakeLists: indent spaces -> tabs

The vast majority of lines are indented with tabs, convert the stragglers
so they don't stand out.

Also, move the final closing ')' of link_libraries to align with
the command, not the arguments.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
CMakeLists: do not unconditionally find OpenGL package

The OpenGL package provides libGL and (Desktop) OpenGL header files.
libGL actually provides two interfaces:
  GLX "window system layer" (as defined by glproto)
  Desktop GL "GL Context API"

For environments that do not use either GLX nor Desktop GL, there is no
reason to look for this package.  In fact, if OpenGL is not found, the
following cmake variables get set to "NOTFOUND":
  OPENGL_INCLUDE_DIR
  OPENGL_gl_LIBRARY

OPENGL_INCLUDE_DIR as NOTFOUND is a problem when building EGL tests and
the piglitutil_gles* libraries, since OPENGL_INCLUDE_DIR is the common
UTIL_GL_INCLUDES, which is in the list of included directories.  It would
be better if it just wasn't defined at all.

Similarly, OPENGL_gl_LIBRARY is linked to the egl_khr_create_context tests
to enable them to use EGL to create a Desktop GL context.  Again, if there
is no Desktop GL, it would probably be better to just not define it at all.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
CMakeLists: only find GLEXT paths if OpenGL is also found

If there is no OpenGL, there won't be OpenGL extensions either, so don't
look for them.  It is better to just leave GLEXT_INCLUDE_DIR undefined,
so it can be safely added to the list of include directories used for
building tests and utils that can be built either with or without Desktop
GL.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
CMakeLists: only set HAS_X11 if X11_FOUND

It should be possible to have a Linux system without X11.  In fact we
even probe to detect X11.  Let's use the result to initialize HAS_X11.

This patch looks right to me, and works on my X11 Linux systesm.  But, I
don't have a system to test either non-Linux nor Linux-without-X11.

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

This patch also sets the default value of PIGLIT_BUILD_GLX_TESTS to
true only if all dependencies are found.

v1: djkurtz
v2: chadv
  - The GLX tests require the GLX protocol headers (glproto.pc). But
    GL tests that simply *use* GLX do not. So PIGLIT_HAS_GLX does not
    depend on glproto.
  - Automatically select default for PIGLIT_BUILD_GLX_TESTS.

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>