Warning, /frameworks/extra-cmake-modules/kde-modules/KDEInstallDirsCommon.cmake is written in an unsupported language. File is not indexed.
0001 # SPDX-FileCopyrightText: 2014-2015 Alex Merry <alex.merry@kde.org> 0002 # SPDX-FileCopyrightText: 2013 Stephen Kelly <steveire@gmail.com> 0003 # SPDX-FileCopyrightText: 2012 David Faure <faure@kde.org> 0004 # SPDX-FileCopyrightText: 2007 Matthias Kretz <kretz@kde.org> 0005 # SPDX-FileCopyrightText: 2006-2007 Laurent Montel <montel@kde.org> 0006 # SPDX-FileCopyrightText: 2006-2013 Alex Neundorf <neundorf@kde.org> 0007 # 0008 # SPDX-License-Identifier: BSD-3-Clause 0009 # 0010 # Common implementation details of KDEInstallDirsX.cmake, not public API. 0011 # 0012 0013 # Figure out what the default install directory for libraries should be. 0014 # This is based on the logic in GNUInstallDirs, but simplified (the 0015 # GNUInstallDirs code deals with re-configuring, but that is dealt with 0016 # by the _define_* macros in this module). 0017 set(_LIBDIR_DEFAULT "lib") 0018 # Override this default 'lib' with 'lib64' if: 0019 # - we are on a Linux, kFreeBSD or Hurd system but NOT cross-compiling 0020 # - we are NOT on debian 0021 # - we are NOT on flatpak 0022 # - we are NOT on NixOS 0023 # - we are on a 64 bits system 0024 # reason is: amd64 ABI: https://gitlab.com/x86-psABIs/x86-64-ABI/-/jobs/artifacts/master/raw/x86-64-ABI/abi.pdf?job=build 0025 # For Debian with multiarch, use 'lib/${CMAKE_LIBRARY_ARCHITECTURE}' if 0026 # CMAKE_LIBRARY_ARCHITECTURE is set (which contains e.g. "i386-linux-gnu" 0027 # See https://wiki.debian.org/Multiarch 0028 if((CMAKE_SYSTEM_NAME MATCHES "Linux|kFreeBSD" OR CMAKE_SYSTEM_NAME STREQUAL "GNU") 0029 AND NOT CMAKE_CROSSCOMPILING 0030 AND NOT EXISTS "/etc/arch-release" 0031 AND NOT DEFINED ENV{FLATPAK_ID} 0032 AND NOT EXISTS "/etc/NIXOS") 0033 if (EXISTS "/etc/debian_version") # is this a debian system ? 0034 if(CMAKE_LIBRARY_ARCHITECTURE) 0035 set(_LIBDIR_DEFAULT "lib/${CMAKE_LIBRARY_ARCHITECTURE}") 0036 endif() 0037 else() # not debian, rely on CMAKE_SIZEOF_VOID_P: 0038 if(NOT DEFINED CMAKE_SIZEOF_VOID_P) 0039 message(AUTHOR_WARNING 0040 "Unable to determine default LIB_INSTALL_LIBDIR directory because no target architecture is known. " 0041 "Please enable at least one language before including KDEInstallDirs.") 0042 else() 0043 if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") 0044 set(_LIBDIR_DEFAULT "lib64") 0045 endif() 0046 endif() 0047 endif() 0048 endif() 0049 0050 set(_gnu_install_dirs_vars 0051 BINDIR 0052 SBINDIR 0053 LIBEXECDIR 0054 SYSCONFDIR 0055 SHAREDSTATEDIR 0056 LOCALSTATEDIR 0057 LIBDIR 0058 INCLUDEDIR 0059 OLDINCLUDEDIR 0060 DATAROOTDIR 0061 DATADIR 0062 INFODIR 0063 LOCALEDIR 0064 MANDIR 0065 DOCDIR) 0066 0067 # Macro for variables that are relative to another variable. We store an empty 0068 # value in the cache (for documentation/GUI cache editor purposes), and store 0069 # the default value in a local variable. If the cache variable is ever set to 0070 # something non-empty, the local variable will no longer be set. However, if 0071 # the cache variable remains (or is set to be) empty, the value will be 0072 # relative to that of the parent variable. 0073 # 0074 # varname: the variable name suffix (eg: BINDIR for KDE_INSTALL_BINDIR) 0075 # parent: the variable suffix of the variable this is relative to 0076 # (eg: DATAROOTDIR for KDE_INSTALL_DATAROOTDIR) 0077 # subdir: the path of the default value of KDE_INSTALL_${varname} 0078 # relative to KDE_INSTALL_${parent}: no leading / 0079 # docstring: documentation about the variable (not including the default value) 0080 # oldstylename (optional): the old-style name of the variable 0081 # alias (optional): alias for the variable (e.g. without '5' in the name) 0082 macro(_define_relative varname parent subdir docstring) 0083 set(_oldstylename) 0084 if(NOT KDE_INSTALL_DIRS_NO_DEPRECATED AND ${ARGC} GREATER 4) 0085 set(_oldstylename "${ARGV4}") 0086 endif() 0087 set(_aliasname) 0088 if(${ARGC} GREATER 5) 0089 set(_aliasname "${ARGV5}") 0090 endif() 0091 set(_cmakename) 0092 if(NOT KDE_INSTALL_DIRS_NO_CMAKE_VARIABLES) 0093 list(FIND _gnu_install_dirs_vars "${varname}" _list_offset) 0094 set(_cmakename_is_deprecated FALSE) 0095 if(NOT KDE_INSTALL_DIRS_NO_DEPRECATED OR NOT _list_offset EQUAL -1) 0096 set(_cmakename CMAKE_INSTALL_${varname}) 0097 if(_list_offset EQUAL -1) 0098 set(_cmakename_is_deprecated TRUE) 0099 endif() 0100 endif() 0101 endif() 0102 0103 # Surprisingly complex logic to deal with joining paths. 0104 # Note that we cannot use arg vars directly in if() because macro args are 0105 # not proper variables. 0106 set(_parent "${parent}") 0107 set(_subdir "${subdir}") 0108 if(_parent AND _subdir) 0109 set(_docpath "${_parent}/${_subdir}") 0110 if(KDE_INSTALL_${_parent}) 0111 set(_realpath "${KDE_INSTALL_${_parent}}/${_subdir}") 0112 else() 0113 set(_realpath "${_subdir}") 0114 endif() 0115 elseif(_parent) 0116 set(_docpath "${_parent}") 0117 set(_realpath "${KDE_INSTALL_${_parent}}") 0118 else() 0119 set(_docpath "${_subdir}") 0120 set(_realpath "${_subdir}") 0121 endif() 0122 0123 if(KDE_INSTALL_${varname}) 0124 # make sure the cache documentation is set correctly 0125 get_property(_iscached CACHE KDE_INSTALL_${varname} PROPERTY VALUE SET) 0126 if (_iscached) 0127 # make sure the docs are still set if it was passed on the command line 0128 set_property(CACHE KDE_INSTALL_${varname} 0129 PROPERTY HELPSTRING "${docstring} (${_docpath})") 0130 # make sure the type is correct if it was passed on the command line 0131 set_property(CACHE KDE_INSTALL_${varname} 0132 PROPERTY TYPE PATH) 0133 endif() 0134 elseif(${_oldstylename}) 0135 message(DEPRECATION "${_oldstylename} is deprecated, use KDE_INSTALL_${varname} instead.") 0136 # The old name was given (probably on the command line): move 0137 # it to the new name 0138 set(KDE_INSTALL_${varname} "${${_oldstylename}}" 0139 CACHE PATH 0140 "${docstring} (${_docpath})" 0141 FORCE) 0142 elseif(${_aliasname}) 0143 # The alias variable was given (probably on the command line): move 0144 # it to the new name 0145 set(KDE_INSTALL_${varname} "${${_aliasname}}" 0146 CACHE PATH 0147 "${docstring} (${_docpath})" 0148 FORCE) 0149 elseif(${_cmakename}) 0150 if(_cmakename_is_deprecated) 0151 message(DEPRECATION "${_cmakename} is deprecated, use KDE_INSTALL_${varname} instead.") 0152 endif() 0153 # The CMAKE_ name was given (probably on the command line): move 0154 # it to the new name 0155 set(KDE_INSTALL_${varname} "${${_cmakename}}" 0156 CACHE PATH 0157 "${docstring} (${_docpath})" 0158 FORCE) 0159 else() 0160 # insert an empty value into the cache, indicating the default 0161 # should be used (including compatibility vars above) 0162 set(KDE_INSTALL_${varname} "" 0163 CACHE PATH "${docstring} (${_docpath})") 0164 set(KDE_INSTALL_${varname} "${_realpath}") 0165 endif() 0166 0167 mark_as_advanced(KDE_INSTALL_${varname}) 0168 0169 if(NOT IS_ABSOLUTE ${KDE_INSTALL_${varname}}) 0170 set(KDE_INSTALL_FULL_${varname} 0171 "${CMAKE_INSTALL_PREFIX}/${KDE_INSTALL_${varname}}") 0172 else() 0173 set(KDE_INSTALL_FULL_${varname} "${KDE_INSTALL_${varname}}") 0174 endif() 0175 0176 # Override compatibility vars at runtime, even though we don't touch 0177 # them in the cache; this way, we keep the variables in sync where 0178 # KDEInstallDirs is included, but don't interfere with, say, 0179 # GNUInstallDirs in a parallel part of the CMake tree. 0180 if(_cmakename) 0181 set(${_cmakename} "${KDE_INSTALL_${varname}}") 0182 set(CMAKE_INSTALL_FULL_${varname} "${KDE_INSTALL_FULL_${varname}}") 0183 endif() 0184 0185 if(_oldstylename) 0186 set(${_oldstylename} "${KDE_INSTALL_${varname}}") 0187 endif() 0188 if (_aliasname) 0189 set(KDE_INSTALL_${_aliasname} "${KDE_INSTALL_${varname}}") 0190 set(KDE_INSTALL_FULL_${_aliasname} "${KDE_INSTALL_FULL_${varname}}") 0191 endif() 0192 endmacro() 0193 0194 # varname: the variable name suffix (eg: BINDIR for KDE_INSTALL_BINDIR) 0195 # dir: the relative path of the default value of KDE_INSTALL_${varname} 0196 # relative to CMAKE_INSTALL_PREFIX: no leading / 0197 # docstring: documentation about the variable (not including the default value) 0198 # oldstylename (optional): the old-style name of the variable 0199 macro(_define_absolute varname dir docstring) 0200 _define_relative("${varname}" "" "${dir}" "${docstring}" ${ARGN}) 0201 endmacro() 0202 0203 macro(_define_non_cache varname value) 0204 set(KDE_INSTALL_${varname} "${value}") 0205 if(NOT IS_ABSOLUTE ${KDE_INSTALL_${varname}}) 0206 set(KDE_INSTALL_FULL_${varname} 0207 "${CMAKE_INSTALL_PREFIX}/${KDE_INSTALL_${varname}}") 0208 else() 0209 set(KDE_INSTALL_FULL_${varname} "${KDE_INSTALL_${varname}}") 0210 endif() 0211 0212 if(NOT KDE_INSTALL_DIRS_NO_CMAKE_VARIABLES) 0213 list(FIND _gnu_install_dirs_vars "${varname}" _list_offset) 0214 if(NOT KDE_INSTALL_DIRS_NO_DEPRECATED OR NOT _list_offset EQUAL -1) 0215 set(CMAKE_INSTALL_${varname} "${KDE_INSTALL_${varname}}") 0216 set(CMAKE_INSTALL_FULL_${varname} "${KDE_INSTALL_FULL_${varname}}") 0217 endif() 0218 endif() 0219 endmacro() 0220 0221 if(APPLE) 0222 _define_absolute(BUNDLEDIR "/Applications/KDE" 0223 "application bundles" 0224 BUNDLE_INSTALL_DIR) 0225 endif() 0226 0227 # Only supported since cmake 3.7 0228 if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 0229 set(CMAKE_INSTALL_PREFIX "${ECM_PREFIX}" CACHE PATH "Install path prefix" FORCE) 0230 endif() 0231 0232 _define_absolute(EXECROOTDIR "" 0233 "executables and libraries" 0234 EXEC_INSTALL_PREFIX) 0235 0236 _define_relative(BINDIR EXECROOTDIR "bin" 0237 "user executables" 0238 BIN_INSTALL_DIR) 0239 _define_relative(SBINDIR EXECROOTDIR "sbin" 0240 "system admin executables" 0241 SBIN_INSTALL_DIR) 0242 _define_relative(LIBDIR EXECROOTDIR "${_LIBDIR_DEFAULT}" 0243 "object code libraries" 0244 LIB_INSTALL_DIR) 0245 0246 if(WIN32) 0247 _define_relative(LIBEXECDIR BINDIR "" 0248 "executables for internal use by programs and libraries" 0249 LIBEXEC_INSTALL_DIR) 0250 else() 0251 _define_relative(LIBEXECDIR LIBDIR "libexec" 0252 "executables for internal use by programs and libraries" 0253 LIBEXEC_INSTALL_DIR) 0254 endif() 0255 0256 _define_relative(CMAKEPACKAGEDIR LIBDIR "cmake" 0257 "CMake packages, including config files" 0258 CMAKECONFIG_INSTALL_PREFIX) 0259 0260 _define_absolute(INCLUDEDIR "include" 0261 "C and C++ header files" 0262 INCLUDE_INSTALL_DIR) 0263 0264 _define_absolute(LOCALSTATEDIR "var" 0265 "modifiable single-machine data") 0266 0267 _define_absolute(SHAREDSTATEDIR "com" 0268 "modifiable architecture-independent data") 0269 0270 if (WIN32) 0271 _define_relative(DATAROOTDIR BINDIR "data" 0272 "read-only architecture-independent data root" 0273 SHARE_INSTALL_PREFIX) 0274 else() 0275 _define_absolute(DATAROOTDIR "share" 0276 "read-only architecture-independent data root" 0277 SHARE_INSTALL_PREFIX) 0278 endif() 0279 0280 _define_relative(DATADIR DATAROOTDIR "" 0281 "read-only architecture-independent data" 0282 DATA_INSTALL_DIR) 0283 0284 # KDE Framework-specific things 0285 _define_relative(DOCBUNDLEDIR DATAROOTDIR "doc/HTML" 0286 "documentation bundles generated using kdoctools" 0287 HTML_INSTALL_DIR) 0288 _define_relative(KCFGDIR DATAROOTDIR "config.kcfg" 0289 "kconfig description files" 0290 KCFG_INSTALL_DIR) 0291 _define_relative(KCONFUPDATEDIR DATAROOTDIR "kconf_update" 0292 "kconf_update scripts" 0293 KCONF_UPDATE_INSTALL_DIR) 0294 _define_relative(KAPPTEMPLATESDIR DATAROOTDIR "kdevappwizard/templates" 0295 "KAppTemplate and KDevelop templates" 0296 KDE_INSTALL_KTEMPLATESDIR 0297 ) 0298 _define_relative(KFILETEMPLATESDIR DATAROOTDIR "kdevfiletemplates/templates" 0299 "KDevelop file templates") 0300 _define_relative(JARDIR "" "jar" 0301 "Java AAR/JAR files for Android") 0302 0303 0304 # Cross-desktop or other system things 0305 _define_relative(ICONDIR DATAROOTDIR "icons" 0306 "icons" 0307 ICON_INSTALL_DIR) 0308 _define_relative(LOCALEDIR DATAROOTDIR "locale" 0309 "locale-dependent data" 0310 LOCALE_INSTALL_DIR) 0311 _define_relative(SOUNDDIR DATAROOTDIR "sounds" 0312 "sound files" 0313 SOUND_INSTALL_DIR) 0314 _define_relative(TEMPLATEDIR DATAROOTDIR "templates" 0315 "templates" 0316 TEMPLATES_INSTALL_DIR) 0317 _define_relative(WALLPAPERDIR DATAROOTDIR "wallpapers" 0318 "desktop wallpaper images" 0319 WALLPAPER_INSTALL_DIR) 0320 _define_relative(APPDIR DATAROOTDIR "applications" 0321 "application desktop files" 0322 XDG_APPS_INSTALL_DIR) 0323 _define_relative(DESKTOPDIR DATAROOTDIR "desktop-directories" 0324 "desktop directories" 0325 XDG_DIRECTORY_INSTALL_DIR) 0326 _define_relative(MIMEDIR DATAROOTDIR "mime/packages" 0327 "mime description files" 0328 XDG_MIME_INSTALL_DIR) 0329 _define_relative(METAINFODIR DATAROOTDIR "metainfo" 0330 "AppStream component metadata") 0331 _define_relative(QCHDIR DATAROOTDIR "doc/qch" 0332 "documentation bundles in QCH format") 0333 _define_relative(MANDIR DATAROOTDIR "man" 0334 "man documentation" 0335 MAN_INSTALL_DIR) 0336 _define_relative(INFODIR DATAROOTDIR "info" 0337 "info documentation") 0338 _define_relative(DBUSDIR DATAROOTDIR "dbus-1" 0339 "D-Bus") 0340 _define_relative(DBUSINTERFACEDIR DBUSDIR "interfaces" 0341 "D-Bus interfaces" 0342 DBUS_INTERFACES_INSTALL_DIR) 0343 _define_relative(DBUSSERVICEDIR DBUSDIR "services" 0344 "D-Bus session services" 0345 DBUS_SERVICES_INSTALL_DIR) 0346 _define_relative(DBUSSYSTEMSERVICEDIR DBUSDIR "system-services" 0347 "D-Bus system services" 0348 DBUS_SYSTEM_SERVICES_INSTALL_DIR) 0349 _define_relative(SYSTEMDUNITDIR CMAKE_INSTALL_PREFIX "lib/systemd" 0350 "Systemd units" 0351 SYSTEMD_UNIT_INSTALL_DIR) 0352 _define_relative(SYSTEMDUSERUNITDIR SYSTEMDUNITDIR "user" 0353 "Systemd user units" 0354 SYSTEMD_USER_UNIT_INSTALL_DIR) 0355 _define_relative(ZSHAUTOCOMPLETEDIR DATAROOTDIR "zsh/site-functions" 0356 "Zsh functions and autocompletion definitions") 0357 0358 set(_default_sysconf_dir "etc") 0359 if (CMAKE_INSTALL_PREFIX STREQUAL "/usr") 0360 set(_default_sysconf_dir "/etc") 0361 endif() 0362 0363 _define_absolute(SYSCONFDIR "${_default_sysconf_dir}" 0364 "read-only single-machine data" 0365 SYSCONF_INSTALL_DIR) 0366 _define_relative(CONFDIR SYSCONFDIR "xdg" 0367 "application configuration files" 0368 CONFIG_INSTALL_DIR) 0369 _define_relative(AUTOSTARTDIR CONFDIR "autostart" 0370 "autostart files" 0371 AUTOSTART_INSTALL_DIR) 0372 0373 0374 set(_mixed_core_path_styles FALSE) 0375 if (IS_ABSOLUTE "${KDE_INSTALL_BINDIR}") 0376 if (NOT IS_ABSOLUTE "${KDE_INSTALL_LIBDIR}" OR NOT IS_ABSOLUTE "${KDE_INSTALL_INCLUDEDIR}") 0377 set(_mixed_core_path_styles ) 0378 endif() 0379 else() 0380 if (IS_ABSOLUTE "${KDE_INSTALL_LIBDIR}" OR IS_ABSOLUTE "${KDE_INSTALL_INCLUDEDIR}") 0381 set(_mixed_core_path_styles TRUE) 0382 endif() 0383 endif() 0384 if (_mixed_core_path_styles) 0385 message(WARNING "KDE_INSTALL_BINDIR, KDE_INSTALL_LIBDIR and KDE_INSTALL_INCLUDEDIR should either all be absolute paths or all be relative paths.") 0386 endif() 0387 0388 0389 # new in cmake 2.8.9: this is used for all installed files which do not have a component set 0390 # so set the default component name to the name of the project, if a project name has been set: 0391 if(NOT "${PROJECT_NAME}" STREQUAL "Project") 0392 set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "${PROJECT_NAME}") 0393 endif()