kde5.eclass: install linguas-related files unconditionally for kconfigwidgets
[gentoo.git] / eclass / kde5.eclass
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 # @ECLASS: kde5.eclass
5 # @MAINTAINER:
6 # kde@gentoo.org
7 # @BLURB: Support eclass for packages that follow KDE packaging conventions.
8 # @DESCRIPTION:
9 # This eclass is intended to streamline the creation of ebuilds for packages
10 # that follow KDE upstream packaging conventions. It's primarily intended for
11 # the three upstream release groups (Frameworks, Plasma, Applications) but
12 # is also for any package that follows similar conventions.
13 #
14 # This eclass unconditionally inherits kde5-functions.eclass and all its public
15 # functions and variables may be considered as part of this eclass's API.
16 #
17 # This eclass unconditionally inherits cmake-utils.eclass and all its public
18 # variables and helper functions (not phase functions) may be considered as part
19 # of this eclass's API.
20 #
21 # This eclass's phase functions are not intended to be mixed and matched, so if
22 # any phase functions are overridden the version here should also be called.
23
24 if [[ -z ${_KDE5_ECLASS} ]]; then
25 _KDE5_ECLASS=1
26
27 # @ECLASS-VARIABLE: VIRTUALX_REQUIRED
28 # @DESCRIPTION:
29 # For proper description see virtualx.eclass manpage.
30 # Here we redefine default value to be manual, if your package needs virtualx
31 # for tests you should proceed with setting VIRTUALX_REQUIRED=test.
32 : ${VIRTUALX_REQUIRED:=manual}
33
34 inherit cmake-utils flag-o-matic kde5-functions virtualx xdg
35
36 case ${EAPI} in
37         6) inherit eapi7-ver eutils gnome2-utils ;;
38 esac
39
40 if [[ ${KDE_BUILD_TYPE} = live ]]; then
41         inherit git-r3
42 fi
43
44 if [[ -v KDE_GCC_MINIMAL ]]; then
45         EXPORT_FUNCTIONS pkg_pretend
46 fi
47
48 EXPORT_FUNCTIONS pkg_setup pkg_nofetch src_unpack src_prepare src_configure src_compile src_test src_install pkg_preinst pkg_postinst pkg_postrm
49
50 # @ECLASS-VARIABLE: ECM_KDEINSTALLDIRS
51 # @DESCRIPTION:
52 # If set to "false", do nothing.
53 # For any other value, assume the package is using KDEInstallDirs macro and switch
54 # KDE_INSTALL_USE_QT_SYS_PATHS to ON.
55 : ${ECM_KDEINSTALLDIRS:=true}
56
57 # @ECLASS-VARIABLE: KDE_AUTODEPS
58 # @DESCRIPTION:
59 # If set to "false", do nothing.
60 # For any other value, add dependencies on dev-qt/qtcore:5, kde-frameworks/kf-env
61 # and kde-frameworks/extra-cmake-modules:5. Additionally, required blockers may
62 # be set depending on the value of CATEGORY.
63 : ${KDE_AUTODEPS:=true}
64
65 # @ECLASS-VARIABLE: KDE_BLOCK_SLOT4
66 # @DESCRIPTION:
67 # This variable only has any effect when when CATEGORY = "kde-apps" and
68 # KDE_AUTODEPS is also set. If set to "true", add RDEPEND block on kde-apps/${PN}:4
69 : ${KDE_BLOCK_SLOT4:=true}
70
71 # @ECLASS-VARIABLE: KDE_DEBUG
72 # @DESCRIPTION:
73 # If set to "false", add -DNDEBUG (via cmake-utils_src_configure) and -DQT_NO_DEBUG
74 # to CPPFLAGS.
75 # Otherwise, add debug to IUSE.
76 : ${KDE_DEBUG:=true}
77
78 # @ECLASS-VARIABLE: KDE_DESIGNERPLUGIN
79 # @DESCRIPTION:
80 # If set to "false", do nothing.
81 # Otherwise, add "designer" to IUSE to toggle build of designer plugins
82 # and add the necessary DEPENDs.
83 : ${KDE_DESIGNERPLUGIN:=false}
84
85 # @ECLASS-VARIABLE: KDE_EXAMPLES
86 # @DESCRIPTION:
87 # If set to "false", unconditionally ignore a top-level examples subdirectory.
88 # Otherwise, add "examples" to IUSE to toggle adding that subdirectory.
89 : ${KDE_EXAMPLES:=false}
90
91 # @ECLASS-VARIABLE: KDE_HANDBOOK
92 # @DESCRIPTION:
93 # If set to "false", do nothing.
94 # Otherwise, add "+handbook" to IUSE, add the appropriate dependency, and
95 # generate and install KDE handbook.
96 # If set to "optional", config with -DCMAKE_DISABLE_FIND_PACKAGE_KF5DocTools=ON
97 # when USE=!handbook. In case package requires KF5KDELibs4Support, see next:
98 # If set to "forceoptional", remove a KF5DocTools dependency from the root
99 # CMakeLists.txt in addition to the above.
100 : ${KDE_HANDBOOK:=false}
101
102 # @ECLASS-VARIABLE: KDE_DOC_DIR
103 # @DESCRIPTION:
104 # Specifies the location of the KDE handbook if not the default.
105 : ${KDE_DOC_DIR:=doc}
106
107 # @ECLASS-VARIABLE: KDE_PO_DIRS
108 # @DESCRIPTION:
109 # Specifies the possible locations of KDE l10n files if not the default.
110 : ${KDE_PO_DIRS:="po poqm"}
111
112 # @ECLASS-VARIABLE: KDE_QTHELP
113 # @DESCRIPTION:
114 # If set to "false", do nothing.
115 # Otherwise, add "doc" to IUSE, add the appropriate dependency, generate
116 # and install Qt compressed help files with -DBUILD_QCH=ON when USE=doc.
117 if [[ ${CATEGORY} = kde-frameworks ]]; then
118         : ${KDE_QTHELP:=true}
119 fi
120 : ${KDE_QTHELP:=false}
121
122 # @ECLASS-VARIABLE: KDE_TEST
123 # @DESCRIPTION:
124 # If set to "false", do nothing.
125 # For any other value, add test to IUSE and add a dependency on dev-qt/qttest:5.
126 # If set to "optional", configure with -DCMAKE_DISABLE_FIND_PACKAGE_Qt5Test=ON
127 # when USE=!test.
128 # If set to "forceoptional", remove a Qt5Test dependency and comment test
129 # subdirs from the root CMakeLists.txt in addition to the above.
130 # If set to "forceoptional-recursive", remove Qt5Test dependencies and make
131 # autotest(s), unittest(s) and test(s) subdirs from *any* CMakeLists.txt in ${S}
132 # and below conditional on BUILD_TESTING. This is always meant as a short-term
133 # fix and creates ${T}/${P}-tests-optional.patch to refine and submit upstream.
134 if [[ ${CATEGORY} = kde-frameworks ]]; then
135         : ${KDE_TEST:=true}
136 fi
137 : ${KDE_TEST:=false}
138
139 # @ECLASS-VARIABLE: KDE_SELINUX_MODULE
140 # @DESCRIPTION:
141 # If set to "none", do nothing.
142 # For any other value, add selinux to IUSE, and depending on that useflag
143 # add a dependency on sec-policy/selinux-${KDE_SELINUX_MODULE} to (R)DEPEND.
144 : ${KDE_SELINUX_MODULE:=none}
145
146 # @ECLASS-VARIABLE: KDE_SUBSLOT
147 # @DESCRIPTION:
148 # If set to "false", do nothing.
149 # If set to "true", add a subslot to the package, where subslot is either
150 # defined as major.minor version for kde-*/ categories or ${PV} if other.
151 # For any other value, that value will be used as subslot.
152 : ${KDE_SUBSLOT:=false}
153
154 # @ECLASS-VARIABLE: KDE_UNRELEASED
155 # @INTERNAL
156 # @DESCRIPTION
157 # An array of $CATEGORY-$PV pairs of packages that are unreleased upstream.
158 # Any package matching this will have fetch restriction enabled, and receive
159 # a proper error message via pkg_nofetch.
160 KDE_UNRELEASED=( )
161
162 HOMEPAGE="https://kde.org/"
163 LICENSE="GPL-2"
164
165 SLOT=5
166
167 if [[ ${CATEGORY} = kde-frameworks ]]; then
168         KDE_SUBSLOT=true
169 fi
170
171 case ${KDE_SUBSLOT} in
172         false)  ;;
173         true)
174                 case ${CATEGORY} in
175                         kde-frameworks | \
176                         kde-plasma | \
177                         kde-apps)
178                                 SLOT+="/$(ver_cut 1-2)"
179                                 ;;
180                         *)
181                                 SLOT+="/${PV}"
182                                 ;;
183                 esac
184                 ;;
185         *)
186                 SLOT+="/${KDE_SUBSLOT}"
187                 ;;
188 esac
189
190 case ${KDE_AUTODEPS} in
191         false)  ;;
192         *)
193                 BDEPEND+=" $(add_frameworks_dep extra-cmake-modules)"
194                 RDEPEND+=" >=kde-frameworks/kf-env-4"
195                 COMMONDEPEND+=" $(add_qt_dep qtcore)"
196
197                 # all packages need breeze/oxygen icons for basic iconset, bug #564838
198                 if [[ ${PN} != breeze-icons && ${PN} != oxygen-icons ]]; then
199                         RDEPEND+=" || ( $(add_frameworks_dep breeze-icons) kde-frameworks/oxygen-icons:* )"
200                 fi
201                 ;;
202 esac
203
204 case ${KDE_DEBUG} in
205         false)  ;;
206         *)
207                 IUSE+=" debug"
208                 ;;
209 esac
210
211 case ${KDE_DESIGNERPLUGIN} in
212         false)  ;;
213         *)
214                 IUSE+=" designer"
215                 BDEPEND+=" designer? ( $(add_frameworks_dep kdesignerplugin) )"
216 esac
217
218 case ${KDE_EXAMPLES} in
219         false)  ;;
220         *)
221                 IUSE+=" examples"
222                 ;;
223 esac
224
225 case ${KDE_HANDBOOK} in
226         false)  ;;
227         *)
228                 IUSE+=" +handbook"
229                 BDEPEND+=" handbook? ( $(add_frameworks_dep kdoctools) )"
230                 ;;
231 esac
232
233 case ${KDE_QTHELP} in
234         false)  ;;
235         *)
236                 IUSE+=" doc"
237                 COMMONDEPEND+=" doc? ( $(add_qt_dep qt-docs) )"
238                 BDEPEND+=" doc? (
239                         $(add_qt_dep qthelp)
240                         >=app-doc/doxygen-1.8.13-r1
241                 )"
242                 ;;
243 esac
244
245 case ${KDE_TEST} in
246         false)  ;;
247         *)
248                 IUSE+=" test"
249                 DEPEND+=" test? ( $(add_qt_dep qttest) )"
250                 ;;
251 esac
252
253 case ${KDE_SELINUX_MODULE} in
254         none)   ;;
255         *)
256                 IUSE+=" selinux"
257                 RDEPEND+=" selinux? ( sec-policy/selinux-${KDE_SELINUX_MODULE} )"
258                 ;;
259 esac
260
261 case ${EAPI} in
262         6) DEPEND+=" ${BDEPEND}" ;;
263 esac
264
265 DEPEND+=" ${COMMONDEPEND}"
266 RDEPEND+=" ${COMMONDEPEND}"
267 unset COMMONDEPEND
268
269 if [[ -n ${KMNAME} && ${KMNAME} != ${PN} && ${KDE_BUILD_TYPE} = release ]]; then
270         S=${WORKDIR}/${KMNAME}-${PV}
271 fi
272
273 _kde_is_unreleased() {
274         local pair
275         for pair in "${KDE_UNRELEASED[@]}" ; do
276                 if [[ "${pair}" = "${CATEGORY}-${PV}" ]]; then
277                         return 0
278                 fi
279         done
280
281         return 1
282 }
283
284 # Determine fetch location for released tarballs
285 _calculate_src_uri() {
286         debug-print-function ${FUNCNAME} "$@"
287
288         local _kmname
289
290         if [[ -n ${KMNAME} ]]; then
291                 _kmname=${KMNAME}
292         else
293                 _kmname=${PN}
294         fi
295
296         case ${PN} in
297                 kdelibs4support | \
298                 khtml | \
299                 kjs | \
300                 kjsembed | \
301                 kmediaplayer | \
302                 kross)
303                         _kmname="portingAids/${_kmname}"
304                         ;;
305         esac
306
307         case ${CATEGORY} in
308                 kde-apps)
309                         case ${PV} in
310                                 ??.?.[6-9]? | ??.??.[6-9]? )
311                                         SRC_URI="mirror://kde/unstable/applications/${PV}/src/${_kmname}-${PV}.tar.xz"
312                                         RESTRICT+=" mirror"
313                                         ;;
314                                 *)
315                                         SRC_URI="mirror://kde/stable/applications/${PV}/src/${_kmname}-${PV}.tar.xz" ;;
316                         esac
317                         ;;
318                 kde-frameworks)
319                         SRC_URI="mirror://kde/stable/frameworks/${PV%.*}/${_kmname}-${PV}.tar.xz" ;;
320                 kde-plasma)
321                         local plasmapv=$(ver_cut 1-3)
322
323                         case ${PV} in
324                                 5.?.[6-9]? | 5.??.[6-9]? )
325                                         # Plasma 5 beta releases
326                                         SRC_URI="mirror://kde/unstable/plasma/${plasmapv}/${_kmname}-${PV}.tar.xz"
327                                         RESTRICT+=" mirror"
328                                         ;;
329                                 *)
330                                         # Plasma 5 stable releases
331                                         SRC_URI="mirror://kde/stable/plasma/${plasmapv}/${_kmname}-${PV}.tar.xz" ;;
332                         esac
333                         ;;
334         esac
335
336         if [[ ${PN} = kdevelop* ]]; then
337                 case ${PV} in
338                         *.*.[6-9]? )
339                                 SRC_URI="mirror://kde/unstable/kdevelop/${PV}/src/${_kmname}-${PV}.tar.xz"
340                                 RESTRICT+=" mirror"
341                                 ;;
342                         *)
343                                 SRC_URI="mirror://kde/stable/kdevelop/${PV}/src/${_kmname}-${PV}.tar.xz" ;;
344                 esac
345         fi
346
347         if _kde_is_unreleased ; then
348                 RESTRICT+=" fetch"
349         fi
350 }
351
352 # Determine fetch location for live sources
353 _calculate_live_repo() {
354         debug-print-function ${FUNCNAME} "$@"
355
356         SRC_URI=""
357
358         # @ECLASS-VARIABLE: EGIT_MIRROR
359         # @DESCRIPTION:
360         # This variable allows easy overriding of default kde mirror service
361         # (anongit) with anything else you might want to use.
362         EGIT_MIRROR=${EGIT_MIRROR:=https://anongit.kde.org}
363
364         local _kmname
365
366         # @ECLASS-VARIABLE: EGIT_REPONAME
367         # @DESCRIPTION:
368         # This variable allows overriding of default repository
369         # name. Specify only if this differ from PN and KMNAME.
370         if [[ -n ${EGIT_REPONAME} ]]; then
371                 # the repository and kmname different
372                 _kmname=${EGIT_REPONAME}
373         elif [[ -n ${KMNAME} ]]; then
374                 _kmname=${KMNAME}
375         else
376                 _kmname=${PN}
377         fi
378
379         if [[ ${PV} == ??.??.49.9999 && ${CATEGORY} = kde-apps ]]; then
380                 EGIT_BRANCH="Applications/$(ver_cut 1-2)"
381         fi
382
383         if [[ ${PV} != 9999 && ${CATEGORY} = kde-plasma ]]; then
384                 EGIT_BRANCH="Plasma/$(ver_cut 1-2)"
385         fi
386
387         if [[ ${PV} != 9999 && ${PN} = kdevelop* ]]; then
388                 EGIT_BRANCH="$(ver_cut 1-2)"
389         fi
390
391         EGIT_REPO_URI="${EGIT_MIRROR}/${_kmname}"
392 }
393
394 case ${KDE_BUILD_TYPE} in
395         live) _calculate_live_repo ;;
396         *) _calculate_src_uri ;;
397 esac
398
399 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: SRC_URI is ${SRC_URI}"
400
401 # @FUNCTION: kde5_pkg_pretend
402 # @DESCRIPTION:
403 # Checks if the active compiler meets the minimum version requirements.
404 # phase function is only exported if KDE_GCC_MINIMAL is defined.
405 kde5_pkg_pretend() {
406         debug-print-function ${FUNCNAME} "$@"
407         _check_gcc_version
408 }
409
410 # @FUNCTION: kde5_pkg_setup
411 # @DESCRIPTION:
412 # Checks if the active compiler meets the minimum version requirements.
413 kde5_pkg_setup() {
414         debug-print-function ${FUNCNAME} "$@"
415         _check_gcc_version
416 }
417
418 # @FUNCTION: kde5_pkg_nofetch
419 # @DESCRIPTION:
420 # Intended for use in the KDE overlay. If this package matches something in
421 # KDE_UNRELEASED, display a giant warning that the package has not yet been
422 # released upstream and should not be used.
423 kde5_pkg_nofetch() {
424         if ! _kde_is_unreleased ; then
425                 return
426         fi
427
428         eerror " _   _ _   _ ____  _____ _     _____    _    ____  _____ ____  "
429         eerror "| | | | \ | |  _ \| ____| |   | ____|  / \  / ___|| ____|  _ \ "
430         eerror "| | | |  \| | |_) |  _| | |   |  _|   / _ \ \___ \|  _| | | | |"
431         eerror "| |_| | |\  |  _ <| |___| |___| |___ / ___ \ ___) | |___| |_| |"
432         eerror " \___/|_| \_|_| \_\_____|_____|_____/_/   \_\____/|_____|____/ "
433         eerror "                                                               "
434         eerror " ____   _    ____ _  __    _    ____ _____ "
435         eerror "|  _ \ / \  / ___| |/ /   / \  / ___| ____|"
436         eerror "| |_) / _ \| |   | ' /   / _ \| |  _|  _|  "
437         eerror "|  __/ ___ \ |___| . \  / ___ \ |_| | |___ "
438         eerror "|_| /_/   \_\____|_|\_\/_/   \_\____|_____|"
439         eerror
440         eerror "${CATEGORY}/${P} has not been released to the public yet"
441         eerror "and is only available to packagers right now."
442         eerror ""
443         eerror "This is not a bug. Please do not file bugs or contact upstream about this."
444         eerror ""
445         eerror "Please consult the upstream release schedule to see when this "
446         eerror "package is scheduled to be released:"
447         eerror "https://community.kde.org/Schedules"
448 }
449
450 # @FUNCTION: kde5_src_unpack
451 # @DESCRIPTION:
452 # Unpack the sources, automatically handling both release and live ebuilds.
453 kde5_src_unpack() {
454         debug-print-function ${FUNCNAME} "$@"
455
456         if [[ ${KDE_BUILD_TYPE} = live ]]; then
457                 git-r3_src_unpack
458         else
459                 default
460         fi
461 }
462
463 # @FUNCTION: kde5_src_prepare
464 # @DESCRIPTION:
465 # Wrapper for cmake-utils_src_prepare with lots of extra logic for magic
466 # handling of linguas, tests, handbook etc.
467 kde5_src_prepare() {
468         debug-print-function ${FUNCNAME} "$@"
469
470         cmake-utils_src_prepare
471
472         # only build examples when required
473         if ! { in_iuse examples && use examples; } ; then
474                 cmake_comment_add_subdirectory examples
475         fi
476
477         # only enable handbook when required
478         if in_iuse handbook && ! use handbook ; then
479                 cmake_comment_add_subdirectory ${KDE_DOC_DIR}
480
481                 if [[ ${KDE_HANDBOOK} = forceoptional ]] ; then
482                         punt_bogus_dep KF5 DocTools
483                         sed -i -e "/kdoctools_install/ s/^/#DONT/" CMakeLists.txt || die
484                 fi
485         fi
486
487         # drop translations when nls is not wanted
488         if in_iuse nls && ! use nls ; then
489                 local po
490                 for po in ${KDE_PO_DIRS}; do
491                         if [[ -d ${po} ]] ; then
492                                 rm -r ${po} || die
493                         fi
494                 done
495         fi
496
497         # enable only the requested translations when required
498         # always install unconditionally for kconfigwidgets - if you use language
499         # X as system language, and there is a combobox with language names, the
500         # translated language name for language Y is taken from /usr/share/locale/Y/kf5_entry.desktop
501         if [[ -v LINGUAS && ${PN} != kconfigwidgets ]] ; then
502                 local po
503                 for po in ${KDE_PO_DIRS}; do
504                 if [[ -d ${po} ]] ; then
505                         pushd ${po} > /dev/null || die
506                         local lang
507                         for lang in *; do
508                                 if [[ -e ${lang} ]] && ! has ${lang/.po/} ${LINGUAS} ; then
509                                         case ${lang} in
510                                                 cmake_modules | \
511                                                 CMakeLists.txt | \
512                                                 ${PN}.pot)      ;;
513                                                 *) rm -r ${lang} || die ;;
514                                         esac
515                                         if [[ -e CMakeLists.txt ]] ; then
516                                                 cmake_comment_add_subdirectory ${lang}
517                                                 sed -e "/add_subdirectory([[:space:]]*${lang}\/.*[[:space:]]*)/d" \
518                                                         -i CMakeLists.txt || die
519                                         fi
520                                 fi
521                         done
522                         popd > /dev/null || die
523                 fi
524                 done
525         fi
526
527         if [[ ${KDE_BUILD_TYPE} = release && ${CATEGORY} != kde-apps ]] ; then
528                 if [[ ${KDE_HANDBOOK} != false && -d ${KDE_DOC_DIR} && -v LINGUAS ]] ; then
529                         pushd ${KDE_DOC_DIR} > /dev/null || die
530                         local lang
531                         for lang in *; do
532                                 if ! has ${lang} ${LINGUAS} ; then
533                                         cmake_comment_add_subdirectory ${lang}
534                                 fi
535                         done
536                         popd > /dev/null || die
537                 fi
538         fi
539
540         # only build unit tests when required
541         if ! { in_iuse test && use test; } ; then
542                 if [[ ${KDE_TEST} = forceoptional ]] ; then
543                         punt_bogus_dep Qt5 Test
544                         # if forceoptional, also cover non-kde categories
545                         cmake_comment_add_subdirectory autotests test tests
546                 elif [[ ${KDE_TEST} = forceoptional-recursive ]] ; then
547                         punt_bogus_dep Qt5 Test
548                         local f pf="${T}/${P}"-tests-optional.patch
549                         touch ${pf} || die "Failed to touch patch file"
550                         for f in $(find . -type f -name "CMakeLists.txt" -exec \
551                                 grep -l "^\s*add_subdirectory\s*\(\s*.*\(auto|unit\)\?tests\?\s*)\s*\)" {} \;); do
552                                 cp ${f} ${f}.old || die "Failed to prepare patch origfile"
553                                 pushd ${f%/*} > /dev/null || die
554                                         punt_bogus_dep Qt5 Test
555                                         sed -i CMakeLists.txt -e \
556                                                 "/^#/! s/add_subdirectory\s*\(\s*.*\(auto|unit\)\?tests\?\s*)\s*\)/if(BUILD_TESTING)\n&\nendif()/" \
557                                                 || die
558                                 popd > /dev/null || die
559                                 diff -Naur ${f}.old ${f} 1>>${pf}
560                                 rm ${f}.old || die "Failed to clean up"
561                         done
562                         einfo "Build system was modified by KDE_TEST=forceoptional-recursive."
563                         einfo "Unified diff file ready for pickup in:"
564                         einfo "  ${pf}"
565                         einfo "Push it upstream to make this message go away."
566                 elif [[ ${CATEGORY} = kde-frameworks || ${CATEGORY} = kde-plasma || ${CATEGORY} = kde-apps ]] ; then
567                         cmake_comment_add_subdirectory autotests test tests
568                 fi
569         fi
570
571         # in frameworks, tests = manual tests so never build them
572         if [[ ${CATEGORY} = kde-frameworks ]] && [[ ${PN} != extra-cmake-modules ]]; then
573                 cmake_comment_add_subdirectory tests
574         fi
575 }
576
577 # @FUNCTION: kde5_src_configure
578 # @DESCRIPTION:
579 # Wrapper for cmake-utils_src_configure with extra logic for magic handling of
580 # handbook, tests etc.
581 kde5_src_configure() {
582         debug-print-function ${FUNCNAME} "$@"
583
584         # we rely on cmake-utils.eclass to append -DNDEBUG too
585         if in_iuse debug && ! use debug; then
586                 append-cppflags -DQT_NO_DEBUG
587         fi
588
589         local cmakeargs
590
591         if in_iuse test && ! use test ; then
592                 cmakeargs+=( -DBUILD_TESTING=OFF )
593
594                 if [[ ${KDE_TEST} = optional ]] ; then
595                         cmakeargs+=( -DCMAKE_DISABLE_FIND_PACKAGE_Qt5Test=ON )
596                 fi
597         fi
598
599         if in_iuse handbook && ! use handbook && [[ ${KDE_HANDBOOK} = optional ]] ; then
600                 cmakeargs+=( -DCMAKE_DISABLE_FIND_PACKAGE_KF5DocTools=ON )
601         fi
602
603         if in_iuse designer && ! use designer && [[ ${KDE_DESIGNERPLUGIN} != false ]] ; then
604                 cmakeargs+=( -DCMAKE_DISABLE_FIND_PACKAGE_KF5DesignerPlugin=ON )
605         fi
606
607         if [[ ${KDE_QTHELP} != false ]]; then
608                 cmakeargs+=( -DBUILD_QCH=$(usex doc) )
609         fi
610
611         if [[ ${ECM_KDEINSTALLDIRS} != false ]] ; then
612                 cmakeargs+=(
613                         # install mkspecs in the same directory as qt stuff
614                         -DKDE_INSTALL_USE_QT_SYS_PATHS=ON
615                 )
616                 # move handbook outside of doc dir for at least two QA warnings, bug 667138
617                 [[ ${EAPI} != 6 ]] && cmakeargs+=( -DKDE_INSTALL_DOCBUNDLEDIR="${EPREFIX}/usr/share/help" )
618         fi
619
620         # allow the ebuild to override what we set here
621         mycmakeargs=("${cmakeargs[@]}" "${mycmakeargs[@]}")
622
623         cmake-utils_src_configure
624 }
625
626 # @FUNCTION: kde5_src_compile
627 # @DESCRIPTION:
628 # Wrapper for cmake-utils_src_compile. Currently doesn't do anything extra, but
629 # is included as part of the API just in case it's needed in the future.
630 kde5_src_compile() {
631         debug-print-function ${FUNCNAME} "$@"
632
633         cmake-utils_src_compile "$@"
634 }
635
636 # @FUNCTION: kde5_src_test
637 # @DESCRIPTION:
638 # Wrapper for cmake-utils_src_test with extra logic for magic handling of dbus
639 # and virtualx.
640 kde5_src_test() {
641         debug-print-function ${FUNCNAME} "$@"
642
643         _test_runner() {
644                 if [[ -n "${VIRTUALDBUS_TEST}" ]]; then
645                         export $(dbus-launch)
646                 fi
647
648                 cmake-utils_src_test
649         }
650
651         # When run as normal user during ebuild development with the ebuild command, the
652         # kde tests tend to access the session DBUS. This however is not possible in a real
653         # emerge or on the tinderbox.
654         # > make sure it does not happen, so bad tests can be recognized and disabled
655         unset DBUS_SESSION_BUS_ADDRESS DBUS_SESSION_BUS_PID
656
657         if [[ ${VIRTUALX_REQUIRED} = always || ${VIRTUALX_REQUIRED} = test ]]; then
658                 virtx _test_runner
659         else
660                 _test_runner
661         fi
662
663         if [[ -n "${DBUS_SESSION_BUS_PID}" ]] ; then
664                 kill ${DBUS_SESSION_BUS_PID}
665         fi
666 }
667
668 # @FUNCTION: kde5_src_install
669 # @DESCRIPTION:
670 # Wrapper for cmake-utils_src_install with extra logic to avoid compressing
671 # certain types of files. For example, khelpcenter is not able to read
672 # compressed handbooks.
673 kde5_src_install() {
674         debug-print-function ${FUNCNAME} "$@"
675
676         cmake-utils_src_install
677
678         # We don't want QCH and tags files to be compressed, because then
679         # cmake can't find the tags and qthelp viewers can't find the docs
680         local p=$(best_version dev-qt/qtcore:5)
681         local pv=$(echo ${p/%-r[0-9]*/} | rev | cut -d - -f 1 | rev)
682         if [[ ${pv} = 5.11* ]]; then
683                 #todo: clean up trailing slash check when EAPI <7 is removed
684                 if [[ -d ${ED%/}/usr/share/doc/qt-${pv} ]]; then
685                         docompress -x /usr/share/doc/qt-${pv}
686                 fi
687         fi
688
689         if [[ ${EAPI} = 6 ]]; then
690                 # We don't want /usr/share/doc/HTML to be compressed,
691                 # because then khelpcenter can't find the docs
692                 #todo: clean up trailing slash check when EAPI <7 is removed
693                 if [[ -d ${ED%/}/usr/share/doc/HTML ]]; then
694                         docompress -x /usr/share/doc/HTML
695                 fi
696         fi
697 }
698
699 # @FUNCTION: kde5_pkg_preinst
700 # @DESCRIPTION:
701 # Sets up environment variables required in kde5_pkg_postinst.
702 kde5_pkg_preinst() {
703         debug-print-function ${FUNCNAME} "$@"
704
705         xdg_pkg_preinst
706 }
707
708 # @FUNCTION: kde5_pkg_postinst
709 # @DESCRIPTION:
710 # Updates the various XDG caches (icon, desktop, mime) if necessary.
711 kde5_pkg_postinst() {
712         debug-print-function ${FUNCNAME} "$@"
713
714         xdg_pkg_postinst
715
716         if [[ -z ${I_KNOW_WHAT_I_AM_DOING} ]]; then
717                 if [[ ${KDE_BUILD_TYPE} = live ]]; then
718                         echo
719                         einfo "WARNING! This is an experimental live ebuild of ${CATEGORY}/${PN}"
720                         einfo "Use it at your own risk."
721                         einfo "Do _NOT_ file bugs at bugs.gentoo.org because of this ebuild!"
722                 fi
723         fi
724 }
725
726 # @FUNCTION: kde5_pkg_postrm
727 # @DESCRIPTION:
728 # Updates the various XDG caches (icon, desktop, mime) if necessary.
729 kde5_pkg_postrm() {
730         debug-print-function ${FUNCNAME} "$@"
731
732         xdg_pkg_postrm
733 }
734
735 fi