app-emacs/ebuild-mode: ppc stable wrt bug #706066
[gentoo.git] / eclass / ecm.eclass
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 # @ECLASS: ecm.eclass
5 # @MAINTAINER:
6 # kde@gentoo.org
7 # @SUPPORTED_EAPIS: 7
8 # @BLURB: Support eclass for packages that use KDE Frameworks with ECM.
9 # @DESCRIPTION:
10 # This eclass is intended to streamline the creation of ebuilds for packages
11 # that use cmake and KDE Frameworks' extra-cmake-modules, thereby following
12 # some of their packaging conventions. It is primarily intended for the three
13 # upstream release groups (Frameworks, Plasma, Applications) but also for any
14 # other package that follows similar conventions.
15 #
16 # This eclass unconditionally inherits cmake.eclass and all its public
17 # variables and helper functions (not phase functions) may be considered as part
18 # of this eclass's API.
19 #
20 # This eclass's phase functions are not intended to be mixed and matched, so if
21 # any phase functions are overridden the version here should also be called.
22 #
23 # Porting from kde5.class
24 # - Convert all add_*_dep dependency functions to regular dependencies
25 # - Manually set LICENSE
26 # - Manually set SLOT
27 # - Rename vars and function names as needed, see kde5.eclass PORTING comments
28 # - Instead of FRAMEWORKS_MINIMAL, define KFMIN in ebuilds and use it for deps
29
30 if [[ -z ${_ECM_ECLASS} ]]; then
31 _ECM_ECLASS=1
32
33 # @ECLASS-VARIABLE: VIRTUALX_REQUIRED
34 # @DESCRIPTION:
35 # For proper description see virtualx.eclass manpage.
36 # Here we redefine default value to be manual, if your package needs virtualx
37 # for tests you should proceed with setting VIRTUALX_REQUIRED=test.
38 : ${VIRTUALX_REQUIRED:=manual}
39
40 # @ECLASS-VARIABLE: ECM_NONGUI
41 # @DEFAULT_UNSET
42 # @DESCRIPTION:
43 # By default, for all CATEGORIES except kde-frameworks, assume we are building
44 # a GUI application. Add dependency on kde-frameworks/breeze-icons or
45 # kde-frameworks/oxygen-icons and run the xdg.eclass routines for pkg_preinst,
46 # pkg_postinst and pkg_postrm. If set to "true", do nothing.
47 if [[ ${CATEGORY} = kde-frameworks ]] ; then
48         : ${ECM_NONGUI:=true}
49 fi
50 : ${ECM_NONGUI:=false}
51
52 inherit cmake flag-o-matic toolchain-funcs virtualx
53
54 if [[ ${ECM_NONGUI} = false ]] ; then
55         inherit xdg
56 fi
57
58 case ${EAPI} in
59         7) ;;
60         *) die "EAPI=${EAPI:-0} is not supported" ;;
61 esac
62
63 if [[ -v KDE_GCC_MINIMAL ]]; then
64         EXPORT_FUNCTIONS pkg_pretend
65 fi
66
67 EXPORT_FUNCTIONS pkg_setup src_prepare src_configure src_test pkg_preinst pkg_postinst pkg_postrm
68
69 # @ECLASS-VARIABLE: ECM_KDEINSTALLDIRS
70 # @DESCRIPTION:
71 # Assume the package is using KDEInstallDirs macro and switch
72 # KDE_INSTALL_USE_QT_SYS_PATHS to ON. If set to "false", do nothing.
73 : ${ECM_KDEINSTALLDIRS:=true}
74
75 # @ECLASS-VARIABLE: ECM_DEBUG
76 # @DESCRIPTION:
77 # Add "debug" to IUSE. If !debug, add -DNDEBUG (via cmake_src_configure)
78 # and -DQT_NO_DEBUG to CPPFLAGS. If set to "false", do nothing.
79 : ${ECM_DEBUG:=true}
80
81 # @ECLASS-VARIABLE: ECM_DESIGNERPLUGIN
82 # @DESCRIPTION:
83 # If set to "true", add "designer" to IUSE to toggle build of designer plugins
84 # and add the necessary BDEPEND. If set to "false", do nothing.
85 : ${ECM_DESIGNERPLUGIN:=false}
86
87 # @ECLASS-VARIABLE: ECM_EXAMPLES
88 # @DESCRIPTION:
89 # By default unconditionally ignore a top-level examples subdirectory.
90 # If set to "true", add "examples" to IUSE to toggle adding that subdirectory.
91 : ${ECM_EXAMPLES:=false}
92
93 # @ECLASS-VARIABLE: ECM_HANDBOOK
94 # @DESCRIPTION:
95 # Will accept "true", "false", "optional", "forceoptional". If set to "false",
96 # do nothing.
97 # Otherwise, add "+handbook" to IUSE, add the appropriate dependency, and let
98 # KF5DocTools generate and install the handbook from docbook file(s) found in
99 # ECM_HANDBOOK_DIR. However if !handbook, disable build of ECM_HANDBOOK_DIR
100 # in CMakeLists.txt.
101 # If set to "optional", build with -DCMAKE_DISABLE_FIND_PACKAGE_KF5DocTools=ON
102 # when !handbook. In case package requires KF5KDELibs4Support, see next:
103 # If set to "forceoptional", remove a KF5DocTools dependency from the root
104 # CMakeLists.txt in addition to the above.
105 : ${ECM_HANDBOOK:=false}
106
107 # @ECLASS-VARIABLE: ECM_HANDBOOK_DIR
108 # @DESCRIPTION:
109 # Specifies the directory containing the docbook file(s) relative to ${S} to
110 # be processed by KF5DocTools (kdoctools_install).
111 : ${ECM_HANDBOOK_DIR:=doc}
112
113 # @ECLASS-VARIABLE: ECM_PO_DIRS
114 # @DESCRIPTION:
115 # Specifies directories of l10n files relative to ${S} to be processed by
116 # KF5I18n (ki18n_install). If IUSE nls exists and is disabled then disable
117 # build of these directories in CMakeLists.txt.
118 : ${ECM_PO_DIRS:="po poqm"}
119
120 # @ECLASS-VARIABLE: ECM_QTHELP
121 # @DEFAULT_UNSET
122 # @DESCRIPTION:
123 # Default value for all CATEGORIES except kde-frameworks is "false".
124 # If set to "true", add "doc" to IUSE, add the appropriate dependency, let
125 # -DBUILD_QCH=ON generate and install Qt compressed help files when USE=doc.
126 # If set to "false", do nothing.
127 if [[ ${CATEGORY} = kde-frameworks ]]; then
128         : ${ECM_QTHELP:=true}
129 fi
130 : ${ECM_QTHELP:=false}
131
132 # @ECLASS-VARIABLE: ECM_TEST
133 # @DEFAULT_UNSET
134 # @DESCRIPTION:
135 # Will accept "true", "false", "optional", "forceoptional",
136 # "forceoptional-recursive".
137 # Default value is "false", except for CATEGORY=kde-frameworks where it is
138 # set to "true". If set to "false", do nothing.
139 # For any other value, add "test" to IUSE and DEPEND on dev-qt/qttest:5.
140 # If set to "optional", build with -DCMAKE_DISABLE_FIND_PACKAGE_Qt5Test=ON
141 # when USE=!test.
142 # If set to "forceoptional", punt Qt5Test dependency and ignore "autotests",
143 # "test", "tests" subdirs from top-level CMakeLists.txt when USE=!test.
144 # If set to "forceoptional-recursive", punt Qt5Test dependencies and make
145 # autotest(s), unittest(s) and test(s) subdirs from *any* CMakeLists.txt in
146 # ${S} and below conditional on BUILD_TESTING when USE=!test. This is always
147 # meant as a short-term fix and creates ${T}/${P}-tests-optional.patch to
148 # refine and submit upstream.
149 if [[ ${CATEGORY} = kde-frameworks ]]; then
150         : ${ECM_TEST:=true}
151 fi
152 : ${ECM_TEST:=false}
153
154 # @ECLASS-VARIABLE: KFMIN
155 # @DEFAULT_UNSET
156 # @DESCRIPTION:
157 # Minimum version of Frameworks to require. Default value for kde-frameworks
158 # is ${PV} and 5.64.0 baseline for everything else. This is not going to be
159 # changed unless we also bump EAPI, which usually implies (rev-)bumping.
160 # Version will later be used to differentiate between KF5/Qt5 and KF6/Qt6.
161 if [[ ${CATEGORY} = kde-frameworks ]]; then
162         : ${KFMIN:=$(ver_cut 1-2)}
163 fi
164 : ${KFMIN:=5.64.0}
165
166 # @ECLASS-VARIABLE: KFSLOT
167 # @INTERNAL
168 # @DESCRIPTION:
169 # KDE Frameworks and Qt slot dependency, implied by KFMIN version.
170 : ${KFSLOT:=5}
171
172 case ${ECM_NONGUI} in
173         true) ;;
174         false)
175                 # gui applications need breeze or oxygen for basic iconset, bug #564838
176                 if [[ -n ${_KDE5_ECLASS} ]] ; then
177                         RDEPEND+=" || (
178                                 >=kde-frameworks/breeze-icons-${KFMIN}:${KFSLOT}
179                                 kde-frameworks/oxygen-icons:*
180                         )"
181                 else
182                         RDEPEND+=" || (
183                                 kde-frameworks/breeze-icons:*
184                                 kde-frameworks/oxygen-icons:*
185                         )"
186                 fi
187                 ;;
188         *)
189                 eerror "Unknown value for \${ECM_NONGUI}"
190                 die "Value ${ECM_NONGUI} is not supported"
191                 ;;
192 esac
193
194 case ${ECM_DEBUG} in
195         true)
196                 IUSE+=" debug"
197                 ;;
198         false) ;;
199         *)
200                 eerror "Unknown value for \${ECM_DEBUG}"
201                 die "Value ${ECM_DEBUG} is not supported"
202                 ;;
203 esac
204
205 case ${ECM_DESIGNERPLUGIN} in
206         true)
207                 IUSE+=" designer"
208                 if [[ -n ${_KDE5_ECLASS} ]] ; then
209                         BDEPEND+=" designer? ( >=dev-qt/designer-5.12.3:${KFSLOT} )"
210                 else
211                         BDEPEND+=" designer? ( dev-qt/designer:${KFSLOT} )"
212                 fi
213                 ;;
214         false) ;;
215         *)
216                 eerror "Unknown value for \${ECM_DESIGNERPLUGIN}"
217                 die "Value ${ECM_DESIGNERPLUGIN} is not supported"
218                 ;;
219 esac
220
221 # @ECLASS-VARIABLE: KDE_DESIGNERPLUGIN
222 # @DESCRIPTION:
223 # If set to "false", do nothing.
224 # Otherwise, add "designer" to IUSE to toggle build of designer plugins
225 # and add the necessary BDEPEND.
226 # TODO: drop after KDE Applications 19.08.3 removal
227 : ${KDE_DESIGNERPLUGIN:=false}
228 case ${KDE_DESIGNERPLUGIN} in
229         true)
230                 IUSE+=" designer"
231                 BDEPEND+="
232                         designer? ( >=kde-frameworks/kdesignerplugin-${KFMIN}:${KFSLOT} )
233                 "
234                 ;;
235         false) ;;
236         *)
237                 eerror "Unknown value for \${KDE_DESIGNERPLUGIN}"
238                 die "Value ${KDE_DESIGNERPLUGIN} is not supported"
239                 ;;
240 esac
241
242 case ${ECM_EXAMPLES} in
243         true)
244                 IUSE+=" examples"
245                 ;;
246         false) ;;
247         *)
248                 eerror "Unknown value for \${ECM_EXAMPLES}"
249                 die "Value ${ECM_EXAMPLES} is not supported"
250                 ;;
251 esac
252
253 case ${ECM_HANDBOOK} in
254         true|optional|forceoptional)
255                 IUSE+=" +handbook"
256                 BDEPEND+=" handbook? ( >=kde-frameworks/kdoctools-${KFMIN}:${KFSLOT} )"
257                 ;;
258         false) ;;
259         *)
260                 eerror "Unknown value for \${ECM_HANDBOOK}"
261                 die "Value ${ECM_HANDBOOK} is not supported"
262                 ;;
263 esac
264
265 case ${ECM_QTHELP} in
266         true)
267                 IUSE+=" doc"
268                 if [[ -n ${_KDE5_ECLASS} ]] ; then
269                         COMMONDEPEND+=" doc? ( >=dev-qt/qt-docs-5.12.3:${KFSLOT} )"
270                         BDEPEND+=" doc? ( >=dev-qt/qthelp-5.12.3:${KFSLOT} )"
271                 else
272                         COMMONDEPEND+=" doc? ( dev-qt/qt-docs:${KFSLOT} )"
273                         BDEPEND+=" doc? ( dev-qt/qthelp:${KFSLOT} )"
274                 fi
275                 BDEPEND+=" doc? ( >=app-doc/doxygen-1.8.13-r1 )"
276                 ;;
277         false) ;;
278         *)
279                 eerror "Unknown value for \${ECM_QTHELP}"
280                 die "Value ${ECM_QTHELP} is not supported"
281                 ;;
282 esac
283
284 case ${ECM_TEST} in
285         true|optional|forceoptional|forceoptional-recursive)
286                 IUSE+=" test"
287                 if [[ -n ${_KDE5_ECLASS} ]] ; then
288                         DEPEND+=" test? ( >=dev-qt/qttest-5.12.3:${KFSLOT} )"
289                 else
290                         DEPEND+=" test? ( dev-qt/qttest:${KFSLOT} )"
291                 fi
292                 RESTRICT+=" !test? ( test )"
293                 ;;
294         false) ;;
295         *)
296                 eerror "Unknown value for \${ECM_TEST}"
297                 die "Value ${ECM_TEST} is not supported"
298                 ;;
299 esac
300
301 BDEPEND+=" >=kde-frameworks/extra-cmake-modules-${KFMIN}:${KFSLOT}"
302 RDEPEND+=" >=kde-frameworks/kf-env-4"
303 if [[ -n ${_KDE5_ECLASS} ]] ; then
304         COMMONDEPEND+=" >=dev-qt/qtcore-5.12.3:${KFSLOT}"
305 else
306         COMMONDEPEND+=" dev-qt/qtcore:${KFSLOT}"
307 fi
308
309 DEPEND+=" ${COMMONDEPEND}"
310 RDEPEND+=" ${COMMONDEPEND}"
311 unset COMMONDEPEND
312
313 # @FUNCTION: _ecm_banned_var
314 # @INTERNAL
315 # @DESCRIPTION:
316 # Banned kde5*.eclass variables are banned.
317 _ecm_banned_var() {
318         die "$1 is banned. use $2 instead."
319 }
320
321 if [[ -z ${_KDE5_ECLASS} ]] ; then
322         [[ -n ${KDE_DEBUG} ]] && _ecm_banned_var KDE_DEBUG ECM_DEBUG
323         [[ -n ${KDE_EXAMPLES} ]] && _ecm_banned_var KDE_EXAMPLES ECM_EXAMPLES
324         [[ -n ${KDE_HANDBOOK} ]] && _ecm_banned_var KDE_HANDBOOK ECM_HANDBOOK
325         [[ -n ${KDE_DOC_DIR} ]] && _ecm_banned_var KDE_DOC_DIR ECM_HANDBOOK_DIR
326         [[ -n ${KDE_PO_DIRS} ]] && _ecm_banned_var KDE_PO_DIRS ECM_PO_DIRS
327         [[ -n ${KDE_QTHELP} ]] && _ecm_banned_var KDE_QTHELP ECM_QTHELP
328         [[ -n ${KDE_TEST} ]] && _ecm_banned_var KDE_TEST ECM_TEST
329 fi
330
331 # @ECLASS-VARIABLE: KDE_GCC_MINIMAL
332 # @DEFAULT_UNSET
333 # @DESCRIPTION:
334 # Minimum version of active GCC to require. This is checked in
335 # ecm_pkg_pretend and ecm_pkg_setup.
336
337 # @FUNCTION: _ecm_check_gcc_version
338 # @INTERNAL
339 # @DESCRIPTION:
340 # Determine if the current GCC version is acceptable, otherwise die.
341 _ecm_check_gcc_version() {
342         if [[ ${MERGE_TYPE} != binary && -v KDE_GCC_MINIMAL ]] && tc-is-gcc; then
343
344                 local version=$(gcc-version)
345
346                 debug-print "GCC version check activated"
347                 debug-print "Version detected: ${version}"
348                 debug-print "Version required: ${KDE_GCC_MINIMAL}"
349
350                 ver_test ${version} -lt ${KDE_GCC_MINIMAL} &&
351                         die "Sorry, but gcc-${KDE_GCC_MINIMAL} or later is required for this package (found ${version})."
352         fi
353 }
354
355 # @FUNCTION: _ecm_strip_handbook_translations
356 # @INTERNAL
357 # @DESCRIPTION:
358 # If LINGUAS is defined, enable only the requested translations when required.
359 _ecm_strip_handbook_translations() {
360         if ! [[ -v LINGUAS ]]; then
361                 return
362         fi
363
364         local lang po
365         for po in ${ECM_PO_DIRS}; do
366                 if [[ -d ${po} ]] ; then
367                         pushd ${po} > /dev/null || die
368                         local lang
369                         for lang in *; do
370                                 if [[ -e ${lang} ]] && ! has ${lang/.po/} ${LINGUAS} ; then
371                                         case ${lang} in
372                                                 cmake_modules | \
373                                                 CMakeLists.txt | \
374                                                 ${PN}.pot)      ;;
375                                                 *) rm -r ${lang} || die ;;
376                                         esac
377                                         if [[ -e CMakeLists.txt ]] ; then
378                                                 cmake_comment_add_subdirectory ${lang}
379                                                 sed -e "/add_subdirectory([[:space:]]*${lang}\/.*[[:space:]]*)/d" \
380                                                         -i CMakeLists.txt || die
381                                         fi
382                                 fi
383                         done
384                         popd > /dev/null || die
385                 fi
386         done
387 }
388
389 # @FUNCTION: ecm_punt_bogus_dep
390 # @USAGE: <prefix> <dependency>
391 # @DESCRIPTION:
392 # Removes a specified dependency from a find_package call with multiple
393 # components.
394 ecm_punt_bogus_dep() {
395         local prefix=${1}
396         local dep=${2}
397
398         if [[ ! -e "CMakeLists.txt" ]]; then
399                 return
400         fi
401
402         pcregrep -Mni "(?s)find_package\s*\(\s*${prefix}[^)]*?${dep}.*?\)" CMakeLists.txt > "${T}/bogus${dep}"
403
404         # pcregrep returns non-zero on no matches/error
405         if [[ $? -ne 0 ]] ; then
406                 return
407         fi
408
409         local length=$(wc -l "${T}/bogus${dep}" | cut -d " " -f 1)
410         local first=$(head -n 1 "${T}/bogus${dep}" | cut -d ":" -f 1)
411         local last=$(( length + first - 1))
412
413         sed -e "${first},${last}s/${dep}//" -i CMakeLists.txt || die
414
415         if [[ ${length} -eq 1 ]] ; then
416                 sed -e "/find_package\s*(\s*${prefix}\(\s\+\(REQUIRED\|CONFIG\|COMPONENTS\|\${[A-Z0-9_]*}\)\)\+\s*)/Is/^/# removed by ecm.eclass - /" -i CMakeLists.txt || die
417         fi
418 }
419
420 # @FUNCTION: ecm_pkg_pretend
421 # @DESCRIPTION:
422 # Checks if the active compiler meets the minimum version requirements.
423 # phase function is only exported if KDE_GCC_MINIMAL is defined.
424 ecm_pkg_pretend() {
425         debug-print-function ${FUNCNAME} "$@"
426         _ecm_check_gcc_version
427 }
428
429 # @FUNCTION: ecm_pkg_setup
430 # @DESCRIPTION:
431 # Checks if the active compiler meets the minimum version requirements.
432 ecm_pkg_setup() {
433         debug-print-function ${FUNCNAME} "$@"
434         _ecm_check_gcc_version
435 }
436
437 # @FUNCTION: ecm_src_prepare
438 # @DESCRIPTION:
439 # Wrapper for cmake_src_prepare with lots of extra logic for magic
440 # handling of linguas, tests, handbook etc.
441 ecm_src_prepare() {
442         debug-print-function ${FUNCNAME} "$@"
443
444         cmake_src_prepare
445
446         # only build examples when required
447         if ! { in_iuse examples && use examples; } ; then
448                 cmake_comment_add_subdirectory examples
449         fi
450
451         # only enable handbook when required
452         if in_iuse handbook && ! use handbook ; then
453                 cmake_comment_add_subdirectory ${ECM_HANDBOOK_DIR}
454
455                 if [[ ${ECM_HANDBOOK} = forceoptional ]] ; then
456                         ecm_punt_bogus_dep KF5 DocTools
457                         sed -i -e "/kdoctools_install/ s/^/#DONT/" CMakeLists.txt || die
458                 fi
459         fi
460
461         # drop translations when nls is not wanted
462         if in_iuse nls && ! use nls ; then
463                 local po
464                 for po in ${ECM_PO_DIRS}; do
465                         rm -rf ${po} || die
466                 done
467         fi
468
469         # don't change behaviour for kde5.eclass consumers
470         # for ported ebuilds, limit playing field of this to kde-*/ categories
471         if [[ -n ${_KDE5_ECLASS} ]] ; then
472                 _ecm_strip_handbook_translations # TODO: kde5.eclass cleanup
473         elif [[ ${CATEGORY} = kde-* ]] ; then
474                 # always install unconditionally for kconfigwidgets - if you use
475                 # language X as system language, and there is a combobox with language
476                 # names, the translated language name for language Y is taken from
477                 # /usr/share/locale/Y/kf5_entry.desktop
478                 [[ ${PN} != kconfigwidgets ]] && _ecm_strip_handbook_translations
479         fi
480
481         # only build unit tests when required
482         if ! { in_iuse test && use test; } ; then
483                 if [[ ${ECM_TEST} = forceoptional ]] ; then
484                         ecm_punt_bogus_dep Qt5 Test
485                         # if forceoptional, also cover non-kde categories
486                         cmake_comment_add_subdirectory autotests test tests
487                 elif [[ ${ECM_TEST} = forceoptional-recursive ]] ; then
488                         ecm_punt_bogus_dep Qt5 Test
489                         local f pf="${T}/${P}"-tests-optional.patch
490                         touch ${pf} || die "Failed to touch patch file"
491                         for f in $(find . -type f -name "CMakeLists.txt" -exec \
492                                 grep -l "^\s*add_subdirectory\s*\(\s*.*\(auto|unit\)\?tests\?\s*)\s*\)" {} \;); do
493                                 cp ${f} ${f}.old || die "Failed to prepare patch origfile"
494                                 pushd ${f%/*} > /dev/null || die
495                                         ecm_punt_bogus_dep Qt5 Test
496                                         sed -i CMakeLists.txt -e \
497                                                 "/^#/! s/add_subdirectory\s*\(\s*.*\(auto|unit\)\?tests\?\s*)\s*\)/if(BUILD_TESTING)\n&\nendif()/" \
498                                                 || die
499                                 popd > /dev/null || die
500                                 diff -Naur ${f}.old ${f} 1>>${pf}
501                                 rm ${f}.old || die "Failed to clean up"
502                         done
503                         eqawarn "Build system was modified by ECM_TEST=forceoptional-recursive."
504                         eqawarn "Unified diff file ready for pickup in:"
505                         eqawarn "  ${pf}"
506                         eqawarn "Push it upstream to make this message go away."
507                 elif [[ ${CATEGORY} = kde-frameworks || ${CATEGORY} = kde-plasma || ${CATEGORY} = kde-apps ]] ; then
508                         cmake_comment_add_subdirectory autotests test tests
509                 fi
510         fi
511
512         # in frameworks, tests = manual tests so never build them
513         if [[ ${CATEGORY} = kde-frameworks ]] && [[ ${PN} != extra-cmake-modules ]]; then
514                 cmake_comment_add_subdirectory tests
515         fi
516 }
517
518 # @FUNCTION: ecm_src_configure
519 # @DESCRIPTION:
520 # Wrapper for cmake_src_configure with extra logic for magic handling of
521 # handbook, tests etc.
522 ecm_src_configure() {
523         debug-print-function ${FUNCNAME} "$@"
524
525         # we rely on cmake.eclass to append -DNDEBUG too
526         if in_iuse debug && ! use debug; then
527                 append-cppflags -DQT_NO_DEBUG
528         fi
529
530         local cmakeargs
531
532         if in_iuse test && ! use test ; then
533                 cmakeargs+=( -DBUILD_TESTING=OFF )
534
535                 if [[ ${ECM_TEST} = optional ]] ; then
536                         cmakeargs+=( -DCMAKE_DISABLE_FIND_PACKAGE_Qt5Test=ON )
537                 fi
538         fi
539
540         if [[ ${ECM_HANDBOOK} = optional ]] ; then
541                 cmakeargs+=( -DCMAKE_DISABLE_FIND_PACKAGE_KF5DocTools=$(usex !handbook) )
542         fi
543
544         if in_iuse designer && [[ ${ECM_DESIGNERPLUGIN} = true ]]; then
545                 cmakeargs+=( -DBUILD_DESIGNERPLUGIN=$(usex designer) )
546         fi
547
548         # TODO: drop after KDE Applications 19.08.3 removal
549         if in_iuse designer && [[ ${KDE_DESIGNERPLUGIN} != false ]] ; then
550                 cmakeargs+=( $(cmake_use_find_package designer KF5DesignerPlugin) )
551         fi
552
553         if [[ ${ECM_QTHELP} = true ]]; then
554                 cmakeargs+=( -DBUILD_QCH=$(usex doc) )
555         fi
556
557         if [[ ${ECM_KDEINSTALLDIRS} = true ]] ; then
558                 cmakeargs+=(
559                         # install mkspecs in the same directory as Qt stuff
560                         -DKDE_INSTALL_USE_QT_SYS_PATHS=ON
561                         # move handbook outside of doc dir, bug 667138
562                         -DKDE_INSTALL_DOCBUNDLEDIR="${EPREFIX}/usr/share/help"
563                 )
564         fi
565
566         # allow the ebuild to override what we set here
567         mycmakeargs=("${cmakeargs[@]}" "${mycmakeargs[@]}")
568
569         cmake_src_configure
570 }
571
572 # @FUNCTION: ecm_src_compile
573 # @DESCRIPTION:
574 # Wrapper for cmake_src_compile. Currently doesn't do anything extra, but
575 # is included as part of the API just in case it's needed in the future.
576 ecm_src_compile() {
577         debug-print-function ${FUNCNAME} "$@"
578
579         cmake_src_compile "$@"
580 }
581
582 # @FUNCTION: ecm_src_test
583 # @DESCRIPTION:
584 # Wrapper for cmake_src_test with extra logic for magic handling of dbus
585 # and virtualx.
586 ecm_src_test() {
587         debug-print-function ${FUNCNAME} "$@"
588
589         _test_runner() {
590                 if [[ -n "${VIRTUALDBUS_TEST}" ]]; then
591                         export $(dbus-launch)
592                 fi
593
594                 cmake_src_test
595         }
596
597         # When run as normal user during ebuild development with the ebuild command,
598         # tests tend to access the session DBUS. This however is not possible in a
599         # real emerge or on the tinderbox.
600         # make sure it does not happen, so bad tests can be recognized and disabled
601         unset DBUS_SESSION_BUS_ADDRESS DBUS_SESSION_BUS_PID
602
603         if [[ ${VIRTUALX_REQUIRED} = always || ${VIRTUALX_REQUIRED} = test ]]; then
604                 virtx _test_runner
605         else
606                 _test_runner
607         fi
608
609         if [[ -n "${DBUS_SESSION_BUS_PID}" ]] ; then
610                 kill ${DBUS_SESSION_BUS_PID}
611         fi
612 }
613
614 # @FUNCTION: ecm_src_install
615 # @DESCRIPTION:
616 # Wrapper for cmake_src_install. Currently doesn't do anything extra, but
617 # is included as part of the API just in case it's needed in the future.
618 ecm_src_install() {
619         debug-print-function ${FUNCNAME} "$@"
620
621         cmake_src_install
622 }
623
624 # @FUNCTION: ecm_pkg_preinst
625 # @DESCRIPTION:
626 # Sets up environment variables required in ecm_pkg_postinst.
627 ecm_pkg_preinst() {
628         debug-print-function ${FUNCNAME} "$@"
629
630         case ${ECM_NONGUI} in
631                 false) xdg_pkg_preinst ;;
632                 *) ;;
633         esac
634 }
635
636 # @FUNCTION: ecm_pkg_postinst
637 # @DESCRIPTION:
638 # Updates the various XDG caches (icon, desktop, mime) if necessary.
639 ecm_pkg_postinst() {
640         debug-print-function ${FUNCNAME} "$@"
641
642         case ${ECM_NONGUI} in
643                 false) xdg_pkg_postinst ;;
644                 *) ;;
645         esac
646
647         if [[ -n ${_KDE_ORG_ECLASS} ]] && [[ -z ${I_KNOW_WHAT_I_AM_DOING} ]] && [[ ${KDE_BUILD_TYPE} = live ]]; then
648                 einfo "WARNING! This is an experimental live ebuild of ${CATEGORY}/${PN}"
649                 einfo "Use it at your own risk."
650                 einfo "Do _NOT_ file bugs at bugs.gentoo.org because of this ebuild!"
651         fi
652 }
653
654 # @FUNCTION: ecm_pkg_postrm
655 # @DESCRIPTION:
656 # Updates the various XDG caches (icon, desktop, mime) if necessary.
657 ecm_pkg_postrm() {
658         debug-print-function ${FUNCNAME} "$@"
659
660         case ${ECM_NONGUI} in
661                 false) xdg_pkg_postrm ;;
662                 *) ;;
663         esac
664 }
665
666 fi