Sdk 6.2: CMake does not include configs from `/app/lib/<ARCH>-linux-gnu/cmake`
I sent PR updating the QtWebEngine base app to Qt6 and hit this issue.
find_package(Qt6${module})
is failing to detect Qt6 modules that are installed in /app/lib/${FLATPAK_ARCH}-linux-gnu
.
For example, when building QtWebView, CMake can't find the QtWebEngine modules from the QtWebEngine base app.
Another example is Jami, see the beta-dev branch.
App packaging need to set _qt_additional_packages_prefix_paths
to /app/lib/<ARCH>-linux-gnu/cmake
in order to work around this issue.
I suggest the following change
--- a/usr/lib/x86_64-linux-gnu/cmake/Qt6/Qt6Config.cmake 2021-12-29 14:28:49.326714902 +0200
+++ b/usr/lib/x86_64-linux-gnu/cmake/Qt6/Qt6Config.cmake 2021-12-29 14:28:07.787293407 +0200
@@ -189,6 +189,8 @@
PATHS
${_qt_cmake_dir}
${_qt_additional_packages_prefix_paths}
+ "/app/lib/cmake"
+ "/app/lib/${CMAKE_CXX_LIBRARY_ARCHITECTURE}/cmake"
${QT_EXAMPLES_CMAKE_PREFIX_PATH}
${__qt_find_package_host_qt_path}
${__qt_use_no_default_path_for_qt_packages}
I also offer an alternative, which requires setting QT_ADDITIONAL_PACKAGES_PREFIX_PATH=/app as environment or CMake variable in the app packaging. I'm not sure how correct is my regex.
--- a/usr/lib/x86_64-linux-gnu/cmake/Qt6/Qt6Config.cmake 2021-12-29 14:45:59.805721020 +0200
+++ b/usr/lib/x86_64-linux-gnu/cmake/Qt6/Qt6Config.cmake 2021-12-29 14:45:35.266061839 +0200
@@ -108,10 +108,12 @@
# NO_DEFAULT_PATH, and thus CMAKE_PREFIX_PATH values are discarded.
# CMAKE_FIND_ROOT_PATH values are not discarded and togegher with the PATHS option, it
# ensures packages from additional prefixes are found.
- if(NOT _qt_additional_path MATCHES "/lib/cmake$")
- string(APPEND _qt_additional_path "/lib/cmake")
+ if(NOT _qt_additional_path MATCHES "/lib(/${CMAKE_CXX_LIBRARY_ARCHITECTURE})?/cmake$")
+ list(APPEND _qt_additional_packages_prefix_paths "${_qt_additional_path}/lib/cmake")
+ list(APPEND _qt_additional_packages_prefix_paths "${_qt_additional_path}/lib/${CMAKE_CXX_LIBRARY_ARCHITECTURE}/cmake")
+ else()
+ list(APPEND _qt_additional_packages_prefix_paths "${_qt_additional_path}")
endif()
- list(APPEND _qt_additional_packages_prefix_paths "${_qt_additional_path}")
endforeach()
unset(_qt_additional_path)
unset(_qt_additional_packages_prefixes)
Edited by twb twb