SUMMARY I am trying to migrate a Kate plugin from Qt5.15.* to 6.1. The CMakeLists.txt is calling kcoreaddons_add_plugin(my_plugin_name INSTALL_NAMESPACE "ktexteditor"), which with Qt6 builds the sources but fails upon linking because it is trying to link not in the build folder but in /INSTALL_NAMESPACE, i.e. in /ktexteditor (For Qt6 the install namespace should be kf6/ktexteditor). STEPS TO REPRODUCE In $project_dir I run: rm -rf build/ cmake -B build/ -D CMAKE_BUILD_TYPE=Release -D QT_MAJOR_VERSION=6 (or 5) cmake --build build/ This is working fine with Qt5 and will create ./build/plugin_name.so in the build folder. A subsequent sudo cmake --install build/ would then copy the plugin .so to /usr/lib/qt/plugins/ktexteditor/ With Qt6 I am getting a linker error: cmake --build build/ [......] [ 85%] Linking CXX shared module /kf6/ktexteditor/my_plugin.so /usr/bin/ld: cannot open output file /kf6/ktexteditor/my_plugin.so: No such file or directory collect2: error: ld returned 1 exit status make[2]: *** [CMakeFiles/my_plugin.dir/build.make:153: /kf6/ktexteditor/my_plugin.so] Error 1 make[1]: *** [CMakeFiles/Makefile2:653: CMakeFiles/my_plugin.dir/all] Error 2 make: *** [Makefile:146: all] Error 2 OBSERVED RESULT cmake --build build/ attempts to link the plugin .so in /kf6/ktexteditor/ EXPECTED RESULT cmake --build build/ should link the plugin .so in ./build/ SOFTWARE/OS VERSIONS Linux/KDE Plasma: Manjaro KDE Plasma Version: 6.0.4 KDE Frameworks Version: 6.1.0 Qt Version: 6.7.0 ADDITIONAL INFORMATION
Can you show your full project sources?
(In reply to Nicolas Fella from comment #1) > Can you show your full project sources? Sure. Here you go: https://github.com/dennis2society/kate-gpg-plugin I have been digging through the KF6CoreAddonsMacro.cmake and see that the CMAKE_LIBRARY_OUTPUT_DIRECTORY is empty, which in line 62 is prepended to /INSTALL_NAMESPACE. This obviously leads to the /kf6/ktexteditor output path.
In https://github.com/dennis2society/kate-gpg-plugin/commit/609bd6d2634862459d13f61825a4e1bdcbad4944 you removed the version from the find_package(ECM) call. This changed the condition in https://invent.kde.org/frameworks/extra-cmake-modules/-/blob/master/kde-modules/KDECMakeSettings.cmake#L253 and causes CMAKE_LIBRARY_OUTPUT_DIRECTORY to be empty
Thanks for the hint. I have restored the find_package(ECM...) line to its previous state but linking is still attempted in /INSTALL_NAMESPACE.
Is KF5_DEP_VERSION set at this point? What if you specify e.g. 6.0 as version?
Yes. I have tried putting it higher in the CMakeLists and setting a specific version (i.e. 6.0) but without any effect.
Thanks Nicolas for giving the correct hint! I could solve it by moving the line set(KF_DEP_VERSION "${QT_MAJOR_VERSION}") almost to the very top of the file. With this I can now build my plugin with both Qt5 and Qt6. I am closing the bug report because the change for the link/output path was probably intentional instead of a bug. However I am still curious why the Qt5 build links the binary in ./build/ while Qt6 creates the library in ./build/bin/kf6/ktexteditor/ Is there any reason why this was changed?