From 3322f585eb5ad11acc1f93ecaafb42e30e37b197 Mon Sep 17 00:00:00 2001 From: Alexey Edelev Date: Thu, 29 Aug 2024 13:47:35 +0200 Subject: [PATCH] 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 _REQUIRED_ variables. The _REQUIRED_ variables are consumed by the PlatformGraphics::PlatformGraphics and stored in the respective _qt_internal_platform_graphics_required_ 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_ variable before running the respective compiler checks. Task-number: QTBUG-128455 Change-Id: Id1987c6294327509a14fbeeb7b8bf39aad6f486c Reviewed-by: Alexandru Croitor Reviewed-by: Karim Pinter --- .../find-modules/FindEGL.cmake | 5 +- cmake/FindGLESv2.cmake | 7 ++- .../FindIntegrityPlatformGraphics.cmake | 6 ++ cmake/platforms/FindPlatformGraphics.cmake | 63 +++++++++++++++++++ .../FindVxWorksPlatformGraphics.cmake | 25 ++++++++ src/gui/CMakeLists.txt | 5 +- src/gui/configure.cmake | 45 +++++++------ src/plugins/platforms/eglfs/CMakeLists.txt | 7 ++- 8 files changed, 133 insertions(+), 30 deletions(-) create mode 100644 cmake/platforms/FindPlatformGraphics.cmake create mode 100644 cmake/platforms/FindVxWorksPlatformGraphics.cmake diff --git a/cmake/3rdparty/extra-cmake-modules/find-modules/FindEGL.cmake b/cmake/3rdparty/extra-cmake-modules/find-modules/FindEGL.cmake index 9ac8e2fa0cf..4ab6e284e71 100644 --- a/cmake/3rdparty/extra-cmake-modules/find-modules/FindEGL.cmake +++ b/cmake/3rdparty/extra-cmake-modules/find-modules/FindEGL.cmake @@ -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(" diff --git a/cmake/FindGLESv2.cmake b/cmake/FindGLESv2.cmake index 645d13079a2..d615a300f48 100644 --- a/cmake/FindGLESv2.cmake +++ b/cmake/FindGLESv2.cmake @@ -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 diff --git a/cmake/platforms/FindIntegrityPlatformGraphics.cmake b/cmake/platforms/FindIntegrityPlatformGraphics.cmake index 7b03d7ae89f..f210e84674a 100644 --- a/cmake/platforms/FindIntegrityPlatformGraphics.cmake +++ b/cmake/platforms/FindIntegrityPlatformGraphics.cmake @@ -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 diff --git a/cmake/platforms/FindPlatformGraphics.cmake b/cmake/platforms/FindPlatformGraphics.cmake new file mode 100644 index 00000000000..80ae2a320e3 --- /dev/null +++ b/cmake/platforms/FindPlatformGraphics.cmake @@ -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) diff --git a/cmake/platforms/FindVxWorksPlatformGraphics.cmake b/cmake/platforms/FindVxWorksPlatformGraphics.cmake new file mode 100644 index 00000000000..a7f574e676e --- /dev/null +++ b/cmake/platforms/FindVxWorksPlatformGraphics.cmake @@ -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() + diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 6feb2bda474..035130cc334 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -365,13 +365,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() diff --git a/src/gui/configure.cmake b/src/gui/configure.cmake index 2fa518a23e2..36ae2a0701e 100644 --- a/src/gui/configure.cmake +++ b/src/gui/configure.cmake @@ -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) @@ -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" @@ -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 @@ -214,6 +220,7 @@ qt_config_compile_test(egl_brcm LABEL "Broadcom EGL (Raspberry Pi)" LIBRARIES EGL::EGL + ${plaform_graphics_libs} CODE "#include #include @@ -233,6 +240,7 @@ qt_config_compile_test(egl_egldevice LABEL "EGLDevice" LIBRARIES EGL::EGL + ${plaform_graphics_libs} CODE "#include #include @@ -255,6 +263,7 @@ qt_config_compile_test(egl_mali LABEL "Mali EGL" LIBRARIES EGL::EGL + ${plaform_graphics_libs} CODE "#include #include @@ -274,6 +283,7 @@ qt_config_compile_test(egl_mali_2 LABEL "Mali 2 EGL" LIBRARIES EGL::EGL + ${plaform_graphics_libs} CODE "#include #include @@ -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 @@ -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 @@ -342,6 +350,7 @@ qt_config_compile_test(egl_rcar LIBRARIES EGL::EGL GLESv2::GLESv2 + ${plaform_graphics_libs} CODE "#include extern \"C\" { @@ -425,15 +434,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__ @@ -461,7 +466,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 @@ -479,7 +485,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 diff --git a/src/plugins/platforms/eglfs/CMakeLists.txt b/src/plugins/platforms/eglfs/CMakeLists.txt index cb4b5d1eb93..7c53dae667c 100644 --- a/src/plugins/platforms/eglfs/CMakeLists.txt +++ b/src/plugins/platforms/eglfs/CMakeLists.txt @@ -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