Gentoo Archives: gentoo-commits

From: "Andreas Hüttel" <dilfridge@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/kde:master commit in: eclass/
Date: Tue, 01 May 2012 20:50:47
Message-Id: 1335904873.b1ebcbfa406006f1a9f7d12cd8583bee05617882.dilfridge@gentoo
1 commit: b1ebcbfa406006f1a9f7d12cd8583bee05617882
2 Author: Andreas K. Huettel (dilfridge) <dilfridge <AT> gentoo <DOT> org>
3 AuthorDate: Tue May 1 18:13:21 2012 +0000
4 Commit: Andreas Hüttel <dilfridge <AT> gentoo <DOT> org>
5 CommitDate: Tue May 1 20:41:13 2012 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/kde.git;a=commit;h=b1ebcbfa
7
8 Copied cmake-utils eclass from main tree
9
10 ---
11 eclass/cmake-utils.eclass | 497 +++++++++++++++++++++++++++++++++++++++++++++
12 1 files changed, 497 insertions(+), 0 deletions(-)
13
14 diff --git a/eclass/cmake-utils.eclass b/eclass/cmake-utils.eclass
15 new file mode 100644
16 index 0000000..7fed054
17 --- /dev/null
18 +++ b/eclass/cmake-utils.eclass
19 @@ -0,0 +1,497 @@
20 +# Copyright 1999-2012 Gentoo Foundation
21 +# Distributed under the terms of the GNU General Public License v2
22 +# $Header: /var/cvsroot/gentoo-x86/eclass/cmake-utils.eclass,v 1.78 2012/04/16 10:28:47 scarabeus Exp $
23 +
24 +# @ECLASS: cmake-utils.eclass
25 +# @MAINTAINER:
26 +# kde@g.o
27 +# @AUTHOR:
28 +# Tomáš Chvátal <scarabeus@g.o>
29 +# Maciej Mrozowski <reavertm@g.o>
30 +# (undisclosed contributors)
31 +# Original author: Zephyrus (zephyrus@××××××.it)
32 +# @BLURB: common ebuild functions for cmake-based packages
33 +# @DESCRIPTION:
34 +# The cmake-utils eclass is base.eclass(5) wrapper that makes creating ebuilds for
35 +# cmake-based packages much easier.
36 +# It provides all inherited features (DOCS, HTML_DOCS, PATCHES) along with out-of-source
37 +# builds (default), in-source builds and an implementation of the well-known use_enable
38 +# and use_with functions for CMake.
39 +
40 +# @ECLASS-VARIABLE: WANT_CMAKE
41 +# @DESCRIPTION:
42 +# Specify if cmake-utils eclass should depend on cmake optionaly or not.
43 +# This is usefull when only part of aplication is using cmake build system.
44 +# Valid values are: always [default], optional (where the value is the useflag
45 +# used for optionality)
46 +WANT_CMAKE="${WANT_CMAKE:-always}"
47 +
48 +# @ECLASS-VARIABLE: CMAKE_MIN_VERSION
49 +# @DESCRIPTION:
50 +# Specify the minimum required CMake version. Default is 2.8.4
51 +CMAKE_MIN_VERSION="${CMAKE_MIN_VERSION:-2.8.4}"
52 +
53 +# @ECLASS-VARIABLE: CMAKE_REMOVE_MODULES_LIST
54 +# @DESCRIPTION:
55 +# Space-separated list of CMake modules that will be removed in $S during src_prepare,
56 +# in order to force packages to use the system version.
57 +CMAKE_REMOVE_MODULES_LIST="${CMAKE_REMOVE_MODULES_LIST:-FindBLAS FindLAPACK}"
58 +
59 +# @ECLASS-VARIABLE: CMAKE_REMOVE_MODULES
60 +# @DESCRIPTION:
61 +# Do we want to remove anything? yes or whatever else for no
62 +CMAKE_REMOVE_MODULES="${CMAKE_REMOVE_MODULES:-yes}"
63 +
64 +CMAKEDEPEND=""
65 +case ${WANT_CMAKE} in
66 + always)
67 + ;;
68 + *)
69 + IUSE+=" ${WANT_CMAKE}"
70 + CMAKEDEPEND+="${WANT_CMAKE}? ( "
71 + ;;
72 +esac
73 +inherit toolchain-funcs multilib flag-o-matic base
74 +
75 +CMAKE_EXPF="src_compile src_test src_install"
76 +case ${EAPI:-0} in
77 + 4|3|2) CMAKE_EXPF+=" src_configure" ;;
78 + 1|0) ;;
79 + *) die "Unknown EAPI, Bug eclass maintainers." ;;
80 +esac
81 +EXPORT_FUNCTIONS ${CMAKE_EXPF}
82 +
83 +: ${DESCRIPTION:="Based on the ${ECLASS} eclass"}
84 +
85 +if [[ ${PN} != cmake ]]; then
86 + CMAKEDEPEND+=" >=dev-util/cmake-${CMAKE_MIN_VERSION}"
87 +fi
88 +
89 +CMAKEDEPEND+=" userland_GNU? ( >=sys-apps/findutils-4.4.0 )"
90 +
91 +[[ ${WANT_CMAKE} = always ]] || CMAKEDEPEND+=" )"
92 +
93 +DEPEND="${CMAKEDEPEND}"
94 +unset CMAKEDEPEND
95 +
96 +# Internal functions used by cmake-utils_use_*
97 +_use_me_now() {
98 + debug-print-function ${FUNCNAME} "$@"
99 +
100 + local uper capitalised x
101 + [[ -z $2 ]] && die "cmake-utils_use-$1 <USE flag> [<flag name>]"
102 + if [[ ! -z $3 ]]; then
103 + # user specified the use name so use it
104 + echo "-D$1$3=$(use $2 && echo ON || echo OFF)"
105 + else
106 + # use all various most used combinations
107 + uper=$(echo ${2} | tr '[:lower:]' '[:upper:]')
108 + capitalised=$(echo ${2} | sed 's/\<\(.\)\([^ ]*\)/\u\1\L\2/g')
109 + for x in $2 $uper $capitalised; do
110 + echo "-D$1$x=$(use $2 && echo ON || echo OFF) "
111 + done
112 + fi
113 +}
114 +_use_me_now_inverted() {
115 + debug-print-function ${FUNCNAME} "$@"
116 +
117 + local uper capitalised x
118 + [[ -z $2 ]] && die "cmake-utils_use-$1 <USE flag> [<flag name>]"
119 + if [[ ! -z $3 ]]; then
120 + # user specified the use name so use it
121 + echo "-D$1$3=$(use $2 && echo OFF || echo ON)"
122 + else
123 + # use all various most used combinations
124 + uper=$(echo ${2} | tr '[:lower:]' '[:upper:]')
125 + capitalised=$(echo ${2} | sed 's/\<\(.\)\([^ ]*\)/\u\1\L\2/g')
126 + for x in $2 $uper $capitalised; do
127 + echo "-D$1$x=$(use $2 && echo OFF || echo ON) "
128 + done
129 + fi
130 +}
131 +
132 +# @ECLASS-VARIABLE: CMAKE_BUILD_DIR
133 +# @DESCRIPTION:
134 +# Build directory where all cmake processed files should be generated.
135 +# For in-source build it's fixed to ${CMAKE_USE_DIR}.
136 +# For out-of-source build it can be overriden, by default it uses
137 +# ${WORKDIR}/${P}_build.
138 +
139 +# @ECLASS-VARIABLE: CMAKE_BUILD_TYPE
140 +# @DESCRIPTION:
141 +# Set to override default CMAKE_BUILD_TYPE. Only useful for packages
142 +# known to make use of "if (CMAKE_BUILD_TYPE MATCHES xxx)".
143 +# If about to be set - needs to be set before invoking cmake-utils_src_configure.
144 +# You usualy do *NOT* want nor need to set it as it pulls CMake default build-type
145 +# specific compiler flags overriding make.conf.
146 +: ${CMAKE_BUILD_TYPE:=Gentoo}
147 +
148 +# @ECLASS-VARIABLE: CMAKE_IN_SOURCE_BUILD
149 +# @DESCRIPTION:
150 +# Set to enable in-source build.
151 +
152 +# @ECLASS-VARIABLE: CMAKE_USE_DIR
153 +# @DESCRIPTION:
154 +# Sets the directory where we are working with cmake.
155 +# For example when application uses autotools and only one
156 +# plugin needs to be done by cmake.
157 +# By default it uses ${S}.
158 +
159 +# @ECLASS-VARIABLE: CMAKE_VERBOSE
160 +# @DESCRIPTION:
161 +# Set to enable verbose messages during compilation.
162 +
163 +# @ECLASS-VARIABLE: PREFIX
164 +# @DESCRIPTION:
165 +# Eclass respects PREFIX variable, though it's not recommended way to set
166 +# install/lib/bin prefixes.
167 +# Use -DCMAKE_INSTALL_PREFIX=... CMake variable instead.
168 +
169 +# @ECLASS-VARIABLE: CMAKE_BINARY
170 +# @DESCRIPTION:
171 +# Eclass can use different cmake binary than the one provided in by system.
172 +: ${CMAKE_BINARY:=cmake}
173 +
174 +# Determine using IN or OUT source build
175 +_check_build_dir() {
176 + : ${CMAKE_USE_DIR:=${S}}
177 + if [[ -n ${CMAKE_IN_SOURCE_BUILD} ]]; then
178 + # we build in source dir
179 + CMAKE_BUILD_DIR="${CMAKE_USE_DIR}"
180 + else
181 + : ${CMAKE_BUILD_DIR:=${WORKDIR}/${P}_build}
182 + fi
183 + mkdir -p "${CMAKE_BUILD_DIR}"
184 + echo ">>> Working in BUILD_DIR: \"$CMAKE_BUILD_DIR\""
185 +}
186 +# @FUNCTION: cmake-utils_use_with
187 +# @USAGE: <USE flag> [flag name]
188 +# @DESCRIPTION:
189 +# Based on use_with. See ebuild(5).
190 +#
191 +# `cmake-utils_use_with foo FOO` echoes -DWITH_FOO=ON if foo is enabled
192 +# and -DWITH_FOO=OFF if it is disabled.
193 +cmake-utils_use_with() { _use_me_now WITH_ "$@" ; }
194 +
195 +# @FUNCTION: cmake-utils_use_enable
196 +# @USAGE: <USE flag> [flag name]
197 +# @DESCRIPTION:
198 +# Based on use_enable. See ebuild(5).
199 +#
200 +# `cmake-utils_use_enable foo FOO` echoes -DENABLE_FOO=ON if foo is enabled
201 +# and -DENABLE_FOO=OFF if it is disabled.
202 +cmake-utils_use_enable() { _use_me_now ENABLE_ "$@" ; }
203 +
204 +# @FUNCTION: cmake-utils_use_disable
205 +# @USAGE: <USE flag> [flag name]
206 +# @DESCRIPTION:
207 +# Based on inversion of use_enable. See ebuild(5).
208 +#
209 +# `cmake-utils_use_enable foo FOO` echoes -DDISABLE_FOO=OFF if foo is enabled
210 +# and -DDISABLE_FOO=ON if it is disabled.
211 +cmake-utils_use_disable() { _use_me_now_inverted DISABLE_ "$@" ; }
212 +
213 +# @FUNCTION: cmake-utils_use_no
214 +# @USAGE: <USE flag> [flag name]
215 +# @DESCRIPTION:
216 +# Based on use_disable. See ebuild(5).
217 +#
218 +# `cmake-utils_use_no foo FOO` echoes -DNO_FOO=OFF if foo is enabled
219 +# and -DNO_FOO=ON if it is disabled.
220 +cmake-utils_use_no() { _use_me_now_inverted NO_ "$@" ; }
221 +
222 +# @FUNCTION: cmake-utils_use_want
223 +# @USAGE: <USE flag> [flag name]
224 +# @DESCRIPTION:
225 +# Based on use_enable. See ebuild(5).
226 +#
227 +# `cmake-utils_use_want foo FOO` echoes -DWANT_FOO=ON if foo is enabled
228 +# and -DWANT_FOO=OFF if it is disabled.
229 +cmake-utils_use_want() { _use_me_now WANT_ "$@" ; }
230 +
231 +# @FUNCTION: cmake-utils_use_build
232 +# @USAGE: <USE flag> [flag name]
233 +# @DESCRIPTION:
234 +# Based on use_enable. See ebuild(5).
235 +#
236 +# `cmake-utils_use_build foo FOO` echoes -DBUILD_FOO=ON if foo is enabled
237 +# and -DBUILD_FOO=OFF if it is disabled.
238 +cmake-utils_use_build() { _use_me_now BUILD_ "$@" ; }
239 +
240 +# @FUNCTION: cmake-utils_use_has
241 +# @USAGE: <USE flag> [flag name]
242 +# @DESCRIPTION:
243 +# Based on use_enable. See ebuild(5).
244 +#
245 +# `cmake-utils_use_has foo FOO` echoes -DHAVE_FOO=ON if foo is enabled
246 +# and -DHAVE_FOO=OFF if it is disabled.
247 +cmake-utils_use_has() { _use_me_now HAVE_ "$@" ; }
248 +
249 +# @FUNCTION: cmake-utils_use_use
250 +# @USAGE: <USE flag> [flag name]
251 +# @DESCRIPTION:
252 +# Based on use_enable. See ebuild(5).
253 +#
254 +# `cmake-utils_use_use foo FOO` echoes -DUSE_FOO=ON if foo is enabled
255 +# and -DUSE_FOO=OFF if it is disabled.
256 +cmake-utils_use_use() { _use_me_now USE_ "$@" ; }
257 +
258 +# @FUNCTION: cmake-utils_use
259 +# @USAGE: <USE flag> [flag name]
260 +# @DESCRIPTION:
261 +# Based on use_enable. See ebuild(5).
262 +#
263 +# `cmake-utils_use foo FOO` echoes -DFOO=ON if foo is enabled
264 +# and -DFOO=OFF if it is disabled.
265 +cmake-utils_use() { _use_me_now "" "$@" ; }
266 +
267 +# Internal function for modifying hardcoded definitions.
268 +# Removes dangerous definitions that override Gentoo settings.
269 +_modify-cmakelists() {
270 + debug-print-function ${FUNCNAME} "$@"
271 +
272 + # Only edit the files once
273 + grep -qs "<<< Gentoo configuration >>>" CMakeLists.txt && return 0
274 +
275 + # Comment out all set (<some_should_be_user_defined_variable> value)
276 + # TODO Add QA checker - inform when variable being checked for below is set in CMakeLists.txt
277 + find "${CMAKE_USE_DIR}" -name CMakeLists.txt \
278 + -exec sed -i -e '/^[[:space:]]*[sS][eE][tT][[:space:]]*([[:space:]]*CMAKE_BUILD_TYPE.*)/{s/^/#IGNORE /g}' {} + \
279 + -exec sed -i -e '/^[[:space:]]*[sS][eE][tT][[:space:]]*([[:space:]]*CMAKE_COLOR_MAKEFILE.*)/{s/^/#IGNORE /g}' {} + \
280 + -exec sed -i -e '/^[[:space:]]*[sS][eE][tT][[:space:]]*([[:space:]]*CMAKE_INSTALL_PREFIX.*)/{s/^/#IGNORE /g}' {} + \
281 + -exec sed -i -e '/^[[:space:]]*[sS][eE][tT][[:space:]]*([[:space:]]*CMAKE_VERBOSE_MAKEFILE.*)/{s/^/#IGNORE /g}' {} + \
282 + || die "${LINENO}: failed to disable hardcoded settings"
283 +
284 + # NOTE Append some useful summary here
285 + cat >> "${CMAKE_USE_DIR}"/CMakeLists.txt <<- _EOF_
286 +
287 + MESSAGE(STATUS "<<< Gentoo configuration >>>
288 + Build type \${CMAKE_BUILD_TYPE}
289 + Install path \${CMAKE_INSTALL_PREFIX}
290 + Compiler flags:
291 + C \${CMAKE_C_FLAGS}
292 + C++ \${CMAKE_CXX_FLAGS}
293 + Linker flags:
294 + Executable \${CMAKE_EXE_LINKER_FLAGS}
295 + Module \${CMAKE_MODULE_LINKER_FLAGS}
296 + Shared \${CMAKE_SHARED_LINKER_FLAGS}\n")
297 + _EOF_
298 +}
299 +
300 +enable_cmake-utils_src_configure() {
301 + debug-print-function ${FUNCNAME} "$@"
302 +
303 + [[ "${CMAKE_REMOVE_MODULES}" == "yes" ]] && {
304 + local name
305 + for name in ${CMAKE_REMOVE_MODULES_LIST} ; do
306 + find "${S}" -name ${name}.cmake -exec rm -v {} +
307 + done
308 + }
309 +
310 + _check_build_dir
311 +
312 + # check if CMakeLists.txt exist and if no then die
313 + if [[ ! -e ${CMAKE_USE_DIR}/CMakeLists.txt ]] ; then
314 + eerror "Unable to locate CMakeLists.txt under:"
315 + eerror "\"${CMAKE_USE_DIR}/CMakeLists.txt\""
316 + eerror "Consider not inheriting the cmake eclass."
317 + die "FATAL: Unable to find CMakeLists.txt"
318 + fi
319 +
320 + # Remove dangerous things.
321 + _modify-cmakelists
322 +
323 + # Fix xdg collision with sandbox
324 + export XDG_CONFIG_HOME="${T}"
325 +
326 + # @SEE CMAKE_BUILD_TYPE
327 + if [[ ${CMAKE_BUILD_TYPE} = Gentoo ]]; then
328 + # Handle release builds
329 + if ! has debug ${IUSE//+} || ! use debug; then
330 + append-cppflags -DNDEBUG
331 + fi
332 + fi
333 +
334 + # Prepare Gentoo override rules (set valid compiler, append CPPFLAGS)
335 + local build_rules=${CMAKE_BUILD_DIR}/gentoo_rules.cmake
336 + cat > "${build_rules}" <<- _EOF_
337 + SET (CMAKE_C_COMPILER $(type -P $(tc-getCC)) CACHE FILEPATH "C compiler" FORCE)
338 + SET (CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> <DEFINES> ${CPPFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "C compile command" FORCE)
339 + SET (CMAKE_CXX_COMPILER $(type -P $(tc-getCXX)) CACHE FILEPATH "C++ compiler" FORCE)
340 + SET (CMAKE_CXX_COMPILE_OBJECT "<CMAKE_CXX_COMPILER> <DEFINES> ${CPPFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "C++ compile command" FORCE)
341 + _EOF_
342 +
343 + has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
344 +
345 + if [[ ${EPREFIX} ]]; then
346 + cat >> "${build_rules}" <<- _EOF_
347 + # in Prefix we need rpath and must ensure cmake gets our default linker path
348 + # right ... except for Darwin hosts
349 + IF (NOT APPLE)
350 + SET (CMAKE_SKIP_RPATH OFF CACHE BOOL "" FORCE)
351 + SET (CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH "${EPREFIX}/usr/${CHOST}/lib/gcc;${EPREFIX}/usr/${CHOST}/lib;${EPREFIX}/usr/$(get_libdir);${EPREFIX}/$(get_libdir)"
352 + CACHE STRING "" FORCE)
353 +
354 + ELSE ()
355 +
356 + SET(CMAKE_PREFIX_PATH "${EPREFIX}${PREFIX:-/usr}" CACHE STRING ""FORCE)
357 + SET(CMAKE_SKIP_BUILD_RPATH OFF CACHE BOOL "" FORCE)
358 + SET(CMAKE_SKIP_RPATH OFF CACHE BOOL "" FORCE)
359 + SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE CACHE BOOL "")
360 + SET(CMAKE_INSTALL_RPATH "${EPREFIX}${PREFIX:-/usr}/lib;${EPREFIX}/usr/${CHOST}/lib/gcc;${EPREFIX}/usr/${CHOST}/lib;${EPREFIX}/usr/$(get_libdir);${EPREFIX}/$(get_libdir)" CACHE STRING "" FORCE)
361 + SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE CACHE BOOL "" FORCE)
362 + SET(CMAKE_INSTALL_NAME_DIR "${EPREFIX}${PREFIX:-/usr}/lib" CACHE STRING "" FORCE)
363 +
364 + ENDIF (NOT APPLE)
365 + _EOF_
366 + fi
367 +
368 + # Common configure parameters (invariants)
369 + local common_config=${CMAKE_BUILD_DIR}/gentoo_common_config.cmake
370 + local libdir=$(get_libdir)
371 + cat > "${common_config}" <<- _EOF_
372 + SET (LIB_SUFFIX ${libdir/lib} CACHE STRING "library path suffix" FORCE)
373 + SET (CMAKE_INSTALL_LIBDIR ${libdir} CACHE PATH "Output directory for libraries")
374 + _EOF_
375 + [[ "${NOCOLOR}" = true || "${NOCOLOR}" = yes ]] && echo 'SET (CMAKE_COLOR_MAKEFILE OFF CACHE BOOL "pretty colors during make" FORCE)' >> "${common_config}"
376 +
377 + # Convert mycmakeargs to an array, for backwards compatibility
378 + # Make the array a local variable since <=portage-2.1.6.x does not
379 + # support global arrays (see bug #297255).
380 + if [[ $(declare -p mycmakeargs 2>&-) != "declare -a mycmakeargs="* ]]; then
381 + local mycmakeargs_local=(${mycmakeargs})
382 + else
383 + local mycmakeargs_local=("${mycmakeargs[@]}")
384 + fi
385 +
386 + # Common configure parameters (overridable)
387 + # NOTE CMAKE_BUILD_TYPE can be only overriden via CMAKE_BUILD_TYPE eclass variable
388 + # No -DCMAKE_BUILD_TYPE=xxx definitions will be in effect.
389 + local cmakeargs=(
390 + --no-warn-unused-cli
391 + -C "${common_config}"
392 + -DCMAKE_INSTALL_PREFIX="${EPREFIX}${PREFIX:-/usr}"
393 + "${mycmakeargs_local[@]}"
394 + -DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}"
395 + -DCMAKE_INSTALL_DO_STRIP=OFF
396 + -DCMAKE_USER_MAKE_RULES_OVERRIDE="${build_rules}"
397 + "${MYCMAKEARGS}"
398 + )
399 +
400 + pushd "${CMAKE_BUILD_DIR}" > /dev/null
401 + debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: mycmakeargs is ${mycmakeargs_local[*]}"
402 + echo "${CMAKE_BINARY}" "${cmakeargs[@]}" "${CMAKE_USE_DIR}"
403 + "${CMAKE_BINARY}" "${cmakeargs[@]}" "${CMAKE_USE_DIR}" || die "cmake failed"
404 + popd > /dev/null
405 +}
406 +
407 +enable_cmake-utils_src_compile() {
408 + debug-print-function ${FUNCNAME} "$@"
409 +
410 + has src_configure ${CMAKE_EXPF} || cmake-utils_src_configure
411 + cmake-utils_src_make "$@"
412 +}
413 +
414 +# @FUNCTION: cmake-utils_src_make
415 +# @DESCRIPTION:
416 +# Function for building the package. Automatically detects the build type.
417 +# All arguments are passed to emake.
418 +cmake-utils_src_make() {
419 + debug-print-function ${FUNCNAME} "$@"
420 +
421 + _check_build_dir
422 + pushd "${CMAKE_BUILD_DIR}" > /dev/null
423 + # first check if Makefile exist otherwise die
424 + [[ -e Makefile ]] || die "Makefile not found. Error during configure stage."
425 + if [[ -n ${CMAKE_VERBOSE} ]]; then
426 + emake VERBOSE=1 "$@" || die "Make failed!"
427 + else
428 + emake "$@" || die "Make failed!"
429 + fi
430 + popd > /dev/null
431 +}
432 +
433 +enable_cmake-utils_src_install() {
434 + debug-print-function ${FUNCNAME} "$@"
435 +
436 + _check_build_dir
437 + pushd "${CMAKE_BUILD_DIR}" > /dev/null
438 + base_src_install "$@"
439 + popd > /dev/null
440 +
441 + # Backward compatibility, for non-array variables
442 + if [[ -n "${DOCS}" ]] && [[ "$(declare -p DOCS 2>/dev/null 2>&1)" != "declare -a"* ]]; then
443 + dodoc ${DOCS} || die "dodoc failed"
444 + fi
445 + if [[ -n "${HTML_DOCS}" ]] && [[ "$(declare -p HTML_DOCS 2>/dev/null 2>&1)" != "declare -a"* ]]; then
446 + dohtml -r ${HTML_DOCS} || die "dohtml failed"
447 + fi
448 +}
449 +
450 +enable_cmake-utils_src_test() {
451 + debug-print-function ${FUNCNAME} "$@"
452 + local ctestargs
453 +
454 + _check_build_dir
455 + pushd "${CMAKE_BUILD_DIR}" > /dev/null
456 + [[ -e CTestTestfile.cmake ]] || { echo "No tests found. Skipping."; return 0 ; }
457 +
458 + [[ -n ${TEST_VERBOSE} ]] && ctestargs="--extra-verbose --output-on-failure"
459 +
460 + if ctest ${ctestargs} "$@" ; then
461 + einfo "Tests succeeded."
462 + else
463 + if [[ -n "${CMAKE_YES_I_WANT_TO_SEE_THE_TEST_LOG}" ]] ; then
464 + # on request from Diego
465 + eerror "Tests failed. Test log ${CMAKE_BUILD_DIR}/Testing/Temporary/LastTest.log follows:"
466 + eerror "--START TEST LOG--------------------------------------------------------------"
467 + cat "${CMAKE_BUILD_DIR}/Testing/Temporary/LastTest.log"
468 + eerror "--END TEST LOG----------------------------------------------------------------"
469 + die "Tests failed."
470 + else
471 + die "Tests failed. When you file a bug, please attach the following file: \n\t${CMAKE_BUILD_DIR}/Testing/Temporary/LastTest.log"
472 + fi
473 + fi
474 + popd > /dev/null
475 +}
476 +
477 +# @FUNCTION: cmake-utils_src_configure
478 +# @DESCRIPTION:
479 +# General function for configuring with cmake. Default behaviour is to start an
480 +# out-of-source build.
481 +cmake-utils_src_configure() {
482 + _execute_optionaly "src_configure" "$@"
483 +}
484 +
485 +# @FUNCTION: cmake-utils_src_compile
486 +# @DESCRIPTION:
487 +# General function for compiling with cmake. Default behaviour is to check for
488 +# EAPI and respectively to configure as well or just compile.
489 +# Automatically detects the build type. All arguments are passed to emake.
490 +cmake-utils_src_compile() {
491 + _execute_optionaly "src_compile" "$@"
492 +}
493 +
494 +# @FUNCTION: cmake-utils_src_install
495 +# @DESCRIPTION:
496 +# Function for installing the package. Automatically detects the build type.
497 +cmake-utils_src_install() {
498 + _execute_optionaly "src_install" "$@"
499 +}
500 +
501 +# @FUNCTION: cmake-utils_src_test
502 +# @DESCRIPTION:
503 +# Function for testing the package. Automatically detects the build type.
504 +cmake-utils_src_test() {
505 + _execute_optionaly "src_test" "$@"
506 +}
507 +
508 +# Optionally executes phases based on WANT_CMAKE variable/USE flag.
509 +_execute_optionaly() {
510 + local phase="$1" ; shift
511 + if [[ ${WANT_CMAKE} = always ]]; then
512 + enable_cmake-utils_${phase} "$@"
513 + else
514 + use ${WANT_CMAKE} && enable_cmake-utils_${phase} "$@"
515 + fi
516 +}