Cross compiling Qt6.2 with dbus/cmake build fails with 'Imported target "dbus-1" includes non-existent path'
Qt6 has been switched to the cmake build system and compiling a mingw build with the dbus 1.13.18 development package generated by the cmake build system fails with the following error:
[ 34s] CMake Error in src/dbus/CMakeLists.txt:
[ 34s] Imported target "dbus-1" includes non-existent path
[ 34s]
[ 34s] "/usr/i686-w64-mingw32/sys-root/mingw//usr/i686-w64-mingw32/sys-root/mingw/lib/dbus-1.0/include"
[ 34s]
[ 34s] in its INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:
[ 34s]
[ 34s] * The path was deleted, renamed, or moved to another location.
[ 34s]
[ 34s] * An install or uninstall procedure did not complete successfully.
[ 34s]
[ 34s] * The installation package was faulty and references files it does not
[ 34s] provide.
[ 34s]
[ 34s]
[ 34s]
The reason for this is that on https://gitlab.freedesktop.org/dbus/dbus/-/blob/master/cmake/DBus1Config.cmake.in#L29 two possibly absolute paths are linked.
It is recommended to leave the creation of the resulting paths to cmake. This can be realized with the target_include_directories
command and the use of the INSTALL_INTERFACE
as shown below
target_include_directories(dbus-1
INTERFACE
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/dbus-1.0>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_LIBDIR}/dbus-1.0/include>
)