target_link_libraries expects a quoted string like "-framework CoreFoundation" when linking frameworks and not 2 different arguments like "-framework" "CoreFoundation". Fix that in the FindWrapOpenGL and FindGLESv2 find modules. Make sure to not quote the framework link flags when generating .pri files even if there are spaces, otherwise building apps with qmake fails. Amends 7fcc9cf05500fd3a0a1ba5c2f90a8ad3bcd8e5b0 Amends 2ed63e587eefb246dba9e69aa01fdb2abb2def13 Amends 55a15a1c1b93d36d705fc69e44b5c806b807dd55 Amends 2a767ab4bb7de8c29d2a8365212244ed944e9aeb Task-number: QTBUG-85240 Change-Id: I66ba36760ad704d65e712072a528d9e25c336dfa Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
50 lines
2.0 KiB
CMake
50 lines
2.0 KiB
CMake
# 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.
|
|
if(TARGET WrapOpenGL::WrapOpenGL)
|
|
set(WrapOpenGL_FOUND ON)
|
|
return()
|
|
endif()
|
|
|
|
set(WrapOpenGL_FOUND OFF)
|
|
|
|
find_package(OpenGL ${WrapOpenGL_FIND_VERSION})
|
|
|
|
if (OpenGL_FOUND)
|
|
set(WrapOpenGL_FOUND ON)
|
|
|
|
add_library(WrapOpenGL::WrapOpenGL INTERFACE IMPORTED)
|
|
if(APPLE)
|
|
# 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.
|
|
# See https://gitlab.kitware.com/cmake/cmake/-/issues/20871 for details.
|
|
get_target_property(__opengl_fw_lib_path OpenGL::GL IMPORTED_LOCATION)
|
|
if(__opengl_fw_lib_path)
|
|
get_filename_component(__opengl_fw_path "${__opengl_fw_lib_path}" DIRECTORY)
|
|
endif()
|
|
|
|
if(NOT __opengl_fw_path)
|
|
# Just a safety measure in case if no OpenGL::GL target exists.
|
|
set(__opengl_fw_path "-framework OpenGL")
|
|
endif()
|
|
|
|
find_library(WrapOpenGL_AGL NAMES AGL)
|
|
if(WrapOpenGL_AGL)
|
|
set(__opengl_agl_fw_path "${WrapOpenGL_AGL}")
|
|
endif()
|
|
if(NOT __opengl_agl_fw_path)
|
|
set(__opengl_agl_fw_path "-framework AGL")
|
|
endif()
|
|
|
|
target_link_libraries(WrapOpenGL::WrapOpenGL INTERFACE ${__opengl_fw_path})
|
|
target_link_libraries(WrapOpenGL::WrapOpenGL INTERFACE ${__opengl_agl_fw_path})
|
|
else()
|
|
target_link_libraries(WrapOpenGL::WrapOpenGL INTERFACE OpenGL::GL)
|
|
endif()
|
|
endif()
|
|
|
|
include(FindPackageHandleStandardArgs)
|
|
find_package_handle_standard_args(WrapOpenGL DEFAULT_MSG WrapOpenGL_FOUND)
|