/[gentoo-x86]/eclass/cmake-utils.eclass
Gentoo

Diff of /eclass/cmake-utils.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.82 Revision 1.96
1# Copyright 1999-2012 Gentoo Foundation 1# Copyright 1999-2013 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/cmake-utils.eclass,v 1.82 2012/09/27 16:35:41 axs Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/cmake-utils.eclass,v 1.96 2013/06/14 21:13:43 creffett Exp $
4 4
5# @ECLASS: cmake-utils.eclass 5# @ECLASS: cmake-utils.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# kde@gentoo.org 7# kde@gentoo.org
8# @AUTHOR: 8# @AUTHOR:
16# cmake-based packages much easier. 16# cmake-based packages much easier.
17# It provides all inherited features (DOCS, HTML_DOCS, PATCHES) along with out-of-source 17# It provides all inherited features (DOCS, HTML_DOCS, PATCHES) along with out-of-source
18# builds (default), in-source builds and an implementation of the well-known use_enable 18# builds (default), in-source builds and an implementation of the well-known use_enable
19# and use_with functions for CMake. 19# and use_with functions for CMake.
20 20
21if [[ ${___ECLASS_ONCE_CMAKE_UTILS} != "recur -_+^+_- spank" ]] ; then
22___ECLASS_ONCE_CMAKE_UTILS="recur -_+^+_- spank"
23
21# @ECLASS-VARIABLE: WANT_CMAKE 24# @ECLASS-VARIABLE: WANT_CMAKE
22# @DESCRIPTION: 25# @DESCRIPTION:
23# Specify if cmake-utils eclass should depend on cmake optionaly or not. 26# Specify if cmake-utils eclass should depend on cmake optionaly or not.
24# This is usefull when only part of aplication is using cmake build system. 27# This is usefull when only part of aplication is using cmake build system.
25# Valid values are: always [default], optional (where the value is the useflag 28# Valid values are: always [default], optional (where the value is the useflag
26# used for optionality) 29# used for optionality)
27WANT_CMAKE="${WANT_CMAKE:-always}" 30WANT_CMAKE="${WANT_CMAKE:-always}"
28 31
29# @ECLASS-VARIABLE: CMAKE_MIN_VERSION 32# @ECLASS-VARIABLE: CMAKE_MIN_VERSION
30# @DESCRIPTION: 33# @DESCRIPTION:
31# Specify the minimum required CMake version. Default is 2.8.4 34# Specify the minimum required CMake version.
32CMAKE_MIN_VERSION="${CMAKE_MIN_VERSION:-2.8.4}" 35CMAKE_MIN_VERSION="${CMAKE_MIN_VERSION:-2.8.9}"
33 36
34# @ECLASS-VARIABLE: CMAKE_REMOVE_MODULES_LIST 37# @ECLASS-VARIABLE: CMAKE_REMOVE_MODULES_LIST
35# @DESCRIPTION: 38# @DESCRIPTION:
36# Space-separated list of CMake modules that will be removed in $S during src_prepare, 39# Space-separated list of CMake modules that will be removed in $S during src_prepare,
37# in order to force packages to use the system version. 40# in order to force packages to use the system version.
42# Do we want to remove anything? yes or whatever else for no 45# Do we want to remove anything? yes or whatever else for no
43CMAKE_REMOVE_MODULES="${CMAKE_REMOVE_MODULES:-yes}" 46CMAKE_REMOVE_MODULES="${CMAKE_REMOVE_MODULES:-yes}"
44 47
45# @ECLASS-VARIABLE: CMAKE_MAKEFILE_GENERATOR 48# @ECLASS-VARIABLE: CMAKE_MAKEFILE_GENERATOR
46# @DESCRIPTION: 49# @DESCRIPTION:
47# Specify a makefile generator to be used by cmake. At this point only "make" 50# Specify a makefile generator to be used by cmake.
48# and "ninja" is supported. 51# At this point only "emake" and "ninja" are supported.
49CMAKE_MAKEFILE_GENERATOR="${CMAKE_MAKEFILE_GENERATOR:-make}" 52CMAKE_MAKEFILE_GENERATOR="${CMAKE_MAKEFILE_GENERATOR:-emake}"
50 53
51CMAKEDEPEND="" 54CMAKEDEPEND=""
52case ${WANT_CMAKE} in 55case ${WANT_CMAKE} in
53 always) 56 always)
54 ;; 57 ;;
59esac 62esac
60inherit toolchain-funcs multilib flag-o-matic base 63inherit toolchain-funcs multilib flag-o-matic base
61 64
62CMAKE_EXPF="src_compile src_test src_install" 65CMAKE_EXPF="src_compile src_test src_install"
63case ${EAPI:-0} in 66case ${EAPI:-0} in
64 2|3|4|5) CMAKE_EXPF+=" src_configure" ;; 67 2|3|4|5) CMAKE_EXPF+=" src_prepare src_configure" ;;
65 1|0) ;; 68 1|0) eqawarn "${CATEGORY}/${PF}: EAPI 0 and 1 support is now deprecated."
69 eqawarn "If you are the package maintainer, please"
70 eqawarn "update this package to a newer EAPI."
71 eqawarn "Support for EAPI 0-1 for 'cmake-utils.eclass'"
72 eqawarn "will be dropped at the beginning of July."
73 ;;
74
66 *) die "Unknown EAPI, Bug eclass maintainers." ;; 75 *) die "Unknown EAPI, Bug eclass maintainers." ;;
67esac 76esac
68EXPORT_FUNCTIONS ${CMAKE_EXPF} 77EXPORT_FUNCTIONS ${CMAKE_EXPF}
78
79case ${CMAKE_MAKEFILE_GENERATOR} in
80 emake)
81 CMAKEDEPEND+=" sys-devel/make"
82 ;;
83 ninja)
84 CMAKEDEPEND+=" dev-util/ninja"
85 ;;
86 *)
87 eerror "Unknown value for \${CMAKE_MAKEFILE_GENERATOR}"
88 die "Value ${CMAKE_MAKEFILE_GENERATOR} is not supported"
89 ;;
90esac
69 91
70if [[ ${PN} != cmake ]]; then 92if [[ ${PN} != cmake ]]; then
71 CMAKEDEPEND+=" >=dev-util/cmake-${CMAKE_MIN_VERSION}" 93 CMAKEDEPEND+=" >=dev-util/cmake-${CMAKE_MIN_VERSION}"
72fi 94fi
73 95
112 echo "-D$1$x=$(use $2 && echo OFF || echo ON) " 134 echo "-D$1$x=$(use $2 && echo OFF || echo ON) "
113 done 135 done
114 fi 136 fi
115} 137}
116 138
117# @ECLASS-VARIABLE: CMAKE_BUILD_DIR 139# @ECLASS-VARIABLE: BUILD_DIR
118# @DESCRIPTION: 140# @DESCRIPTION:
119# Build directory where all cmake processed files should be generated. 141# Build directory where all cmake processed files should be generated.
120# For in-source build it's fixed to ${CMAKE_USE_DIR}. 142# For in-source build it's fixed to ${CMAKE_USE_DIR}.
121# For out-of-source build it can be overriden, by default it uses 143# For out-of-source build it can be overriden, by default it uses
122# ${WORKDIR}/${P}_build. 144# ${WORKDIR}/${P}_build.
145#
146# This variable has been called CMAKE_BUILD_DIR formerly.
147# It is set under that name for compatibility.
123 148
124# @ECLASS-VARIABLE: CMAKE_BUILD_TYPE 149# @ECLASS-VARIABLE: CMAKE_BUILD_TYPE
125# @DESCRIPTION: 150# @DESCRIPTION:
126# Set to override default CMAKE_BUILD_TYPE. Only useful for packages 151# Set to override default CMAKE_BUILD_TYPE. Only useful for packages
127# known to make use of "if (CMAKE_BUILD_TYPE MATCHES xxx)". 152# known to make use of "if (CMAKE_BUILD_TYPE MATCHES xxx)".
161# Determine using IN or OUT source build 186# Determine using IN or OUT source build
162_check_build_dir() { 187_check_build_dir() {
163 : ${CMAKE_USE_DIR:=${S}} 188 : ${CMAKE_USE_DIR:=${S}}
164 if [[ -n ${CMAKE_IN_SOURCE_BUILD} ]]; then 189 if [[ -n ${CMAKE_IN_SOURCE_BUILD} ]]; then
165 # we build in source dir 190 # we build in source dir
166 CMAKE_BUILD_DIR="${CMAKE_USE_DIR}" 191 BUILD_DIR="${CMAKE_USE_DIR}"
167 else 192 else
193 # Respect both the old variable and the new one, depending
194 # on which one was set by the ebuild.
195 if [[ ! ${BUILD_DIR} && ${CMAKE_BUILD_DIR} ]]; then
196 eqawarn "The CMAKE_BUILD_DIR variable has been renamed to BUILD_DIR."
197 eqawarn "Please migrate the ebuild to use the new one."
198
199 # In the next call, both variables will be set already
200 # and we'd have to know which one takes precedence.
201 _RESPECT_CMAKE_BUILD_DIR=1
202 fi
203
204 if [[ ${_RESPECT_CMAKE_BUILD_DIR} ]]; then
205 BUILD_DIR=${CMAKE_BUILD_DIR:-${WORKDIR}/${P}_build}
206 else
168 : ${CMAKE_BUILD_DIR:=${WORKDIR}/${P}_build} 207 : ${BUILD_DIR:=${WORKDIR}/${P}_build}
169 fi 208 fi
209 fi
210
211 # Backwards compatibility for getting the value.
212 CMAKE_BUILD_DIR=${BUILD_DIR}
213
170 mkdir -p "${CMAKE_BUILD_DIR}" 214 mkdir -p "${BUILD_DIR}"
171 echo ">>> Working in BUILD_DIR: \"$CMAKE_BUILD_DIR\"" 215 echo ">>> Working in BUILD_DIR: \"$BUILD_DIR\""
172} 216}
173 217
174# Determine which generator to use 218# Determine which generator to use
175_generator_to_use() { 219_generator_to_use() {
176 if [[ ${CMAKE_MAKEFILE_GENERATOR} = "ninja" ]]; then 220 local generator_name
177 has_version dev-util/ninja && echo "Ninja" && return 221
178 fi 222 case ${CMAKE_MAKEFILE_GENERATOR} in
179 echo "Unix Makefiles" 223 ninja)
224 generator_name="Ninja"
225 ;;
226 emake)
227 generator_name="Unix Makefiles"
228 ;;
229 *)
230 eerror "Unknown value for \${CMAKE_MAKEFILE_GENERATOR}"
231 die "Value ${CMAKE_MAKEFILE_GENERATOR} is not supported"
232 ;;
233 esac
234
235 echo ${generator_name}
180} 236}
181 237
182# @FUNCTION: cmake-utils_use_with 238# @FUNCTION: cmake-utils_use_with
183# @USAGE: <USE flag> [flag name] 239# @USAGE: <USE flag> [flag name]
184# @DESCRIPTION: 240# @DESCRIPTION:
195# 251#
196# `cmake-utils_use_enable foo FOO` echoes -DENABLE_FOO=ON if foo is enabled 252# `cmake-utils_use_enable foo FOO` echoes -DENABLE_FOO=ON if foo is enabled
197# and -DENABLE_FOO=OFF if it is disabled. 253# and -DENABLE_FOO=OFF if it is disabled.
198cmake-utils_use_enable() { _use_me_now ENABLE_ "$@" ; } 254cmake-utils_use_enable() { _use_me_now ENABLE_ "$@" ; }
199 255
256# @FUNCTION: cmake-utils_use_find_package
257# @USAGE: <USE flag> [flag name]
258# @DESCRIPTION:
259# Based on use_enable. See ebuild(5).
260#
261# `cmake-utils_use_find_package foo FOO` echoes -DCMAKE_DISABLE_FIND_PACKAGE=OFF
262# if foo is enabled and -DCMAKE_DISABLE_FIND_PACKAGE=ON if it is disabled.
263# This can be used to make find_package optional (since cmake-2.8.6).
264cmake-utils_use_find_package() { _use_me_now_inverted CMAKE_DISABLE_FIND_PACKAGE_ "$@" ; }
265
200# @FUNCTION: cmake-utils_use_disable 266# @FUNCTION: cmake-utils_use_disable
201# @USAGE: <USE flag> [flag name] 267# @USAGE: <USE flag> [flag name]
202# @DESCRIPTION: 268# @DESCRIPTION:
203# Based on inversion of use_enable. See ebuild(5). 269# Based on inversion of use_enable. See ebuild(5).
204# 270#
264# Removes dangerous definitions that override Gentoo settings. 330# Removes dangerous definitions that override Gentoo settings.
265_modify-cmakelists() { 331_modify-cmakelists() {
266 debug-print-function ${FUNCNAME} "$@" 332 debug-print-function ${FUNCNAME} "$@"
267 333
268 # Only edit the files once 334 # Only edit the files once
269 grep -qs "<<< Gentoo configuration >>>" CMakeLists.txt && return 0 335 grep -qs "<<< Gentoo configuration >>>" "${CMAKE_USE_DIR}"/CMakeLists.txt && return 0
270 336
271 # Comment out all set (<some_should_be_user_defined_variable> value) 337 # Comment out all set (<some_should_be_user_defined_variable> value)
272 # TODO Add QA checker - inform when variable being checked for below is set in CMakeLists.txt 338 # TODO Add QA checker - inform when variable being checked for below is set in CMakeLists.txt
273 find "${CMAKE_USE_DIR}" -name CMakeLists.txt \ 339 find "${CMAKE_USE_DIR}" -name CMakeLists.txt \
274 -exec sed -i -e '/^[[:space:]]*[sS][eE][tT][[:space:]]*([[:space:]]*CMAKE_BUILD_TYPE.*)/{s/^/#IGNORE /g}' {} + \ 340 -exec sed -i -e '/^[[:space:]]*[sS][eE][tT][[:space:]]*([[:space:]]*CMAKE_BUILD_TYPE.*)/{s/^/#IGNORE /g}' {} + \
291 Module \${CMAKE_MODULE_LINKER_FLAGS} 357 Module \${CMAKE_MODULE_LINKER_FLAGS}
292 Shared \${CMAKE_SHARED_LINKER_FLAGS}\n") 358 Shared \${CMAKE_SHARED_LINKER_FLAGS}\n")
293 _EOF_ 359 _EOF_
294} 360}
295 361
362enable_cmake-utils_src_prepare() {
363 debug-print-function ${FUNCNAME} "$@"
364
365 base_src_prepare
366}
367
368# @VARIABLE: mycmakeargs
369# @DEFAULT_UNSET
370# @DESCRIPTION:
371# Optional cmake defines as a bash array. Should be defined before calling
372# src_configure.
373# @CODE
374# src_configure() {
375# local mycmakeargs=(
376# $(cmake-utils_use_with openconnect)
377# )
378# cmake-utils_src_configure
379# }
380
381
296enable_cmake-utils_src_configure() { 382enable_cmake-utils_src_configure() {
297 debug-print-function ${FUNCNAME} "$@" 383 debug-print-function ${FUNCNAME} "$@"
298 384
299 [[ "${CMAKE_REMOVE_MODULES}" == "yes" ]] && { 385 [[ "${CMAKE_REMOVE_MODULES}" == "yes" ]] && {
300 local name 386 local name
325 if ! has debug ${IUSE//+} || ! use debug; then 411 if ! has debug ${IUSE//+} || ! use debug; then
326 append-cppflags -DNDEBUG 412 append-cppflags -DNDEBUG
327 fi 413 fi
328 fi 414 fi
329 415
330 # Prepare Gentoo override rules (set valid compiler, append CPPFLAGS) 416 # Prepare Gentoo override rules (set valid compiler, append CPPFLAGS etc.)
331 local build_rules=${CMAKE_BUILD_DIR}/gentoo_rules.cmake 417 local build_rules=${BUILD_DIR}/gentoo_rules.cmake
332 cat > "${build_rules}" <<- _EOF_ 418 cat > "${build_rules}" <<- _EOF_
419 SET (CMAKE_AR $(type -P $(tc-getAR)) CACHE FILEPATH "Archive manager" FORCE)
420 SET (CMAKE_ASM_COMPILE_OBJECT "<CMAKE_C_COMPILER> <DEFINES> ${CFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "ASM compile command" FORCE)
333 SET (CMAKE_C_COMPILER $(type -P $(tc-getCC)) CACHE FILEPATH "C compiler" FORCE) 421 SET (CMAKE_C_COMPILER $(type -P $(tc-getCC)) CACHE FILEPATH "C compiler" FORCE)
334 SET (CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> <DEFINES> ${CPPFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "C compile command" FORCE) 422 SET (CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> <DEFINES> ${CPPFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "C compile command" FORCE)
335 SET (CMAKE_CXX_COMPILER $(type -P $(tc-getCXX)) CACHE FILEPATH "C++ compiler" FORCE) 423 SET (CMAKE_CXX_COMPILER $(type -P $(tc-getCXX)) CACHE FILEPATH "C++ compiler" FORCE)
336 SET (CMAKE_CXX_COMPILE_OBJECT "<CMAKE_CXX_COMPILER> <DEFINES> ${CPPFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "C++ compile command" FORCE) 424 SET (CMAKE_CXX_COMPILE_OBJECT "<CMAKE_CXX_COMPILER> <DEFINES> ${CPPFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "C++ compile command" FORCE)
425 SET (CMAKE_RANLIB $(type -P $(tc-getRANLIB)) CACHE FILEPATH "Archive index generator" FORCE)
426 SET (PKG_CONFIG_EXECUTABLE $(type -P $(tc-getPKG_CONFIG)) CACHE FILEPATH "pkg-config executable" FORCE)
337 _EOF_ 427 _EOF_
338 428
339 has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX= 429 has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
340 430
341 if [[ ${EPREFIX} ]]; then 431 if [[ ${EPREFIX} ]]; then
360 ENDIF (NOT APPLE) 450 ENDIF (NOT APPLE)
361 _EOF_ 451 _EOF_
362 fi 452 fi
363 453
364 # Common configure parameters (invariants) 454 # Common configure parameters (invariants)
365 local common_config=${CMAKE_BUILD_DIR}/gentoo_common_config.cmake 455 local common_config=${BUILD_DIR}/gentoo_common_config.cmake
366 local libdir=$(get_libdir) 456 local libdir=$(get_libdir)
367 cat > "${common_config}" <<- _EOF_ 457 cat > "${common_config}" <<- _EOF_
368 SET (LIB_SUFFIX ${libdir/lib} CACHE STRING "library path suffix" FORCE) 458 SET (LIB_SUFFIX ${libdir/lib} CACHE STRING "library path suffix" FORCE)
369 SET (CMAKE_INSTALL_LIBDIR ${libdir} CACHE PATH "Output directory for libraries") 459 SET (CMAKE_INSTALL_LIBDIR ${libdir} CACHE PATH "Output directory for libraries")
370 _EOF_ 460 _EOF_
392 -DCMAKE_INSTALL_DO_STRIP=OFF 482 -DCMAKE_INSTALL_DO_STRIP=OFF
393 -DCMAKE_USER_MAKE_RULES_OVERRIDE="${build_rules}" 483 -DCMAKE_USER_MAKE_RULES_OVERRIDE="${build_rules}"
394 "${MYCMAKEARGS}" 484 "${MYCMAKEARGS}"
395 ) 485 )
396 486
397 pushd "${CMAKE_BUILD_DIR}" > /dev/null 487 pushd "${BUILD_DIR}" > /dev/null
398 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: mycmakeargs is ${mycmakeargs_local[*]}" 488 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: mycmakeargs is ${mycmakeargs_local[*]}"
399 echo "${CMAKE_BINARY}" "${cmakeargs[@]}" "${CMAKE_USE_DIR}" 489 echo "${CMAKE_BINARY}" "${cmakeargs[@]}" "${CMAKE_USE_DIR}"
400 "${CMAKE_BINARY}" "${cmakeargs[@]}" "${CMAKE_USE_DIR}" || die "cmake failed" 490 "${CMAKE_BINARY}" "${cmakeargs[@]}" "${CMAKE_USE_DIR}" || die "cmake failed"
401 popd > /dev/null 491 popd > /dev/null
402} 492}
406 496
407 has src_configure ${CMAKE_EXPF} || cmake-utils_src_configure 497 has src_configure ${CMAKE_EXPF} || cmake-utils_src_configure
408 cmake-utils_src_make "$@" 498 cmake-utils_src_make "$@"
409} 499}
410 500
501# @FUNCTION: ninja_src_make
502# @INTERNAL
503# @DESCRIPTION:
504# Build the package using ninja generator
505ninja_src_make() {
506 debug-print-function ${FUNCNAME} "$@"
507
508 [[ -e build.ninja ]] || die "Makefile not found. Error during configure stage."
509
510 if [[ "${CMAKE_VERBOSE}" != "OFF" ]]; then
511 # TODO: get load average from portage (-l option)
512 ninja ${MAKEOPTS} -v "$@" || die
513 else
514 ninja "$@" || die
515 fi
516}
517
518# @FUNCTION: make_src_make
519# @INTERNAL
520# @DESCRIPTION:
521# Build the package using make generator
522emake_src_make() {
523 debug-print-function ${FUNCNAME} "$@"
524
525 [[ -e Makefile ]] || die "Makefile not found. Error during configure stage."
526
527 if [[ "${CMAKE_VERBOSE}" != "OFF" ]]; then
528 emake VERBOSE=1 "$@" || die
529 else
530 emake "$@" || die
531 fi
532
533}
534
411# @FUNCTION: cmake-utils_src_make 535# @FUNCTION: cmake-utils_src_make
412# @DESCRIPTION: 536# @DESCRIPTION:
413# Function for building the package. Automatically detects the build type. 537# Function for building the package. Automatically detects the build type.
414# All arguments are passed to emake. 538# All arguments are passed to emake.
415cmake-utils_src_make() { 539cmake-utils_src_make() {
416 debug-print-function ${FUNCNAME} "$@" 540 debug-print-function ${FUNCNAME} "$@"
417 541
418 _check_build_dir 542 _check_build_dir
419 pushd "${CMAKE_BUILD_DIR}" > /dev/null 543 pushd "${BUILD_DIR}" > /dev/null
420 if [[ $(_generator_to_use) = Ninja ]]; then 544
421 # first check if Makefile exist otherwise die 545 ${CMAKE_MAKEFILE_GENERATOR}_src_make $@
422 [[ -e build.ninja ]] || die "Makefile not found. Error during configure stage." 546
423 if [[ "${CMAKE_VERBOSE}" != "OFF" ]]; then
424 #TODO get load average from portage (-l option)
425 ninja ${MAKEOPTS} -v "$@"
426 else
427 ninja "$@"
428 fi || die "ninja failed!"
429 else
430 # first check if Makefile exist otherwise die
431 [[ -e Makefile ]] || die "Makefile not found. Error during configure stage."
432 if [[ "${CMAKE_VERBOSE}" != "OFF" ]]; then
433 emake VERBOSE=1 "$@" || die "Make failed!"
434 else
435 emake "$@" || die "Make failed!"
436 fi
437 fi
438 popd > /dev/null 547 popd > /dev/null
439} 548}
440 549
441enable_cmake-utils_src_install() { 550enable_cmake-utils_src_install() {
442 debug-print-function ${FUNCNAME} "$@" 551 debug-print-function ${FUNCNAME} "$@"
443 552
444 _check_build_dir 553 _check_build_dir
445 pushd "${CMAKE_BUILD_DIR}" > /dev/null 554 pushd "${BUILD_DIR}" > /dev/null
446 if [[ $(_generator_to_use) = Ninja ]]; then 555
447 DESTDIR=${D} ninja install "$@" || die "died running ninja install" 556 DESTDIR="${D}" ${CMAKE_MAKEFILE_GENERATOR} install "$@" || die "died running ${CMAKE_MAKEFILE_GENERATOR} install"
448 base_src_install_docs 557 base_src_install_docs
449 else 558
450 base_src_install "$@"
451 fi
452 popd > /dev/null 559 popd > /dev/null
453 560
454 # Backward compatibility, for non-array variables 561 # Backward compatibility, for non-array variables
455 if [[ -n "${DOCS}" ]] && [[ "$(declare -p DOCS 2>/dev/null 2>&1)" != "declare -a"* ]]; then 562 if [[ -n "${DOCS}" ]] && [[ "$(declare -p DOCS 2>/dev/null 2>&1)" != "declare -a"* ]]; then
456 dodoc ${DOCS} || die "dodoc failed" 563 dodoc ${DOCS} || die "dodoc failed"
460 fi 567 fi
461} 568}
462 569
463enable_cmake-utils_src_test() { 570enable_cmake-utils_src_test() {
464 debug-print-function ${FUNCNAME} "$@" 571 debug-print-function ${FUNCNAME} "$@"
465 local ctestargs
466 572
467 _check_build_dir 573 _check_build_dir
468 pushd "${CMAKE_BUILD_DIR}" > /dev/null 574 pushd "${BUILD_DIR}" > /dev/null
469 [[ -e CTestTestfile.cmake ]] || { echo "No tests found. Skipping."; return 0 ; } 575 [[ -e CTestTestfile.cmake ]] || { echo "No tests found. Skipping."; return 0 ; }
470 576
471 [[ -n ${TEST_VERBOSE} ]] && ctestargs="--extra-verbose --output-on-failure" 577 [[ -n ${TEST_VERBOSE} ]] && myctestargs+=( --extra-verbose --output-on-failure )
472 578
473 if ctest ${ctestargs} "$@" ; then 579 if ctest "${myctestargs[@]}" "$@" ; then
474 einfo "Tests succeeded." 580 einfo "Tests succeeded."
581 popd > /dev/null
582 return 0
475 else 583 else
476 if [[ -n "${CMAKE_YES_I_WANT_TO_SEE_THE_TEST_LOG}" ]] ; then 584 if [[ -n "${CMAKE_YES_I_WANT_TO_SEE_THE_TEST_LOG}" ]] ; then
477 # on request from Diego 585 # on request from Diego
478 eerror "Tests failed. Test log ${CMAKE_BUILD_DIR}/Testing/Temporary/LastTest.log follows:" 586 eerror "Tests failed. Test log ${BUILD_DIR}/Testing/Temporary/LastTest.log follows:"
479 eerror "--START TEST LOG--------------------------------------------------------------" 587 eerror "--START TEST LOG--------------------------------------------------------------"
480 cat "${CMAKE_BUILD_DIR}/Testing/Temporary/LastTest.log" 588 cat "${BUILD_DIR}/Testing/Temporary/LastTest.log"
481 eerror "--END TEST LOG----------------------------------------------------------------" 589 eerror "--END TEST LOG----------------------------------------------------------------"
482 die "Tests failed." 590 die "Tests failed."
483 else 591 else
484 die "Tests failed. When you file a bug, please attach the following file: \n\t${CMAKE_BUILD_DIR}/Testing/Temporary/LastTest.log" 592 die "Tests failed. When you file a bug, please attach the following file: \n\t${BUILD_DIR}/Testing/Temporary/LastTest.log"
485 fi 593 fi
486 fi 594
595 # die might not die due to nonfatal
487 popd > /dev/null 596 popd > /dev/null
597 return 1
598 fi
599}
600
601# @FUNCTION: cmake-utils_src_prepare
602# @DESCRIPTION:
603# Wrapper function around base_src_prepare, just to expand the eclass API.
604cmake-utils_src_prepare() {
605 _execute_optionaly "src_prepare" "$@"
488} 606}
489 607
490# @FUNCTION: cmake-utils_src_configure 608# @FUNCTION: cmake-utils_src_configure
491# @DESCRIPTION: 609# @DESCRIPTION:
492# General function for configuring with cmake. Default behaviour is to start an 610# General function for configuring with cmake. Default behaviour is to start an
525 enable_cmake-utils_${phase} "$@" 643 enable_cmake-utils_${phase} "$@"
526 else 644 else
527 use ${WANT_CMAKE} && enable_cmake-utils_${phase} "$@" 645 use ${WANT_CMAKE} && enable_cmake-utils_${phase} "$@"
528 fi 646 fi
529} 647}
648
649fi

Legend:
Removed from v.1.82  
changed lines
  Added in v.1.96

  ViewVC Help
Powered by ViewVC 1.1.20