From cd2f66b9aa12455b914952c5c61518490d0c172d Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Tue, 15 Dec 2020 21:40:27 +0000 Subject: Define relative paths when KDE_INSTALL_USE_QT_SYS_PATHS is enabled When building multiple KDE projects, installing them to "$DESTDIR" and having cmake look for kde dependencies in "$DESTDIR" using "CMAKE_PREFIX_PATH=$DESTDIR/usr", we currently get failures when calling find_package() on projects that use KDE_INSTALL_QTPLUGINDIR, KDE_INSTALL_QTQMLDIR and KDE_INSTALL_QTQUICKIMPORTSDIR because these are defined as absolute paths when KDE_INSTALL_USE_QT_SYS_PATHS is enabled. This commit defines these paths relative to qmake's QT_INSTALL_PREFIX property instead when KDE is install to the same prefix as Qt. This fixes DESTDIR installations because with relative paths, CMake will search for these paths in "$DESTDIR" as well as "/". We limit this change to the scenario where the Qt and CMake install prefixes are the same because always doing this would break backwards compatibility as qml and plugins would be installed into CMAKE_INSTALL_PREFIX instead of QT_INSTALL_PREFIX after this change. --- modules/ECMGeneratePriFile.cmake | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'modules/ECMGeneratePriFile.cmake') diff --git a/modules/ECMGeneratePriFile.cmake b/modules/ECMGeneratePriFile.cmake index f63a0ce2..22c88183 100644 --- a/modules/ECMGeneratePriFile.cmake +++ b/modules/ECMGeneratePriFile.cmake @@ -89,7 +89,11 @@ endif() if(KDE_INSTALL_USE_QT_SYS_PATHS OR _askqmake) include(ECMQueryQmake) + query_qmake(qt_install_prefix_dir QT_INSTALL_PREFIX TRY) query_qmake(qt_host_data_dir QT_HOST_DATA) + if(qt_install_prefix_dir STREQUAL "${CMAKE_INSTALL_PREFIX}") + file(RELATIVE_PATH qt_host_data_dir ${qt_install_prefix_dir} ${qt_host_data_dir}) + endif() set(ECM_MKSPECS_INSTALL_DIR ${qt_host_data_dir}/mkspecs/modules CACHE PATH "The directory where mkspecs will be installed to.") else() set(ECM_MKSPECS_INSTALL_DIR mkspecs/modules CACHE PATH "The directory where mkspecs will be installed to.") -- cgit v1.2.1