I am including a KF5 header (#include <KXmlGui/KXMLGUIClient>
) and while KDevelop gives me info about this header when I hover the directive, GCC by no means can find this and other (very few and random) KF5 headers.
I am using CMake and I used the api.kde.org to find (and link against) every needed module for every header. I can't figure this out.
[ 5%] Building CXX object src/CMakeFiles/test_ktechlab.dir/ktechlab.cpp.o
cd /mnt/Volume_3/Gentoo/projects/ktechlab/build/src && /usr/bin/c++ -DQT_CORE_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -I/mnt/Volume_3/Gentoo/projects/ktechlab/build/src -I/mnt/Volume_3/Gentoo/projects/ktechlab/src -I/mnt/Volume_3/Gentoo/projects/ktechlab/build/src/test_ktechlab_autogen/include -I/mnt/Volume_3/Gentoo/projects/ktechlab/ON -I/mnt/Volume_3/Gentoo/projects/ktechlab/build -I/mnt/Volume_3/Gentoo/projects/ktechlab/build/src/core -I/mnt/Volume_3/Gentoo/projects/ktechlab/src/core -I/mnt/Volume_3/Gentoo/projects/ktechlab/src/drawparts -I/mnt/Volume_3/Gentoo/projects/ktechlab/src/electronics -I/mnt/Volume_3/Gentoo/projects/ktechlab/src/electronics/components -I/mnt/Volume_3/Gentoo/projects/ktechlab/src/electronics/simulation -I/mnt/Volume_3/Gentoo/projects/ktechlab/src/flowparts -I/mnt/Volume_3/Gentoo/projects/ktechlab/src/gui -I/mnt/Volume_3/Gentoo/projects/ktechlab/build/src/gui -I/mnt/Volume_3/Gentoo/projects/ktechlab/src/gui/itemeditor -I/mnt/Volume_3/Gentoo/projects/ktechlab/src/languages -I/mnt/Volume_3/Gentoo/projects/ktechlab/src/mechanics -I/mnt/Volume_3/Gentoo/projects/ktechlab/src/micro -I/usr/include/qt5 -I/usr/include/qt5/QtCore -I/usr/lib64/qt5/mkspecs/linux-g++ -I/usr/include/qt5/QtGui -I/usr/include/qt5/QtWidgets -I/usr/include/gpsim -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -std=c++0x -fno-operator-names -fno-exceptions -Wall -Wextra -Wcast-align -Wchar-subscripts -Wformat-security -Wno-long-long -Wpointer-arith -Wundef -Wnon-virtual-dtor -Woverloaded-virtual -Werror=return-type -Wvla -Wdate-time -Wsuggest-override -Wlogical-op -fPIC -g -fvisibility=hidden -fvisibility-inlines-hidden -fno-inline -o CMakeFiles/test_ktechlab.dir/ktechlab.cpp.o -c /mnt/Volume_3/Gentoo/projects/ktechlab/src/ktechlab.cpp
make[2]: Leaving directory '/mnt/Volume_3/Gentoo/projects/ktechlab/build'
make[1]: Leaving directory '/mnt/Volume_3/Gentoo/projects/ktechlab/build'
/mnt/Volume_3/Gentoo/projects/ktechlab/src/ktechlab.cpp:12:10: fatal error: KXmlGui/KXMLGUIClient: No such file or directory
#include <KXmlGui/KXMLGUIClient>
^~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [src/CMakeFiles/test_ktechlab.dir/build.make:79: src/CMakeFiles/test_ktechlab.dir/ktechlab.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:279: src/CMakeFiles/test_ktechlab.dir/all] Error 2
make: *** [Makefile:144: all] Error 2
*** Failure: Exit code 2 ***
Any ideas?
You will have to
XmlGui
as a component in your find_package
command.KF5::XmlGui
in target_link_libraries
for the target in question.If you're wondering, why target_link_libraries
affects your include path, you're not alone - but that is the way it works.