aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaan De Meyer <daan.j.demeyer@gmail.com>2020-12-15 21:40:27 +0000
committerAleix Pol Gonzalez <aleixpol@kde.org>2021-02-08 14:31:43 +0000
commitcd2f66b9aa12455b914952c5c61518490d0c172d (patch)
treec2bdc3491f2bf93706dcc003af2bd0a51a1180e0
parent73c16740d2629cd03f9b9081919a569d2aaa4af4 (diff)
downloadextra-cmake-modules-cd2f66b9aa12455b914952c5c61518490d0c172d.tar.gz
extra-cmake-modules-cd2f66b9aa12455b914952c5c61518490d0c172d.tar.bz2
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.
-rw-r--r--kde-modules/KDEInstallDirs.cmake10
-rw-r--r--modules/ECMGeneratePriFile.cmake4
2 files changed, 14 insertions, 0 deletions
diff --git a/kde-modules/KDEInstallDirs.cmake b/kde-modules/KDEInstallDirs.cmake
index bba3a9c8..8b332ff9 100644
--- a/kde-modules/KDEInstallDirs.cmake
+++ b/kde-modules/KDEInstallDirs.cmake
@@ -469,20 +469,30 @@ endif()
option (KDE_INSTALL_USE_QT_SYS_PATHS "Install mkspecs files, QCH files for Qt-based libs, Plugins and Imports to the Qt 5 install dir" "${_default_KDE_INSTALL_USE_QT_SYS_PATHS}")
if(KDE_INSTALL_USE_QT_SYS_PATHS)
# Qt-specific vars
+ query_qmake(qt_install_prefix_dir QT_INSTALL_PREFIX TRY)
query_qmake(qt_plugins_dir QT_INSTALL_PLUGINS)
+ if(qt_install_prefix_dir STREQUAL "${CMAKE_INSTALL_PREFIX}")
+ file(RELATIVE_PATH qt_plugins_dir ${qt_install_prefix_dir} ${qt_plugins_dir})
+ endif()
_define_absolute(QTPLUGINDIR ${qt_plugins_dir}
"Qt plugins"
QT_PLUGIN_INSTALL_DIR)
query_qmake(qt_imports_dir QT_INSTALL_IMPORTS)
+ if(qt_install_prefix_dir STREQUAL "${CMAKE_INSTALL_PREFIX}")
+ file(RELATIVE_PATH qt_imports_dir ${qt_install_prefix_dir} ${qt_imports_dir})
+ endif()
_define_absolute(QTQUICKIMPORTSDIR ${qt_imports_dir}
"QtQuick1 imports"
IMPORTS_INSTALL_DIR)
query_qmake(qt_qml_dir QT_INSTALL_QML)
+ if(qt_install_prefix_dir STREQUAL "${CMAKE_INSTALL_PREFIX}")
+ file(RELATIVE_PATH qt_qml_dir ${qt_install_prefix_dir} ${qt_qml_dir})
+ endif()
_define_absolute(QMLDIR ${qt_qml_dir}
"QtQuick2 imports"
QML_INSTALL_DIR)
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.")