Skip to content

Commit

Permalink
CMake: Fix build with CMake 3.28 on macOS
Browse files Browse the repository at this point in the history
FindWrapOpenGL.cmake assumed that IMPORTED_LOCATION is the absolute path
of the library within the framework. That's not the case with CMake 3.28
anymore. There, IMPORTED_LOCATION is the absolute path of the framework
directory.

The relevant upstream CMake change is
6b01a27f901b5eb392955fea322cde44a1b782a3.

Pick-to: 6.2 6.5 6.6
Change-Id: I6b702a28318e0978c56dec83c398965aa77ef020
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
  • Loading branch information
jobor committed Sep 12, 2023
1 parent 53cc923 commit 0efea80
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions cmake/FindWrapOpenGL.cmake
Expand Up @@ -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()

Expand Down

0 comments on commit 0efea80

Please sign in to comment.