From 8116fdde1c13fe00fb03414b56da2d66e215f279 Mon Sep 17 00:00:00 2001 From: Tatiana Borisova Date: Thu, 24 Mar 2022 15:09:25 +0200 Subject: [PATCH] Reorganize work with graphical libraries on INTEGRITY - Currently we manually unpack all platform libraries, that are required for GUI apps, and pack it into single eglmegapack.a library. It could be better do not execute such additional step, but have possibility to add required graphical libs to cmake interface lib via toolchain file list variable. Pick-to: 6.2 6.3 Change-Id: Ic4122600f02e6828d528ee4f00075f8c27f42e38 Reviewed-by: Alexandru Croitor --- .../find-modules/FindEGL.cmake | 4 +++ cmake/FindGLESv2.cmake | 3 +++ .../FindIntegrityPlatformGraphics.cmake | 26 +++++++++++++++++++ src/gui/CMakeLists.txt | 7 +++++ src/gui/configure.cmake | 24 ++++++++++++++--- src/plugins/platforms/eglfs/CMakeLists.txt | 5 ++++ 6 files changed, 65 insertions(+), 4 deletions(-) create mode 100644 cmake/platforms/FindIntegrityPlatformGraphics.cmake diff --git a/cmake/3rdparty/extra-cmake-modules/find-modules/FindEGL.cmake b/cmake/3rdparty/extra-cmake-modules/find-modules/FindEGL.cmake index a3573bacd4d..0733f1f702c 100644 --- a/cmake/3rdparty/extra-cmake-modules/find-modules/FindEGL.cmake +++ b/cmake/3rdparty/extra-cmake-modules/find-modules/FindEGL.cmake @@ -120,6 +120,10 @@ 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}") +endif() + check_cxx_source_compiles(" #include diff --git a/cmake/FindGLESv2.cmake b/cmake/FindGLESv2.cmake index 25b9044bb28..6d7147f5636 100644 --- a/cmake/FindGLESv2.cmake +++ b/cmake/FindGLESv2.cmake @@ -15,6 +15,9 @@ 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}") diff --git a/cmake/platforms/FindIntegrityPlatformGraphics.cmake b/cmake/platforms/FindIntegrityPlatformGraphics.cmake new file mode 100644 index 00000000000..cfcd260740c --- /dev/null +++ b/cmake/platforms/FindIntegrityPlatformGraphics.cmake @@ -0,0 +1,26 @@ +#.rst: +# IntegrityPlatformGraphics +# --------- +find_package_handle_standard_args(IntegrityPlatformGraphics + FOUND_VAR + IntegrityPlatformGraphics_FOUND + REQUIRED_VARS + IntegrityPlatformGraphics_LIBRARY + IntegrityPlatformGraphics_INCLUDE_DIR +) + +if(IntegrityPlatformGraphics_FOUND + AND NOT TARGET IntegrityPlatformGraphics::IntegrityPlatformGraphics) + add_library(IntegrityPlatformGraphics::IntegrityPlatformGraphics STATIC IMPORTED) + set_target_properties(IntegrityPlatformGraphics::IntegrityPlatformGraphics PROPERTIES + IMPORTED_LOCATION "${IntegrityPlatformGraphics_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${IntegrityPlatformGraphics_INCLUDE_DIR}" + ) + target_link_libraries(IntegrityPlatformGraphics::IntegrityPlatformGraphics + INTERFACE ${IntegrityPlatformGraphics_LIBRARIES_PACK}) +endif() + +mark_as_advanced(IntegrityPlatformGraphics_LIBRARY) + +# compatibility variables +set(IntegrityPlatformGraphics_LIBRARIES ${IntegrityPlatformGraphics_LIBRARY}) diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index c0adb60c017..e9a07f124ef 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -330,6 +330,13 @@ if(QT_FEATURE_opengl) if(QT_FEATURE_opengles2) find_package(GLESv2) target_link_libraries(Gui PUBLIC GLESv2::GLESv2) + + if(INTEGRITY AND _qt_igy_gui_libs) + find_package(IntegrityPlatformGraphics) + target_link_libraries(Gui + INTERFACE $) + 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 af6d63be8c1..8f6d227a306 100644 --- a/src/gui/configure.cmake +++ b/src/gui/configure.cmake @@ -30,6 +30,11 @@ qt_find_package(ATSPI2 PROVIDED_TARGETS PkgConfig::ATSPI2 MODULE_NAME gui QMAKE_ 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(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) set_package_properties(WrapFreetype PROPERTIES TYPE REQUIRED) if(QT_FEATURE_system_zlib) @@ -289,11 +294,16 @@ 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 - EGL::EGL + ${test_libs} CODE "#include @@ -397,10 +407,15 @@ if(WASM) endif() # special case end +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 - GLESv2::GLESv2 + ${test_libs} # special case begin COMPILE_OPTIONS ${extra_compiler_options} # special case end @@ -425,11 +440,12 @@ glMapBufferRange(GL_ARRAY_BUFFER, 0, 0, GL_MAP_READ_BIT); } ") + # opengles31 qt_config_compile_test(opengles31 LABEL "OpenGL ES 3.1" LIBRARIES - GLESv2::GLESv2 + ${test_libs} CODE "#include @@ -447,7 +463,7 @@ glProgramUniform1i(0, 0, 0); qt_config_compile_test(opengles32 LABEL "OpenGL ES 3.2" LIBRARIES - GLESv2::GLESv2 + ${test_libs} CODE "#include diff --git a/src/plugins/platforms/eglfs/CMakeLists.txt b/src/plugins/platforms/eglfs/CMakeLists.txt index 61adb947781..c8b398e7a29 100644 --- a/src/plugins/platforms/eglfs/CMakeLists.txt +++ b/src/plugins/platforms/eglfs/CMakeLists.txt @@ -56,6 +56,11 @@ 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 QT_FEATURE_opengl SOURCES api/qeglfscontext.cpp api/qeglfscontext_p.h