summaryrefslogtreecommitdiffstats
path: root/cmake/FindWrapOpenGL.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/FindWrapOpenGL.cmake')
-rw-r--r--cmake/FindWrapOpenGL.cmake20
1 files changed, 17 insertions, 3 deletions
diff --git a/cmake/FindWrapOpenGL.cmake b/cmake/FindWrapOpenGL.cmake
index 538bb021a7..7295a159ca 100644
--- a/cmake/FindWrapOpenGL.cmake
+++ b/cmake/FindWrapOpenGL.cmake
@@ -1,5 +1,5 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+# SPDX-License-Identifier: BSD-3-Clause
# We can't create the same interface imported target multiple times, CMake will complain if we do
# that. This can happen if the find_package call is done in multiple different subdirectories.
@@ -17,14 +17,18 @@ if (OpenGL_FOUND)
add_library(WrapOpenGL::WrapOpenGL INTERFACE IMPORTED)
if(APPLE)
+ # CMake 3.27 and older:
# On Darwin platforms FindOpenGL sets IMPORTED_LOCATION to the absolute path of the library
# within the framework. This ends up as an absolute path link flag, which we don't want,
# because that makes our .prl files un-relocatable.
# Extract the framework path instead, and use that in INTERFACE_LINK_LIBRARIES,
- # which CMake ends up transforming into a reloctable -framework flag.
+ # which CMake ends up transforming into a relocatable -framework flag.
# See https://gitlab.kitware.com/cmake/cmake/-/issues/20871 for details.
+ #
+ # CMake 3.28 and above:
+ # IMPORTED_LOCATION is the absolute path the the OpenGL.framework folder.
get_target_property(__opengl_fw_lib_path OpenGL::GL IMPORTED_LOCATION)
- if(__opengl_fw_lib_path)
+ if(__opengl_fw_lib_path AND NOT __opengl_fw_lib_path MATCHES "/([^/]+)\\.framework$")
get_filename_component(__opengl_fw_path "${__opengl_fw_lib_path}" DIRECTORY)
endif()
@@ -46,6 +50,16 @@ if (OpenGL_FOUND)
else()
target_link_libraries(WrapOpenGL::WrapOpenGL INTERFACE OpenGL::GL)
endif()
+elseif(UNIX AND NOT APPLE AND NOT CMAKE_SYSTEM_NAME STREQUAL "Integrity")
+ # Requesting only the OpenGL component ensures CMake does not mark the package as
+ # not found if neither GLX nor libGL are available. This allows finding OpenGL
+ # on an X11-less Linux system.
+ find_package(OpenGL ${WrapOpenGL_FIND_VERSION} COMPONENTS OpenGL)
+ if (OpenGL_FOUND)
+ set(WrapOpenGL_FOUND ON)
+ add_library(WrapOpenGL::WrapOpenGL INTERFACE IMPORTED)
+ target_link_libraries(WrapOpenGL::WrapOpenGL INTERFACE OpenGL::OpenGL)
+ endif()
endif()
include(FindPackageHandleStandardArgs)