From 254a4703469488f76450e2fb5f8445e202aeeabe Mon Sep 17 00:00:00 2001 From: Elias Daler Date: Tue, 14 Aug 2018 00:06:31 +0300 Subject: [PATCH] Fix CMP0072 CMake warning - also allow user to set OpenGL_GL_PREFERENCE --- src/SFML/Window/CMakeLists.txt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/SFML/Window/CMakeLists.txt b/src/SFML/Window/CMakeLists.txt index 916c1dcdd..1fe8b5a43 100644 --- a/src/SFML/Window/CMakeLists.txt +++ b/src/SFML/Window/CMakeLists.txt @@ -235,6 +235,13 @@ if(SFML_OS_LINUX OR SFML_OS_FREEBSD OR SFML_OPENBSD) target_link_libraries(sfml-window PRIVATE X11) endif() +# CMake 3.11 and later prefer to choose GLVND, but we choose legacy OpenGL for backward compability +# (unless the OpenGL_GL_PREFERENCE was explicitly set) +# See CMP0072 for more details (cmake --help-policy CMP0072) +if ((NOT ${CMAKE_VERSION} VERSION_LESS 3.11) AND (NOT OpenGL_GL_PREFERENCE)) + set(OpenGL_GL_PREFERENCE "LEGACY") +endif() + if(SFML_OPENGL_ES) if(SFML_OS_IOS) target_link_libraries(sfml-window PRIVATE "-framework OpenGLES") @@ -242,7 +249,7 @@ if(SFML_OPENGL_ES) target_link_libraries(sfml-window PRIVATE EGL GLESv1_CM) endif() else() - sfml_find_package(OpenGL INCLUDE "OPENGL_INCLUDE_DIR" LINK "OPENGL_gl_LIBRARY") + sfml_find_package(OpenGL INCLUDE "OPENGL_INCLUDE_DIR" LINK "OPENGL_LIBRARIES") target_link_libraries(sfml-window PRIVATE OpenGL) endif()