Generalize PlatformGraphics

Add the unified PlatformGraphics module, which looks for either Integrity
or VxWorks platform graphics.

The PlatformGraphics module creates the interface
PlatformGraphics::PlatformGraphics target which links the respective
platform graphics target. It's expected that from the platform graphics
targets to deliver the consistent subset of definitions, libraries,
include directories, compiler and linker flags and also the special
<platform>_REQUIRED_<LIBRARIES|INCLUDES|DEFINITIONS> variables.

The <platform>_REQUIRED_<LIBRARIES|INCLUDES|DEFINITIONS> variables are
consumed by the PlatformGraphics::PlatformGraphics and stored in the
respective _qt_internal_platform_graphics_required_<type> property, to
access the value without scope limitations. The property then is
checked by the EGL and GLESv2 modules(this can be done elsewhere too)
and is appended to the CMAKE_REQUIRED_<type> variable before running
the respective compiler checks.

Task-number: QTBUG-128455
Change-Id: Id1987c6294327509a14fbeeb7b8bf39aad6f486c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Karim Pinter <karim.pinter@qt.io>
(cherry picked from commit 3322f585eb5ad11acc1f93ecaafb42e30e37b197)
This commit is contained in:
Alexey Edelev 2024-08-29 13:47:35 +02:00
parent 94187d9f79
commit 26d9fca58e
8 changed files with 133 additions and 30 deletions

View File

