Skip to content

Commit

Permalink
Generalize PlatformGraphics
Browse files Browse the repository at this point in the history
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 3322f58)
  • Loading branch information
semlanik committed Sep 13, 2024
1 parent 94187d9 commit 26d9fca
Show file tree
Hide file tree
Showing 8 changed files with 133 additions and 30 deletions.
5 changes: 3 additions & 2 deletions cmake/3rdparty/extra-cmake-modules/find-modules/FindEGL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@ list(APPEND CMAKE_REQUIRED_LIBRARIES "${EGL_LIBRARY}")
list(APPEND CMAKE_REQUIRED_INCLUDES "${EGL_INCLUDE_DIR}")
list(APPEND CMAKE_REQUIRED_DEFINITIONS "${EGL_DEFINITIONS}")

if(_qt_igy_gui_libs)
list(APPEND CMAKE_REQUIRED_LIBRARIES "${_qt_igy_gui_libs}")
find_package(PlatformGraphics)
if(TARGET PlatformGraphics::PlatformGraphics)
platform_graphics_extend_check_cxx_source_required_variables()
endif()

check_cxx_source_compiles("
Expand Down
7 changes: 4 additions & 3 deletions cmake/FindGLESv2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ else()
if(EGL_LIBRARY)
list(APPEND CMAKE_REQUIRED_LIBRARIES "${EGL_LIBRARY}")
endif()
if(_qt_igy_gui_libs)
list(APPEND CMAKE_REQUIRED_LIBRARIES "${_qt_igy_gui_libs}")
endif()
set(_includes "${CMAKE_REQUIRED_INCLUDES}")
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("
#ifdef __APPLE__
# include <OpenGLES/ES2/gl.h>
Expand Down
6 changes: 6 additions & 0 deletions cmake/platforms/FindIntegrityPlatformGraphics.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@
#.rst:
# 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
FOUND_VAR
IntegrityPlatformGraphics_FOUND
REQUIRED_VARS
IntegrityPlatformGraphics_LIBRARY
IntegrityPlatformGraphics_INCLUDE_DIR
IntegrityPlatformGraphics_REQUIRED_LIBRARIES
)

if(IntegrityPlatformGraphics_FOUND
Expand Down
63 changes: 63 additions & 0 deletions cmake/platforms/FindPlatformGraphics.cmake
Original file line number Diff line number Diff line change
@@ -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)
25 changes: 25 additions & 0 deletions cmake/platforms/FindVxWorksPlatformGraphics.cmake
Original file line number Diff line number Diff line change
@@ -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()

5 changes: 2 additions & 3 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -364,13 +364,12 @@ if(QT_FEATURE_opengl)
find_package(GLESv2)
target_link_libraries(Gui PUBLIC GLESv2::GLESv2)

if(INTEGRITY AND _qt_igy_gui_libs)
if(TARGET PlatformGraphics::PlatformGraphics)
qt_internal_extend_target(Gui
LIBRARIES
IntegrityPlatformGraphics::IntegrityPlatformGraphics
PlatformGraphics::PlatformGraphics
)
endif()

elseif(NOT QT_FEATURE_opengl_dynamic)
target_link_libraries(Gui PUBLIC WrapOpenGL::WrapOpenGL)
endif()
Expand Down
45 changes: 26 additions & 19 deletions src/gui/configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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(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(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)
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)
if(QT_FEATURE_system_zlib)
qt_add_qmake_lib_dependency(freetype zlib)
Expand Down Expand Up @@ -157,6 +156,12 @@ qt_find_package(RenderDoc PROVIDED_TARGETS RenderDoc::RenderDoc)

#### Tests

if(TARGET PlatformGraphics::PlatformGraphics)
set(plaform_graphics_libs PlatformGraphics::PlatformGraphics)
else()
set(plaform_graphics_libs "")
endif()

# drm_atomic
qt_config_compile_test(drm_atomic
LABEL "DRM Atomic API"
Expand Down Expand Up @@ -185,6 +190,7 @@ qt_config_compile_test(egl_x11
LIBRARIES
EGL::EGL
X11::X11
${plaform_graphics_libs}
CODE
"// 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
Expand Down Expand Up @@ -214,6 +220,7 @@ qt_config_compile_test(egl_brcm
LABEL "Broadcom EGL (Raspberry Pi)"
LIBRARIES
EGL::EGL
${plaform_graphics_libs}
CODE
"#include <EGL/egl.h>
#include <bcm_host.h>
Expand All @@ -233,6 +240,7 @@ qt_config_compile_test(egl_egldevice
LABEL "EGLDevice"
LIBRARIES
EGL::EGL
${plaform_graphics_libs}
CODE
"#include <EGL/egl.h>
#include <EGL/eglext.h>
Expand All @@ -255,6 +263,7 @@ qt_config_compile_test(egl_mali
LABEL "Mali EGL"
LIBRARIES
EGL::EGL
${plaform_graphics_libs}
CODE
"#include <EGL/fbdev_window.h>
#include <EGL/egl.h>
Expand All @@ -274,6 +283,7 @@ qt_config_compile_test(egl_mali_2
LABEL "Mali 2 EGL"
LIBRARIES
EGL::EGL
${plaform_graphics_libs}
CODE
"#include <EGL/egl.h>
#include <GLES2/gl2.h>
Expand All @@ -288,10 +298,12 @@ mali_native_window *w = 0;
")

# egl-viv

qt_config_compile_test(egl_viv
LABEL "i.Mx6 EGL"
LIBRARIES
EGL::EGL
${plaform_graphics_libs}
COMPILE_OPTIONS
"-DEGL_API_FB=1"
CODE
Expand All @@ -314,16 +326,12 @@ fbGetDisplayByIndex(0);
"# 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
qt_config_compile_test(egl_openwfd
LABEL "OpenWFD EGL"
LIBRARIES
${test_libs}
EGL::EGL
${plaform_graphics_libs}
CODE
"#include <wfd.h>
Expand All @@ -342,6 +350,7 @@ qt_config_compile_test(egl_rcar
LIBRARIES
EGL::EGL
GLESv2::GLESv2
${plaform_graphics_libs}
CODE
"#include <EGL/egl.h>
extern \"C\" {
Expand Down Expand Up @@ -435,15 +444,11 @@ if(WASM)
set(extra_compiler_options "-s FULL_ES3=1")
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
LABEL "OpenGL ES 3.0"
LIBRARIES
${test_libs}
GLESv2::GLESv2
${plaform_graphics_libs}
COMPILE_OPTIONS ${extra_compiler_options}
CODE
"#ifdef __APPLE__
Expand Down Expand Up @@ -471,7 +476,8 @@ glMapBufferRange(GL_ARRAY_BUFFER, 0, 0, GL_MAP_READ_BIT);
qt_config_compile_test(opengles31
LABEL "OpenGL ES 3.1"
LIBRARIES
${test_libs}
GLESv2::GLESv2
${plaform_graphics_libs}
CODE
"#include <GLES3/gl31.h>
Expand All @@ -489,7 +495,8 @@ glProgramUniform1i(0, 0, 0);
qt_config_compile_test(opengles32
LABEL "OpenGL ES 3.2"
LIBRARIES
${test_libs}
GLESv2::GLESv2
${plaform_graphics_libs}
CODE
"#include <GLES3/gl32.h>
Expand Down
7 changes: 4 additions & 3 deletions src/plugins/platforms/eglfs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ qt_internal_extend_target(EglFSDeviceIntegrationPrivate CONDITION TARGET Qt::Inp
Qt::InputSupportPrivate
)

qt_internal_extend_target(EglFSDeviceIntegrationPrivate CONDITION INTEGRITY AND TARGET IntegrityPlatformGraphics::IntegrityPlatformGraphics
LIBRARIES
IntegrityPlatformGraphics::IntegrityPlatformGraphics
qt_internal_extend_target(EglFSDeviceIntegrationPrivate
CONDITION TARGET PlatformGraphics::PlatformGraphics
PUBLIC_LIBRARIES
PlatformGraphics::PlatformGraphics
)

qt_internal_extend_target(EglFSDeviceIntegrationPrivate CONDITION QT_FEATURE_opengl
Expand Down

0 comments on commit 26d9fca

Please sign in to comment.