diff options
author | Brad King <brad.king@kitware.com> | 2017-11-20 14:42:07 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2017-11-20 14:43:27 (GMT) |
commit | 9100ea1d82538b300145d589ca4961ff2050ac4d (patch) | |
tree | 14b1f1a11d4b8a89777b2d63b2a56d96a2a250c6 /Modules | |
parent | b0c2cd47f0b62f3586e3f45ed554357ac27dd576 (diff) | |
parent | 2ea17412a9a40bd66342a1761ac8f067f5d2ab09 (diff) | |
download | CMake-9100ea1d82538b300145d589ca4961ff2050ac4d.zip CMake-9100ea1d82538b300145d589ca4961ff2050ac4d.tar.gz CMake-9100ea1d82538b300145d589ca4961ff2050ac4d.tar.bz2 |
Merge topic 'FindOpenGL-glvnd-policy'
2ea17412 FindOpenGL: Add policy CMP0072 to prefer GLVND for legacy GL
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Clinton Stimpson <clinton@elemtech.com>
Merge-request: !1491
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/FindOpenGL.cmake | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/Modules/FindOpenGL.cmake b/Modules/FindOpenGL.cmake index 9063492..91db5af 100644 --- a/Modules/FindOpenGL.cmake +++ b/Modules/FindOpenGL.cmake @@ -99,11 +99,13 @@ # If the GLVND OpenGL and GLX libraries are available, prefer them. # This forces ``OPENGL_gl_LIBRARY`` to be empty. # This is the default if components were requested (since components -# correspond to GLVND libraries). +# correspond to GLVND libraries) or if policy :policy:`CMP0072` is +# set to ``NEW``. # # ``LEGACY`` # Prefer to use the legacy libGL library, if available. -# This is the default if no components were requested. +# This is the default if no components were requested and +# policy :policy:`CMP0072` is not set to ``NEW``. # # For EGL targets the client must rely on GLVND support on the user's system. # Linking should use the ``OpenGL::OpenGL OpenGL::EGL`` targets. Using GLES* @@ -220,6 +222,7 @@ else() /usr/shlib /usr/X11R6/lib ) + set(_OpenGL_GL_POLICY_WARN 0) if(NOT DEFINED OpenGL_GL_PREFERENCE) set(OpenGL_GL_PREFERENCE "") endif() @@ -237,8 +240,17 @@ else() set(OpenGL_GL_PREFERENCE "GLVND") else() # No preference was explicitly specified and no GLVND components were - # requested. Prefer libGL for legacy GL. - set(OpenGL_GL_PREFERENCE "LEGACY") + # requested. Use a policy to choose the default. + cmake_policy(GET CMP0072 _OpenGL_GL_POLICY) + if("x${_OpenGL_GL_POLICY}x" STREQUAL "xNEWx") + set(OpenGL_GL_PREFERENCE "GLVND") + else() + set(OpenGL_GL_PREFERENCE "LEGACY") + if("x${_OpenGL_GL_POLICY}x" STREQUAL "xx") + set(_OpenGL_GL_POLICY_WARN 1) + endif() + endif() + unset(_OpenGL_GL_POLICY) endif() if("x${OpenGL_GL_PREFERENCE}x" STREQUAL "xGLVNDx" AND OPENGL_opengl_LIBRARY AND OPENGL_glx_LIBRARY) @@ -257,6 +269,23 @@ else() ) endif() + if(_OpenGL_GL_POLICY_WARN AND OPENGL_gl_LIBRARY AND OPENGL_opengl_LIBRARY AND OPENGL_glx_LIBRARY) + message(AUTHOR_WARNING + "Policy CMP0072 is not set: FindOpenGL prefers GLVND by default when available. " + "Run \"cmake --help-policy CMP0072\" for policy details. " + "Use the cmake_policy command to set the policy and suppress this warning." + "\n" + "FindOpenGL found both a legacy GL library:\n" + " OPENGL_gl_LIBRARY: ${OPENGL_gl_LIBRARY}\n" + "and GLVND libraries for OpenGL and GLX:\n" + " OPENGL_opengl_LIBRARY: ${OPENGL_opengl_LIBRARY}\n" + " OPENGL_glx_LIBRARY: ${OPENGL_glx_LIBRARY}\n" + "OpenGL_GL_PREFERENCE has not been set to \"GLVND\" or \"LEGACY\", so for " + "compatibility with CMake 3.10 and below the legacy GL library will be used." + ) + endif() + unset(_OpenGL_GL_POLICY_WARN) + # FPHSA cannot handle "this OR that is required", so we conditionally set what # it must look for. First clear any previous config we might have done: set(_OpenGL_REQUIRED_VARS) |