cmake: don't fail, on Linux, if X11 is not found

Submitted by Mircea Gherzan on April 20, 2016, 4:23 p.m.

Details

Message ID 78fa0ec8-6bf1-7720-b18d-4ef0646a12f2@intel.com
State New
Headers show
Series "cmake: don't fail, on Linux, if X11 is not found" ( rev: 1 ) in Piglit

Not browsing as part of any series.

Commit Message

Mircea Gherzan April 20, 2016, 4:23 p.m.
On 16-Feb-16 9:12 PM, Dylan Baker wrote:
> Quoting Mircea Gherzan (2016-02-16 10:54:30)
>> If X11 is not found then GLX cannot be available, so just disable the
>> building of the OpenGL test instead of hardcoding libGL/GLX as a build
>> requirement. GLES tests are on by default on Linux, so the build still
>> makes sense.
>>
>> Signed-off-by: Mircea Gherzan <mircea.gherzan@intel.com>
>> ---
>>  CMakeLists.txt | 4 ++++
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/CMakeLists.txt b/CMakeLists.txt
>> index 736677f..902ca3e 100644
>> --- a/CMakeLists.txt
>> +++ b/CMakeLists.txt
>> @@ -45,6 +45,10 @@ option(PIGLIT_BUILD_GLES2_TESTS "Build tests for OpenGL ES2" ${PIGLIT_BUILD_GLES
>>  option(PIGLIT_BUILD_GLES3_TESTS "Build tests for OpenGL ES3" ${PIGLIT_BUILD_GLES_TESTS_DEFAULT})
>>  option(PIGLIT_BUILD_CL_TESTS "Build tests for OpenCL" OFF)
>>
>> +if((NOT X11_FOUND) AND (CMAKE_SYSTEM_NAME STREQUAL "Linux"))
>> +       set(PIGLIT_BUILD_GL_TESTS OFF)
>> +endif()
>> +
>>  if(PIGLIT_BUILD_GL_TESTS)
>>         find_package(OpenGL REQUIRED)
>>  endif()
>> --
>> 2.5.0
>>
>
> NAK. This is throwing the baby out with the bath water. We absolutely
> don't need to have X11 to run piglit tests.
>
> The only things that rely on X11 directly are glean (which are going
> away) and the EGL tests, everything else uses waffle to handle this.
> It's trivial extend the guard around glean and add one around EGL in
> tests/CMakeLists.txt.

Then can you please suggest another approach for allowing piglit to 
build on a system with no X11 or GLX headers?

Right now, on such a system, I get:

CMake Error at 
/usr/share/cmake-3.2/Modules/FindPackageHandleStandardArgs.cmake:138 
(message):
   Could NOT find OpenGL (missing: OPENGL_gl_LIBRARY OPENGL_INCLUDE_DIR)
Call Stack (most recent call first):
   /usr/share/cmake-3.2/Modules/FindPackageHandleStandardArgs.cmake:374 
(_FPHSA_FAILURE_MESSAGE)
   /usr/share/cmake-3.2/Modules/FindOpenGL.cmake:168 
(FIND_PACKAGE_HANDLE_STANDARD_ARGS)
   CMakeLists.txt:49 (find_package)

What about the following approach?



Thanks.

Patch hide | download patch | download mbox

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8e2abba..efb03a8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -39,15 +39,17 @@  else()
         set(PIGLIT_BUILD_GLES_TESTS_DEFAULT OFF)
  endif()

-option(PIGLIT_BUILD_GL_TESTS "Build tests for OpenGL" ON)
  option(PIGLIT_BUILD_GLES1_TESTS "Build tests for OpenGL ES1" 
${PIGLIT_BUILD_GLES_TESTS_DEFAULT})
  option(PIGLIT_BUILD_GLES2_TESTS "Build tests for OpenGL ES2" 
${PIGLIT_BUILD_GLES_TESTS_DEFAULT})
  option(PIGLIT_BUILD_GLES3_TESTS "Build tests for OpenGL ES3" 
${PIGLIT_BUILD_GLES_TESTS_DEFAULT})
  option(PIGLIT_BUILD_CL_TESTS "Build tests for OpenCL" OFF)

-if(PIGLIT_BUILD_GL_TESTS)
-       find_package(OpenGL REQUIRED)
-endif()
+find_package(OpenGL)
+if (OpenGL_FOUND)
+       option(PIGLIT_BUILD_GL_TESTS "Build tests for OpenGL" ON)
+else ()
+       option(PIGLIT_BUILD_GL_TESTS "Build tests for OpenGL" OFF)
+endif ()

Comments

Quoting Mircea Gherzan (2016-04-20 09:23:00)
> On 16-Feb-16 9:12 PM, Dylan Baker wrote:
> > Quoting Mircea Gherzan (2016-02-16 10:54:30)
> >> If X11 is not found then GLX cannot be available, so just disable the
> >> building of the OpenGL test instead of hardcoding libGL/GLX as a build
> >> requirement. GLES tests are on by default on Linux, so the build still
> >> makes sense.
> >>
> >> Signed-off-by: Mircea Gherzan <mircea.gherzan@intel.com>
> >> ---
> >>  CMakeLists.txt | 4 ++++
> >>  1 file changed, 4 insertions(+)
> >>
> >> diff --git a/CMakeLists.txt b/CMakeLists.txt
> >> index 736677f..902ca3e 100644
> >> --- a/CMakeLists.txt
> >> +++ b/CMakeLists.txt
> >> @@ -45,6 +45,10 @@ option(PIGLIT_BUILD_GLES2_TESTS "Build tests for OpenGL ES2" ${PIGLIT_BUILD_GLES
> >>  option(PIGLIT_BUILD_GLES3_TESTS "Build tests for OpenGL ES3" ${PIGLIT_BUILD_GLES_TESTS_DEFAULT})
> >>  option(PIGLIT_BUILD_CL_TESTS "Build tests for OpenCL" OFF)
> >>
> >> +if((NOT X11_FOUND) AND (CMAKE_SYSTEM_NAME STREQUAL "Linux"))
> >> +       set(PIGLIT_BUILD_GL_TESTS OFF)
> >> +endif()
> >> +
> >>  if(PIGLIT_BUILD_GL_TESTS)
> >>         find_package(OpenGL REQUIRED)
> >>  endif()
> >> --
> >> 2.5.0
> >>
> >
> > NAK. This is throwing the baby out with the bath water. We absolutely
> > don't need to have X11 to run piglit tests.
> >
> > The only things that rely on X11 directly are glean (which are going
> > away) and the EGL tests, everything else uses waffle to handle this.
> > It's trivial extend the guard around glean and add one around EGL in
> > tests/CMakeLists.txt.
> 
> Then can you please suggest another approach for allowing piglit to 
> build on a system with no X11 or GLX headers?
> 
> Right now, on such a system, I get:
> 
> CMake Error at 
> /usr/share/cmake-3.2/Modules/FindPackageHandleStandardArgs.cmake:138 
> (message):
>    Could NOT find OpenGL (missing: OPENGL_gl_LIBRARY OPENGL_INCLUDE_DIR)
> Call Stack (most recent call first):
>    /usr/share/cmake-3.2/Modules/FindPackageHandleStandardArgs.cmake:374 
> (_FPHSA_FAILURE_MESSAGE)
>    /usr/share/cmake-3.2/Modules/FindOpenGL.cmake:168 
> (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
>    CMakeLists.txt:49 (find_package)

Whoa, hold up. That's not GLX you're missing, that's OpenGL you're
missing. That's two completely different problems.

Are you trying to run piglit on a system with only GLES or with desktop
OpenGL but no X11 (or at least GLX)?

In the short term you could pass -DPIGLIT_BUILD_GL_TESTS=0 to cmake right?

> 
> What about the following approach?
> 
> diff --git a/CMakeLists.txt b/CMakeLists.txt
> index 8e2abba..efb03a8 100644
> --- a/CMakeLists.txt
> +++ b/CMakeLists.txt
> @@ -39,15 +39,17 @@ else()
>          set(PIGLIT_BUILD_GLES_TESTS_DEFAULT OFF)
>   endif()
> 
> -option(PIGLIT_BUILD_GL_TESTS "Build tests for OpenGL" ON)
>   option(PIGLIT_BUILD_GLES1_TESTS "Build tests for OpenGL ES1" 
> ${PIGLIT_BUILD_GLES_TESTS_DEFAULT})
>   option(PIGLIT_BUILD_GLES2_TESTS "Build tests for OpenGL ES2" 
> ${PIGLIT_BUILD_GLES_TESTS_DEFAULT})
>   option(PIGLIT_BUILD_GLES3_TESTS "Build tests for OpenGL ES3" 
> ${PIGLIT_BUILD_GLES_TESTS_DEFAULT})
>   option(PIGLIT_BUILD_CL_TESTS "Build tests for OpenCL" OFF)
> 
> -if(PIGLIT_BUILD_GL_TESTS)
> -       find_package(OpenGL REQUIRED)
> -endif()
> +find_package(OpenGL)
> +if (OpenGL_FOUND)
> +       option(PIGLIT_BUILD_GL_TESTS "Build tests for OpenGL" ON)
> +else ()
> +       option(PIGLIT_BUILD_GL_TESTS "Build tests for OpenGL" OFF)
> +endif ()
> 
> 
> Thanks.
> 
> -- 
> - Mircea
On 20-Apr-16 7:58 PM, Dylan Baker wrote:
> Quoting Mircea Gherzan (2016-04-20 09:23:00)
>>
>> Then can you please suggest another approach for allowing piglit to
>> build on a system with no X11 or GLX headers?
>>
>> Right now, on such a system, I get:
>>
>> CMake Error at
>> /usr/share/cmake-3.2/Modules/FindPackageHandleStandardArgs.cmake:138
>> (message):
>>    Could NOT find OpenGL (missing: OPENGL_gl_LIBRARY OPENGL_INCLUDE_DIR)
>> Call Stack (most recent call first):
>>    /usr/share/cmake-3.2/Modules/FindPackageHandleStandardArgs.cmake:374
>> (_FPHSA_FAILURE_MESSAGE)
>>    /usr/share/cmake-3.2/Modules/FindOpenGL.cmake:168
>> (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
>>    CMakeLists.txt:49 (find_package)
>
> Whoa, hold up. That's not GLX you're missing, that's OpenGL you're
> missing. That's two completely different problems.
>
> Are you trying to run piglit on a system with only GLES or with desktop
> OpenGL but no X11 (or at least GLX)?

I've built Mesa with --disable-glx so there's no libGL.so. I do have the 
Mesa <install_dir>/lib/pkgconfig to PKG_CONFIG_PATH and the cmake still 
fails with "Could NOT find OpenGL".

> In the short term you could pass -DPIGLIT_BUILD_GL_TESTS=0 to cmake right?

Tried it but I fails with:

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:
OPENGL_gl_LIBRARY