From c5a034a6b5218ebc9f7eb38387c9d91fa3e4134d Mon Sep 17 00:00:00 2001 From: Volker Krause Date: Mon, 22 Mar 2021 15:38:36 +0200 Subject: Split KDEInstallDirs into a 5 and a 6 variant This factors out large parts of the common code into separate modules, and adds a backward compatibility wrapper. The 6 variant drops some deprecated variables where possible, but otherwise is the same as the 5 variant. It still lacks a replacement for the paths depending on ECMQueryQMake though. --- kde-modules/KDEInstallDirs6.cmake | 332 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 332 insertions(+) create mode 100644 kde-modules/KDEInstallDirs6.cmake (limited to 'kde-modules/KDEInstallDirs6.cmake') diff --git a/kde-modules/KDEInstallDirs6.cmake b/kde-modules/KDEInstallDirs6.cmake new file mode 100644 index 00000000..e0e03c10 --- /dev/null +++ b/kde-modules/KDEInstallDirs6.cmake @@ -0,0 +1,332 @@ +# SPDX-FileCopyrightText: 2014-2015 Alex Merry +# SPDX-FileCopyrightText: 2013 Stephen Kelly +# SPDX-FileCopyrightText: 2012 David Faure +# SPDX-FileCopyrightText: 2007 Matthias Kretz +# SPDX-FileCopyrightText: 2006-2007 Laurent Montel +# SPDX-FileCopyrightText: 2006-2013 Alex Neundorf +# SPDX-FileCopyrightText: 2021 Volker Krause +# +# SPDX-License-Identifier: BSD-3-Clause + +#[=======================================================================[.rst: +KDEInstallDirs6 +--------------- + +Define KDE standard installation directories for Qt6/KF6 based software. + +Note that none of the variables defined by this module provide any +information about the location of already-installed KDE software. + +Also sets ``CMAKE_INSTALL_PREFIX`` to the installation prefix of ECM, +unless that variable has been already explicitly set by something else. + +Inclusion of this module defines the following variables: + +``KDE_INSTALL_`` + destination for files of a given type +``KDE_INSTALL_FULL_`` + corresponding absolute path + +where ```` is one of (default values in parentheses and alternative, +deprecated variable name in square brackets): + +``BUNDLEDIR`` + application bundles (``/Applications/KDE``) [``BUNDLE_INSTALL_DIR``] +``EXECROOTDIR`` + executables and libraries (````) [``EXEC_INSTALL_PREFIX``] +``BINDIR`` + user executables (``EXECROOTDIR/bin``) [``BIN_INSTALL_DIR``] +``SBINDIR`` + system admin executables (``EXECROOTDIR/sbin``) [``SBIN_INSTALL_DIR``] +``LIBDIR`` + object code libraries (``EXECROOTDIR/lib``, ``EXECROOTDIR/lib64`` or + ``EXECROOTDIR/lib/`` variables (or their ``CMAKE_INSTALL_`` or +deprecated counterparts) may be passed to the DESTINATION options of +``install()`` commands for the corresponding file type. They are set in the +CMake cache, and so the defaults above can be overridden by users. + +Note that the ``KDE_INSTALL_``, ``CMAKE_INSTALL_`` or deprecated +form of the variable can be changed using CMake command line variable +definitions; in either case, all forms of the variable will be affected. The +effect of passing multiple forms of the same variable on the command line +(such as ``KDE_INSTALL_BINDIR`` and ``CMAKE_INSTALL_BINDIR`` is undefined. + +The variable ``KDE_INSTALL_TARGETS_DEFAULT_ARGS`` is also defined (along with +the deprecated form ``INSTALL_TARGETS_DEFAULT_ARGS``). This should be used +when libraries or user-executable applications are installed, in the +following manner: + +.. code-block:: cmake + + install(TARGETS mylib myapp ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) + +It MUST NOT be used for installing plugins, system admin executables or +executables only intended for use internally by other code. Those should use +``KDE_INSTALL_PLUGINDIR``, ``KDE_INSTALL_SBINDIR`` or +``KDE_INSTALL_LIBEXECDIR`` respectively. + +Additionally, ``CMAKE_INSTALL_DEFAULT_COMPONENT_NAME`` will be set to +``${PROJECT_NAME}`` to provide a sensible default for this CMake option. + +Note that mixing absolute and relative paths, particularly for ``BINDIR``, +``LIBDIR`` and ``INCLUDEDIR``, can cause issues with exported targets. Given +that the default values for these are relative paths, relative paths should +be used on the command line when possible (eg: use +``-DKDE_INSTALL_LIBDIR=lib64`` instead of +``-DKDE_INSTALL_LIBDIR=/usr/lib/lib64`` to override the library directory). + +Since 5.82.0. + +The ``KDE_INSTALL_PREFIX_SCRIPT`` option will install a ${CMAKE_INSTALL_PREFIX}/prefix.sh +file that allows to easily incorporate the necessary environment variables +for the prefix into a process. +#]=======================================================================] + + +include(${CMAKE_CURRENT_LIST_DIR}/KDEInstallDirsCommon.cmake) + +if(WIN32) + _define_non_cache(LIBEXECDIR_KF6 "${CMAKE_INSTALL_LIBEXECDIR}") +else() + _define_non_cache(LIBEXECDIR_KF6 "${CMAKE_INSTALL_LIBEXECDIR}/kf6") +endif() + +# TODO TODO TODO +#include("${ECM_MODULE_DIR}/ECMQueryQmake.cmake") + +set(_default_KDE_INSTALL_USE_QT_SYS_PATHS OFF) +if(NOT DEFINED KDE_INSTALL_USE_QT_SYS_PATHS) + query_qmake(qt_install_prefix_dir QT_INSTALL_PREFIX TRY) + if(qt_install_prefix_dir STREQUAL "${CMAKE_INSTALL_PREFIX}") + message(STATUS "Installing in the same prefix as Qt, adopting their path scheme.") + set(_default_KDE_INSTALL_USE_QT_SYS_PATHS ON) + endif() +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}") +# TODO TODO TODO +#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_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) +#else() + set(_pluginsDirParent LIBDIR) + if (ANDROID) + set(_pluginsDirParent) + #androiddeployqt wants plugins right in the prefix + endif() + _define_relative(QTPLUGINDIR "${_pluginsDirParent}" "plugins" + "Qt plugins" + QT_PLUGIN_INSTALL_DIR) + + _define_relative(QMLDIR LIBDIR "qml" + "QtQuick2 imports" + QML_INSTALL_DIR) +#endif() + +_define_non_cache(INCLUDEDIR_KF6 "${CMAKE_INSTALL_INCLUDEDIR}/KF6") + +_define_non_cache(DATADIR_KF5 "${CMAKE_INSTALL_DATADIR}/kf6") + +# TODO TODO TODO +# Qt-specific data vars +#if(KDE_INSTALL_USE_QT_SYS_PATHS) +# query_qmake(qt_docs_dir QT_INSTALL_DOCS) +# +# _define_absolute(QTQCHDIR ${qt_docs_dir} +# "documentation bundles in QCH format for Qt-extending libraries") +#else() + _define_relative(QTQCHDIR DATAROOTDIR "doc/qch" + "documentation bundles in QCH format for Qt-extending libraries") +#endif() + + +# KDE Framework-specific things +_define_relative(KSERVICES6DIR DATAROOTDIR "kservices6" + "services for KDE Frameworks 6" + SERVICES_INSTALL_DIR) +_define_relative(KSERVICETYPES6DIR DATAROOTDIR "kservicetypes6" + "service types for KDE Frameworks 6" + SERVICETYPES_INSTALL_DIR) +_define_relative(KNOTIFY6RCDIR DATAROOTDIR "knotifications6" + "knotify description files" + KNOTIFYRC_INSTALL_DIR) +_define_relative(KXMLGUI6DIR DATAROOTDIR "kxmlgui6" + "kxmlgui .rc files" + KXMLGUI_INSTALL_DIR) +_define_relative(LOGGINGCATEGORIESDIR DATAROOTDIR "qlogging-categories6" + "Qt Logging categories files") + + +# For more documentation see above. +# Later on it will be possible to extend this for installing OSX frameworks +# The COMPONENT Devel argument has the effect that static libraries belong to the +# "Devel" install component. If we use this also for all install() commands +# for header files, it will be possible to install +# -everything: make install OR cmake -P cmake_install.cmake +# -only the development files: cmake -DCOMPONENT=Devel -P cmake_install.cmake +# -everything except the development files: cmake -DCOMPONENT=Unspecified -P cmake_install.cmake +# This can then also be used for packaging with cpack. +# FIXME: why is INCLUDES (only) set for ARCHIVE targets? +set(KF6_INSTALL_TARGETS_DEFAULT_ARGS RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT Devel + INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR_KF6}" +) + +# on the Mac support an extra install directory for application bundles +if(APPLE) + set(KF6_INSTALL_TARGETS_DEFAULT_ARGS ${KF6_INSTALL_TARGETS_DEFAULT_ARGS} + BUNDLE DESTINATION "${BUNDLE_INSTALL_DIR}" ) +endif() + +include(${CMAKE_CURRENT_LIST_DIR}/KDESetupPrefixScript.cmake) -- cgit v1.2.1