Hi,
I am building the NetworkManagerQt package inside a Yocto project.
NetworkMangagerQt creates a file called KF5NetworkManagerQtTargets.cmake
using
the following command inside a CMakeLists.txt
file:
install(EXPORT KF5NetworkManagerQtTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE KF5NetworkManagerQtTargets.cmake NAMESPACE KF5:: )
This exported cmake-file contains absolute paths:
...
set_target_properties(KF5::NetworkManagerQt PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include/KF5/NetworkManagerQt;
/home/holger/data/Yocto/yocto-yoe/build/tmp/work/core2-32-ks-linux/networkmanager-qt/5.31.0-r0/recipe-sysroot/usr/include/libnm;
/home/holger/data/Yocto/yocto-yoe/build/tmp/work/core2-32-ks-linux/networkmanager-qt/5.31.0-r0/recipe-sysroot/usr/include/libmount;
/home/holger/data/Yocto/yocto-yoe/build/tmp/work/core2-32-ks-linux/networkmanager-qt/5.31.0-r0/recipe-sysroot/usr/include/blkid;
/home/holger/data/Yocto/yocto-yoe/build/tmp/work/core2-32-ks-linux/networkmanager-qt/5.31.0-r0/recipe-sysroot/usr/include/glib-2.0;
/home/holger/data/Yocto/yocto-yoe/build/tmp/work/core2-32-ks-linux/networkmanager-qt/5.31.0-r0/recipe-sysroot/usr/lib/glib-2.0/include;
${_IMPORT_PREFIX}/include/KF5"
INTERFACE_LINK_LIBRARIES "Qt5::Core;Qt5::Network;Qt5::DBus"
)
...
(The absolute path in question is /home/holger/data/Yocto/yocto-yoe/build/tmp/work/core2-32-ks-linux/networkmanager-qt/5.31.0-r0/recipe-sysroot/
).
This absolute path makes it impossible to use Yocto’s shared state cache
feature, since at the point when the cache is re-used the old working copy to
which the absolute paths point to may no longer be there.
A better approach would be to use the CMAKE_SYSROOT
variable, like so:
set_target_properties(KF5::NetworkManagerQt PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include/KF5/NetworkManagerQt;
${CMAKE_SYSROOT}/usr/include/libnm;
${CMAKE_SYSROOT}/usr/include/libmount;
${CMAKE_SYSROOT}/usr/include/blkid;
${CMAKE_SYSROOT}/usr/include/glib-2.0;
${CMAKE_SYSROOT}/usr/lib/glib-2.0/include;
${_IMPORT_PREFIX}/include/KF5"
INTERFACE_LINK_LIBRARIES "Qt5::Core;Qt5::Network;Qt5::DBus"
)
Can this change be achieved in a clean way without patching CMake?
(Patching NetworkManagerQt would be ok, though).
Best,
Holger