sdl12-compat: build: Automatically use legacy GLX library if libOpenGL was not found

From fede2ffeff0e82d5fca537a91561059fcd803cc3 Mon Sep 17 00:00:00 2001
From: Simon McVittie <[EMAIL REDACTED]>
Date: Wed, 2 Mar 2022 14:01:23 +0000
Subject: [PATCH] build: Automatically use legacy GLX library if libOpenGL was
 not found

In older runtime environments like Steam Runtime 1 'scout', we don't
necessarily have access to the GLVND dispatch library.

Signed-off-by: Simon McVittie <smcv@collabora.com>
---
 CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index f4e0779..53c8192 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -220,7 +220,7 @@ if(SDL12TESTS)
     test_program(testdyngl "test/testdyngl.c")
     test_program(testgl "test/testgl.c")
     if(OPENGL_FOUND)
-      if(CMAKE_VERSION VERSION_LESS 3.10)
+      if(CMAKE_VERSION VERSION_LESS 3.10 OR NOT OPENGL_opengl_LIBRARY)
         target_link_libraries(testgl ${OPENGL_gl_LIBRARY})
       else()
         target_link_libraries(testgl ${OPENGL_opengl_LIBRARY})