@ -120,8 +120,9 @@ list(APPEND CMAKE_REQUIRED_LIBRARIES "${EGL_LIBRARY}")
list(APPEND CMAKE_REQUIRED_INCLUDES "${EGL_INCLUDE_DIR}") list(APPEND CMAKE_REQUIRED_INCLUDES "${EGL_INCLUDE_DIR}")
list(APPEND CMAKE_REQUIRED_DEFINITIONS "${EGL_DEFINITIONS}") list(APPEND CMAKE_REQUIRED_DEFINITIONS "${EGL_DEFINITIONS}")
if(_qt_igy_gui_libs) find_package(PlatformGraphics)
list(APPEND CMAKE_REQUIRED_LIBRARIES "${_qt_igy_gui_libs}") if(TARGET PlatformGraphics::PlatformGraphics)
platform_graphics_extend_check_cxx_source_required_variables()
endif() endif()
check_cxx_source_compiles(" check_cxx_source_compiles("

View File

@ -18,12 +18,13 @@ else()
if(EGL_LIBRARY) if(EGL_LIBRARY)
list(APPEND CMAKE_REQUIRED_LIBRARIES "${EGL_LIBRARY}") list(APPEND CMAKE_REQUIRED_LIBRARIES "${EGL_LIBRARY}")
endif() endif()
if(_qt_igy_gui_libs)
list(APPEND CMAKE_REQUIRED_LIBRARIES "${_qt_igy_gui_libs}")
endif()
set(_includes "${CMAKE_REQUIRED_INCLUDES}") set(_includes "${CMAKE_REQUIRED_INCLUDES}")
list(APPEND CMAKE_REQUIRED_INCLUDES "${GLESv2_INCLUDE_DIR}") list(APPEND CMAKE_REQUIRED_INCLUDES "${GLESv2_INCLUDE_DIR}")
find_package(PlatformGraphics)
if(TARGET PlatformGraphics::PlatformGraphics)
platform_graphics_extend_check_cxx_source_required_variables()
endif()
check_cxx_source_compiles(" check_cxx_source_compiles("
#ifdef __APPLE__ #ifdef __APPLE__
# include <OpenGLES/ES2/gl.h> # include <OpenGLES/ES2/gl.h>

View File

@ -4,12 +4,18 @@
#.rst: #.rst:
# IntegrityPlatformGraphics # IntegrityPlatformGraphics
# --------- # ---------
# Temporary fall back to allow integrating this pachset without the
# toolchain file updated.
set(IntegrityPlatformGraphics_REQUIRED_LIBRARIES ${_qt_igy_gui_libs})
find_package_handle_standard_args(IntegrityPlatformGraphics find_package_handle_standard_args(IntegrityPlatformGraphics
FOUND_VAR FOUND_VAR
IntegrityPlatformGraphics_FOUND IntegrityPlatformGraphics_FOUND
REQUIRED_VARS REQUIRED_VARS
IntegrityPlatformGraphics_LIBRARY IntegrityPlatformGraphics_LIBRARY
IntegrityPlatformGraphics_INCLUDE_DIR IntegrityPlatformGraphics_INCLUDE_DIR
IntegrityPlatformGraphics_REQUIRED_LIBRARIES
) )
if(IntegrityPlatformGraphics_FOUND if(IntegrityPlatformGraphics_FOUND

View File

@ -0,0 +1,63 @@
# Copyright (C) 2024 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
#.rst:
# PlatformGraphics
# ---------
if(INTEGRITY)
set(platform Integrity)
elseif(VXWORKS)
set(platform VxWorks)
else()
set(PlatformGraphics_FOUND FALSE)
return()
endif()
find_package(${platform}PlatformGraphics)
set(platform_target ${platform}PlatformGraphics::${platform}PlatformGraphics)
if(NOT ${platform}PlatformGraphics_FOUND OR
NOT TARGET ${platform_target})
set(PlatformGraphics_FOUND FALSE)
return()
endif()
if(NOT TARGET PlatformGraphics::PlatformGraphics)
add_library(PlatformGraphics::PlatformGraphics INTERFACE IMPORTED)
target_link_libraries(PlatformGraphics::PlatformGraphics INTERFACE ${platform_target})
# The list of libraries that are required to pass the EGL/OpenGL/GLESv2
# compile checks. The list might or might not be provided by platforms or
# toolchain files.
foreach(known_var LIBRARIES INCLUDES DEFINITIONS)
string(TOLOWER "${known_var}" known_var_lc)
if(${platform}PlatformGraphics_REQUIRED_${known_var})
set_property(TARGET PlatformGraphics::PlatformGraphics PROPERTY
_qt_internal_platform_graphics_required_${known_var_lc}
"${${platform}PlatformGraphics_REQUIRED_${known_var}}"
)
endif()
endforeach()
unset(known_var)
unset(known_var_lc)
endif()
function(platform_graphics_extend_check_cxx_source_required_variables)
foreach(known_var LIBRARIES INCLUDES DEFINITIONS)
string(TOLOWER "${known_var}" known_var_lc)
get_target_property(platform_graphics_required_${known_var_lc}
PlatformGraphics::PlatformGraphics
_qt_internal_platform_graphics_required_${known_var_lc}
)
if(platform_graphics_required_${known_var_lc})
list(APPEND CMAKE_REQUIRED_${known_var} ${platform_graphics_required_${known_var_lc}})
set(CMAKE_REQUIRED_${known_var} "${CMAKE_REQUIRED_${known_var}}" PARENT_SCOPE)
endif()
endforeach()
endfunction()
unset(platform)
unset(platform_target)
set(PlatformGraphics_FOUND TRUE)

View File

@ -0,0 +1,25 @@
# Copyright (C) 2024 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
#.rst:
# VxWorksPlatformGraphics
# ---------
find_package_handle_standard_args(VxWorksPlatformGraphics
FOUND_VAR
VxWorksPlatformGraphics_FOUND
REQUIRED_VARS
VxWorksPlatformGraphics_LIBRARIES_PACK
VxWorksPlatformGraphics_REQUIRED_LIBRARIES
)
if(VxWorksPlatformGraphics_FOUND
AND NOT TARGET VxWorksPlatformGraphics::VxWorksPlatformGraphics)
add_library(VxWorksPlatformGraphics::VxWorksPlatformGraphics INTERFACE IMPORTED)
set_target_properties(VxWorksPlatformGraphics::VxWorksPlatformGraphics PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${VxWorksPlatformGraphics_INCLUDE_DIR}"
INTERFACE_LINK_LIBRARIES "${VxWorksPlatformGraphics_LIBRARIES_PACK}"
INTERFACE_COMPILE_DEFINITIONS "${VxWorksPlatformGraphics_DEFINES}"
)
set(VxWorksPlatformGraphics_REQUIRED_DEFINITIONS ${VxWorksPlatformGraphics_DEFINES})
endif()

View File

@ -364,13 +364,12 @@ if(QT_FEATURE_opengl)
find_package(GLESv2) find_package(GLESv2)
target_link_libraries(Gui PUBLIC GLESv2::GLESv2) target_link_libraries(Gui PUBLIC GLESv2::GLESv2)
if(INTEGRITY AND _qt_igy_gui_libs) if(TARGET PlatformGraphics::PlatformGraphics)
qt_internal_extend_target(Gui qt_internal_extend_target(Gui
LIBRARIES LIBRARIES
IntegrityPlatformGraphics::IntegrityPlatformGraphics PlatformGraphics::PlatformGraphics
) )
endif() endif()
elseif(NOT QT_FEATURE_opengl_dynamic) elseif(NOT QT_FEATURE_opengl_dynamic)
target_link_libraries(Gui PUBLIC WrapOpenGL::WrapOpenGL) target_link_libraries(Gui PUBLIC WrapOpenGL::WrapOpenGL)
endif() endif()

View File

@ -33,12 +33,11 @@ qt_set01(X11_SUPPORTED LINUX OR HPUX OR FREEBSD OR NETBSD OR OPENBSD OR SOLARIS
qt_find_package(ATSPI2 PROVIDED_TARGETS PkgConfig::ATSPI2 MODULE_NAME gui QMAKE_LIB atspi) qt_find_package(ATSPI2 PROVIDED_TARGETS PkgConfig::ATSPI2 MODULE_NAME gui QMAKE_LIB atspi)
qt_find_package(DirectFB PROVIDED_TARGETS PkgConfig::DirectFB MODULE_NAME gui QMAKE_LIB directfb) qt_find_package(DirectFB PROVIDED_TARGETS PkgConfig::DirectFB MODULE_NAME gui QMAKE_LIB directfb)
qt_find_package(Libdrm PROVIDED_TARGETS Libdrm::Libdrm MODULE_NAME gui QMAKE_LIB drm) qt_find_package(Libdrm PROVIDED_TARGETS Libdrm::Libdrm MODULE_NAME gui QMAKE_LIB drm)
qt_find_package(PlatformGraphics
PROVIDED_TARGETS PlatformGraphics::PlatformGraphics
MODULE_NAME gui QMAKE_LIB platform_graphics)
qt_find_package(EGL PROVIDED_TARGETS EGL::EGL MODULE_NAME gui QMAKE_LIB egl) qt_find_package(EGL PROVIDED_TARGETS EGL::EGL MODULE_NAME gui QMAKE_LIB egl)
if(INTEGRITY AND _qt_igy_gui_libs)
qt_find_package(IntegrityPlatformGraphics
PROVIDED_TARGETS IntegrityPlatformGraphics::IntegrityPlatformGraphics
MODULE_NAME gui QMAKE_LIB integrity_platform_graphics)
endif()
qt_find_package(WrapSystemFreetype 2.2.0 PROVIDED_TARGETS WrapSystemFreetype::WrapSystemFreetype MODULE_NAME gui QMAKE_LIB freetype) qt_find_package(WrapSystemFreetype 2.2.0 PROVIDED_TARGETS WrapSystemFreetype::WrapSystemFreetype MODULE_NAME gui QMAKE_LIB freetype)
if(QT_FEATURE_system_zlib) if(QT_FEATURE_system_zlib)
qt_add_qmake_lib_dependency(freetype zlib) qt_add_qmake_lib_dependency(freetype zlib)
@ -157,6 +156,12 @@ qt_find_package(RenderDoc PROVIDED_TARGETS RenderDoc::RenderDoc)
#### Tests #### Tests
if(TARGET PlatformGraphics::PlatformGraphics)
set(plaform_graphics_libs PlatformGraphics::PlatformGraphics)
else()
set(plaform_graphics_libs "")
endif()
# drm_atomic # drm_atomic
qt_config_compile_test(drm_atomic qt_config_compile_test(drm_atomic
LABEL "DRM Atomic API" LABEL "DRM Atomic API"
@ -185,6 +190,7 @@ qt_config_compile_test(egl_x11
LIBRARIES LIBRARIES
EGL::EGL EGL::EGL
X11::X11 X11::X11
${plaform_graphics_libs}
CODE CODE
"// Check if EGL is compatible with X. Some EGL implementations, typically on "// Check if EGL is compatible with X. Some EGL implementations, typically on
// embedded devices, are not intended to be used together with X. EGL support // embedded devices, are not intended to be used together with X. EGL support
@ -214,6 +220,7 @@ qt_config_compile_test(egl_brcm
LABEL "Broadcom EGL (Raspberry Pi)" LABEL "Broadcom EGL (Raspberry Pi)"
LIBRARIES LIBRARIES
EGL::EGL EGL::EGL
${plaform_graphics_libs}
CODE CODE
"#include <EGL/egl.h> "#include <EGL/egl.h>
#include <bcm_host.h> #include <bcm_host.h>
@ -233,6 +240,7 @@ qt_config_compile_test(egl_egldevice
LABEL "EGLDevice" LABEL "EGLDevice"
LIBRARIES LIBRARIES
EGL::EGL EGL::EGL
${plaform_graphics_libs}
CODE CODE
"#include <EGL/egl.h> "#include <EGL/egl.h>
#include <EGL/eglext.h> #include <EGL/eglext.h>
@ -255,6 +263,7 @@ qt_config_compile_test(egl_mali
LABEL "Mali EGL" LABEL "Mali EGL"
LIBRARIES LIBRARIES
EGL::EGL EGL::EGL
${plaform_graphics_libs}
CODE CODE
"#include <EGL/fbdev_window.h> "#include <EGL/fbdev_window.h>
#include <EGL/egl.h> #include <EGL/egl.h>
@ -274,6 +283,7 @@ qt_config_compile_test(egl_mali_2
LABEL "Mali 2 EGL" LABEL "Mali 2 EGL"
LIBRARIES LIBRARIES
EGL::EGL EGL::EGL
${plaform_graphics_libs}
CODE CODE
"#include <EGL/egl.h> "#include <EGL/egl.h>
#include <GLES2/gl2.h> #include <GLES2/gl2.h>
@ -288,10 +298,12 @@ mali_native_window *w = 0;
") ")
# egl-viv # egl-viv
qt_config_compile_test(egl_viv qt_config_compile_test(egl_viv
LABEL "i.Mx6 EGL" LABEL "i.Mx6 EGL"
LIBRARIES LIBRARIES
EGL::EGL EGL::EGL
${plaform_graphics_libs}
COMPILE_OPTIONS COMPILE_OPTIONS
"-DEGL_API_FB=1" "-DEGL_API_FB=1"
CODE CODE
@ -314,16 +326,12 @@ fbGetDisplayByIndex(0);
"# FIXME: qmake: ['DEFINES += EGL_API_FB=1', '!integrity: DEFINES += LINUX=1'] "# FIXME: qmake: ['DEFINES += EGL_API_FB=1', '!integrity: DEFINES += LINUX=1']
) )
set(test_libs EGL::EGL)
if(INTEGRITY AND _qt_igy_gui_libs)
set(test_libs ${test_libs} IntegrityPlatformGraphics::IntegrityPlatformGraphics)
endif()
# egl-openwfd # egl-openwfd
qt_config_compile_test(egl_openwfd qt_config_compile_test(egl_openwfd
LABEL "OpenWFD EGL" LABEL "OpenWFD EGL"
LIBRARIES LIBRARIES
${test_libs} EGL::EGL
${plaform_graphics_libs}
CODE CODE
"#include <wfd.h> "#include <wfd.h>
@ -342,6 +350,7 @@ qt_config_compile_test(egl_rcar
LIBRARIES LIBRARIES
EGL::EGL EGL::EGL
GLESv2::GLESv2 GLESv2::GLESv2
${plaform_graphics_libs}
CODE CODE
"#include <EGL/egl.h> "#include <EGL/egl.h>
extern \"C\" { extern \"C\" {
@ -435,15 +444,11 @@ if(WASM)
set(extra_compiler_options "-s FULL_ES3=1") set(extra_compiler_options "-s FULL_ES3=1")
endif() endif()
set(test_libs GLESv2::GLESv2)
if(INTEGRITY AND _qt_igy_gui_libs)
set(test_libs ${test_libs} IntegrityPlatformGraphics::IntegrityPlatformGraphics)
endif()
qt_config_compile_test(opengles3 qt_config_compile_test(opengles3
LABEL "OpenGL ES 3.0" LABEL "OpenGL ES 3.0"
LIBRARIES LIBRARIES
${test_libs} GLESv2::GLESv2
${plaform_graphics_libs}
COMPILE_OPTIONS ${extra_compiler_options} COMPILE_OPTIONS ${extra_compiler_options}
CODE CODE
"#ifdef __APPLE__ "#ifdef __APPLE__
@ -471,7 +476,8 @@ glMapBufferRange(GL_ARRAY_BUFFER, 0, 0, GL_MAP_READ_BIT);
qt_config_compile_test(opengles31 qt_config_compile_test(opengles31
LABEL "OpenGL ES 3.1" LABEL "OpenGL ES 3.1"
LIBRARIES LIBRARIES
${test_libs} GLESv2::GLESv2
${plaform_graphics_libs}
CODE CODE
"#include <GLES3/gl31.h> "#include <GLES3/gl31.h>
@ -489,7 +495,8 @@ glProgramUniform1i(0, 0, 0);
qt_config_compile_test(opengles32 qt_config_compile_test(opengles32
LABEL "OpenGL ES 3.2" LABEL "OpenGL ES 3.2"
LIBRARIES LIBRARIES
${test_libs} GLESv2::GLESv2
${plaform_graphics_libs}
CODE CODE
"#include <GLES3/gl32.h> "#include <GLES3/gl32.h>

View File

@ -57,9 +57,10 @@ qt_internal_extend_target(EglFSDeviceIntegrationPrivate CONDITION TARGET Qt::Inp
Qt::InputSupportPrivate Qt::InputSupportPrivate
) )
qt_internal_extend_target(EglFSDeviceIntegrationPrivate CONDITION INTEGRITY AND TARGET IntegrityPlatformGraphics::IntegrityPlatformGraphics qt_internal_extend_target(EglFSDeviceIntegrationPrivate
LIBRARIES CONDITION TARGET PlatformGraphics::PlatformGraphics
IntegrityPlatformGraphics::IntegrityPlatformGraphics PUBLIC_LIBRARIES
PlatformGraphics::PlatformGraphics
) )
qt_internal_extend_target(EglFSDeviceIntegrationPrivate CONDITION QT_FEATURE_opengl qt_internal_extend_target(EglFSDeviceIntegrationPrivate CONDITION QT_FEATURE_opengl