I’m having difficulty getting a part to build with the cmake plugin that is dependent on a previous part also built with the cmake plugin. The parts are adwaita-qt and qgnomeplatform. QGnomePlatform depends on adwaita-qt libs being present. Adwaita-qt successfully installs to SNAPCRAFT_STAGE but when QGnomePlatform attempts to build I get the following error:
Building qgnomeplatform
+ snapcraftctl build
+ cmake /root/parts/qgnomeplatform/src/ -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1")
-- Checking for module 'glib-2.0'
-- Found glib-2.0, version 2.64.6
-- Found GSettingSchemas: TRUE
CMake Error at /root/stage/usr/lib/x86_64-linux-gnu/cmake/AdwaitaQt/AdwaitaQtTargets.cmake:80 (message):
The imported target "adwaitaqtpriv" references the file
"/usr/lib/x86_64-linux-gnu/libadwaitaqtpriv.so.1.4.1"
but this file does not exist. Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
"/root/stage/usr/lib/x86_64-linux-gnu/cmake/AdwaitaQt/AdwaitaQtTargets.cmake"
but not all the files it references.
Call Stack (most recent call first):
/root/stage/usr/lib/x86_64-linux-gnu/cmake/AdwaitaQt/AdwaitaQtConfig.cmake:44 (include)
CMakeLists.txt:50 (find_package)
-- Configuring incomplete, errors occurred!
See also "/root/parts/qgnomeplatform/build/CMakeFiles/CMakeOutput.log".
See also "/root/parts/qgnomeplatform/build/CMakeFiles/CMakeError.log".
Failed to build 'qgnomeplatform'.
Recommended resolution:
Check the build logs and ensure the part's configuration and sources are correct.
The libadwaitaqtpriv.so.1.4.1 library does get installed to SNAPCRAFT_STAGE
Ah, yes, hm. _IMPORT_PREFIX will point to /usr if you set CMAKE_INSTALL_PREFIX like that, I think.
Have you tried setting -DCMAKE_INSTALL_PREFIX="" for the dependency?
I’ve split the 2 parts out to a separate snap to experiment on this, unfortunately setting -DCMAKE_INSTALL_PREFIX="" doesn’t resolve the problem:
'qgnomeplatform' has dependencies that need to be staged: adwaita-qt
Skipping pull adwaita-qt (already ran)
Building adwaita-qt
+ snapcraftctl build
+ cmake /root/parts/adwaita-qt/src/ -G Ninja -DCMAKE_FIND_ROOT_PATH=/snap/kde-frameworks-5-qt-5-15-3-core20-sdk/current -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PkgConfig: /snap/kde-frameworks-5-qt-5-15-3-core20-sdk/current/usr/bin/pkg-config (found version "0.29.1")
-- Found XCB: /snap/kde-frameworks-5-qt-5-15-3-core20-sdk/current/usr/lib/x86_64-linux-gnu/libxcb.so (Required is at least version "1.10")
-- Configuring done
-- Generating done
-- Build files have been written to: /root/parts/adwaita-qt/build
+ cmake --build . -- -j2
[49/49] Linking CXX shared module src/style/adwaita.so
+ DESTDIR=/root/parts/adwaita-qt/install
+ cmake --build . --target install
[0/1] Install the project...
-- Install configuration: "Release"
-- Installing: /root/parts/adwaita-qt/install/lib/libadwaitaqtpriv.so.1.4.1
-- Installing: /root/parts/adwaita-qt/install/lib/libadwaitaqtpriv.so.1
-- Set runtime path of "/root/parts/adwaita-qt/install/lib/libadwaitaqtpriv.so.1.4.1" to ""
-- Installing: /root/parts/adwaita-qt/install/lib/libadwaitaqtpriv.so
-- Installing: /root/parts/adwaita-qt/install/lib/libadwaitaqt.so.1.4.1
-- Installing: /root/parts/adwaita-qt/install/lib/libadwaitaqt.so.1
-- Set runtime path of "/root/parts/adwaita-qt/install/lib/libadwaitaqt.so.1.4.1" to ""
-- Installing: /root/parts/adwaita-qt/install/lib/libadwaitaqt.so
-- Installing: /root/parts/adwaita-qt/install/include/AdwaitaQt/adwaita.h
-- Installing: /root/parts/adwaita-qt/install/include/AdwaitaQt/adwaitacolors.h
-- Installing: /root/parts/adwaita-qt/install/include/AdwaitaQt/adwaitarenderer.h
-- Installing: /root/parts/adwaita-qt/install/include/AdwaitaQt/adwaitaqt_export.h
-- Installing: /root/parts/adwaita-qt/install/lib/pkgconfig/adwaita-qt.pc
-- Installing: /root/parts/adwaita-qt/install/lib/cmake/AdwaitaQt/AdwaitaQtConfig.cmake
-- Installing: /root/parts/adwaita-qt/install/lib/cmake/AdwaitaQt/AdwaitaQtConfigVersion.cmake
-- Installing: /root/parts/adwaita-qt/install/lib/cmake/AdwaitaQt/AdwaitaQtTargets.cmake
-- Installing: /root/parts/adwaita-qt/install/lib/cmake/AdwaitaQt/AdwaitaQtTargets-release.cmake
-- Installing: /root/parts/adwaita-qt/install/snap/kde-frameworks-5-qt-5-15-3-core20-sdk/6/usr/lib/x86_64-linux-gnu/qt5/plugins/styles/adwaita.so
-- Set runtime path of "/root/parts/adwaita-qt/install/snap/kde-frameworks-5-qt-5-15-3-core20-sdk/6/usr/lib/x86_64-linux-gnu/qt5/plugins/styles/adwaita.so" to ""
Staging adwaita-qt
+ snapcraftctl stage
Pulling qgnomeplatform
+ snapcraftctl pull
Cloning into '/root/parts/qgnomeplatform/src'...
remote: Enumerating objects: 37, done.
remote: Counting objects: 100% (37/37), done.
remote: Compressing objects: 100% (32/32), done.
remote: Total 37 (delta 6), reused 15 (delta 2), pack-reused 0
Unpacking objects: 100% (37/37), 45.13 KiB | 1.74 MiB/s, done.
Note: switching to '71da0a5d29ecf0503532148105f6ee509e635c73'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:
git switch -c <new-branch-name>
Or undo this operation with:
git switch -
Turn off this advice by setting config variable advice.detachedHead to false
Skipping build adwaita-qt (already ran)
Building qgnomeplatform
+ snapcraftctl build
+ cmake /root/parts/qgnomeplatform/src/ -G Ninja -DCMAKE_FIND_ROOT_PATH=/snap/kde-frameworks-5-qt-5-15-3-core20-sdk/current -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Found PkgConfig: /snap/kde-frameworks-5-qt-5-15-3-core20-sdk/current/usr/bin/pkg-config (found version "0.29.1")
-- Checking for module 'glib-2.0'
-- Found glib-2.0, version 2.64.6
-- Found GSettingSchemas: TRUE
CMake Error at /root/stage/lib/cmake/AdwaitaQt/AdwaitaQtTargets.cmake:80 (message):
The imported target "adwaitaqtpriv" references the file
"/lib/libadwaitaqtpriv.so.1.4.1"
but this file does not exist. Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
"/root/stage/lib/cmake/AdwaitaQt/AdwaitaQtTargets.cmake"
but not all the files it references.
Call Stack (most recent call first):
/root/stage/lib/cmake/AdwaitaQt/AdwaitaQtConfig.cmake:44 (include)
CMakeLists.txt:50 (find_package)
-- Configuring incomplete, errors occurred!
See also "/root/parts/qgnomeplatform/build/CMakeFiles/CMakeOutput.log".
See also "/root/parts/qgnomeplatform/build/CMakeFiles/CMakeError.log".
Failed to build 'qgnomeplatform'.
Recommended resolution:
Check the build logs and ensure the part's configuration and sources are correct.
With the blank prefix it ends up installing to $SNAPCRAFT_STAGE/lib but as before, QGnomePlatform expects it to exist under /lib
That seems a problem with the way QGnomePlataform configures its project. You might try digging into CMake files trying to find where exactly it references this lib, and sed your way out of this.
That can be a PITA though, CMake seems very confusing to me (I really dislike it, but it seems to get the job done, since everybody uses it).
@ivo.cavalcante I suspect you’re right with the configuration issue lying with adwaita-qt/qgnomeplatform as in my content snap I’ve managed to use cmake parts, which are dependent on previous cmake parts. Was hoping there might be a more elegant way as opposed to using sed or rsync to move the libs to the system location.
@ppd Thanks for the suggestion, I had to make a slight tweak as one of the install paths was
which aside from looking incorrect also resulted in an error trying to write to a read-only location. Similarly when this part is included in my content snap it installs to
Not too sure why this happens, but basically had to correct that path:
override-build: |
snapcraftctl build
rsync -a --ignore-existing $SNAPCRAFT_PART_INSTALL/root/stage/ $SNAPCRAFT_PART_INSTALL
rm -rf $SNAPCRAFT_PART_INSTALL/root
rsync -a --ignore-existing $SNAPCRAFT_PART_INSTALL/ /
The resulting snap successfully allows QGnomePlatform to be used by my Qt snaps. Thanks for the assistance.
On a side note related to QGnomePlatform it looks like it doesn’t use desktop portals so might not be all that of an upgrade at the moment (perhaps a code change needed in Qt itself so it’s aware QT_QPA_PLATFORMTHEME='gnome'?).
It looks like it does use portal dialogs, doesn’t it?
Btw., what do you want to do with this? Ship QGnomePlatform inside a snap that uses kde-neon? Because we could probably include this in the platform snap itself if @jriddell doesn’t mind.
I did end up giving this a go yesterday, and I can confirm that I did get a snap to be produced but I would still have to do some reorganising manually for adwaita.so in the Adwaita-qt part and libqgnomeplatformtheme.so in the QGnomePlatform part as they still get installed under $SNAPCRAFT_PART_INSTALL/root/stage.
Hmm judging by the code it definitely looks like it should be using portals for the file chooser but this isn’t my experience. The file chooser doesn’t allow me access to removable drives indicating it’s not using portals. Being on GNOME I usually see the current application change to “Portal” which does not happen in my case.
The reason I want to include this within my content snap is so that Qt applications integrate better with the GNOME desktop. I also have plasma-integration included in the snap providing KDEPlasmaPlatformTheme.so as a platformtheme for good integration with KDE (the kde content snap also includes this). When using Qt apps from Flathub, of the selection I’ve used, they ususally use QGnomePlatform. Ideally I would use the content snap provided by the kde-neon extension, but it’s due to lacking certain libs for GNOME like QGnomePlatform and librsvg2 (problem related to this explained here) that have prevented me from adopting it as they don’t look at home on GNOME/GTK desktop environments.
If you set QT_PLUGIN_PATH right for your app (= first this qgnomeplatform snap path, then the KDE framework path), it should find QGnomePlatform and do the right thing. As a matter of fact, I know the kde-neon extension sets this plugin path correctly to first look in the snap itself. So you shouldn’t have to do anything in this case.
You can easily tell by enabling looking glass with alt + f2 (run a command) and running “lg”.
There’s a “Windows” tab that should display something like this for an app that uses the portal:
Ah didn’t realise in your adapted yaml you set DQT_PLUGINS_DIR=/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/qt5/plugins which ended up placing adwaita.so and libqgnomeplatformtheme.so under the correct location, didn’t see this parameter documented in the qgnomeplatform repo.
Portals ended up working correctly when I didn’t set QT_QPA_PLATFORMTHEME manually.