/[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.94 Revision 1.101
1# Copyright 1999-2013 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.94 2013/04/07 17:21:11 kensington Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/cmake-utils.eclass,v 1.101 2013/12/24 14:54:26 dilfridge 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:
10# Maciej Mrozowski <reavertm@gentoo.org> 10# Maciej Mrozowski <reavertm@gentoo.org>
11# (undisclosed contributors) 11# (undisclosed contributors)
12# Original author: Zephyrus (zephyrus@mirach.it) 12# Original author: Zephyrus (zephyrus@mirach.it)
13# @BLURB: common ebuild functions for cmake-based packages 13# @BLURB: common ebuild functions for cmake-based packages
14# @DESCRIPTION: 14# @DESCRIPTION:
15# The cmake-utils eclass is base.eclass(5) wrapper that makes creating ebuilds for 15# The cmake-utils eclass makes creating ebuilds for 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 16# 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 17# builds (default), in-source builds and an implementation of the well-known use_enable
19# and use_with functions for CMake. 18# and use_with functions for CMake.
20 19
21if [[ ${___ECLASS_ONCE_CMAKE_UTILS} != "recur -_+^+_- spank" ]] ; then 20if [[ ${___ECLASS_ONCE_CMAKE_UTILS} != "recur -_+^+_- spank" ]] ; then
48# @ECLASS-VARIABLE: CMAKE_MAKEFILE_GENERATOR 47# @ECLASS-VARIABLE: CMAKE_MAKEFILE_GENERATOR
49# @DESCRIPTION: 48# @DESCRIPTION:
50# Specify a makefile generator to be used by cmake. 49# Specify a makefile generator to be used by cmake.
51# At this point only "emake" and "ninja" are supported. 50# At this point only "emake" and "ninja" are supported.
52CMAKE_MAKEFILE_GENERATOR="${CMAKE_MAKEFILE_GENERATOR:-emake}" 51CMAKE_MAKEFILE_GENERATOR="${CMAKE_MAKEFILE_GENERATOR:-emake}"
52
53# @ECLASS-VARIABLE: CMAKE_WARN_UNUSED_CLI
54# @DESCRIPTION:
55# Warn about variables that are declared on the command line
56# but not used. Might give false-positives.
57# "no" to disable (default) or anything else to enable.
58CMAKE_WARN_UNUSED_CLI="${CMAKE_WARN_UNUSED_CLI:-no}"
53 59
54CMAKEDEPEND="" 60CMAKEDEPEND=""
55case ${WANT_CMAKE} in 61case ${WANT_CMAKE} in
56 always) 62 always)
57 ;; 63 ;;
58 *) 64 *)
59 IUSE+=" ${WANT_CMAKE}" 65 IUSE+=" ${WANT_CMAKE}"
60 CMAKEDEPEND+="${WANT_CMAKE}? ( " 66 CMAKEDEPEND+="${WANT_CMAKE}? ( "
61 ;; 67 ;;
62esac 68esac
63inherit toolchain-funcs multilib flag-o-matic base 69inherit toolchain-funcs multilib flag-o-matic eutils
64 70
65CMAKE_EXPF="src_compile src_test src_install" 71CMAKE_EXPF="src_compile src_test src_install"
66case ${EAPI:-0} in 72case ${EAPI:-0} in
67 2|3|4|5) CMAKE_EXPF+=" src_prepare src_configure" ;; 73 2|3|4|5) CMAKE_EXPF+=" src_prepare src_configure" ;;
68 1|0) ;; 74 1|0) eerror "cmake-utils no longer supports EAPI 0-1." && die
75 ;;
69 *) die "Unknown EAPI, Bug eclass maintainers." ;; 76 *) die "Unknown EAPI, bug eclass maintainers." ;;
70esac 77esac
71EXPORT_FUNCTIONS ${CMAKE_EXPF} 78EXPORT_FUNCTIONS ${CMAKE_EXPF}
72 79
73case ${CMAKE_MAKEFILE_GENERATOR} in 80case ${CMAKE_MAKEFILE_GENERATOR} in
74 emake) 81 emake)
250# @FUNCTION: cmake-utils_use_find_package 257# @FUNCTION: cmake-utils_use_find_package
251# @USAGE: <USE flag> [flag name] 258# @USAGE: <USE flag> [flag name]
252# @DESCRIPTION: 259# @DESCRIPTION:
253# Based on use_enable. See ebuild(5). 260# Based on use_enable. See ebuild(5).
254# 261#
255# `cmake-utils_use_find_package foo FOO` echoes -DCMAKE_DISABLE_FIND_PACKAGE=OFF 262# `cmake-utils_use_find_package foo LibFoo` echoes -DCMAKE_DISABLE_FIND_PACKAGE_LibFoo=OFF
256# if foo is enabled and -DCMAKE_DISABLE_FIND_PACKAGE=ON if it is disabled. 263# if foo is enabled and -DCMAKE_DISABLE_FIND_PACKAGE_LibFoo=ON if it is disabled.
257# This can be used to make find_package optional (since cmake-2.8.6). 264# This can be used to make find_package optional (since cmake-2.8.6).
258cmake-utils_use_find_package() { _use_me_now_inverted CMAKE_DISABLE_FIND_PACKAGE_ "$@" ; } 265cmake-utils_use_find_package() { _use_me_now_inverted CMAKE_DISABLE_FIND_PACKAGE_ "$@" ; }
259 266
260# @FUNCTION: cmake-utils_use_disable 267# @FUNCTION: cmake-utils_use_disable
261# @USAGE: <USE flag> [flag name] 268# @USAGE: <USE flag> [flag name]
317# Based on use_enable. See ebuild(5). 324# Based on use_enable. See ebuild(5).
318# 325#
319# `cmake-utils_use foo FOO` echoes -DFOO=ON if foo is enabled 326# `cmake-utils_use foo FOO` echoes -DFOO=ON if foo is enabled
320# and -DFOO=OFF if it is disabled. 327# and -DFOO=OFF if it is disabled.
321cmake-utils_use() { _use_me_now "" "$@" ; } 328cmake-utils_use() { _use_me_now "" "$@" ; }
329
330# @FUNCTION: cmake-utils_useno
331# @USAGE: <USE flag> [flag name]
332# @DESCRIPTION:
333# Based on use_enable. See ebuild(5).
334#
335# `cmake-utils_useno foo NOFOO` echoes -DNOFOO=OFF if foo is enabled
336# and -DNOFOO=ON if it is disabled.
337cmake-utils_useno() { _use_me_now_inverted "" "$@" ; }
322 338
323# Internal function for modifying hardcoded definitions. 339# Internal function for modifying hardcoded definitions.
324# Removes dangerous definitions that override Gentoo settings. 340# Removes dangerous definitions that override Gentoo settings.
325_modify-cmakelists() { 341_modify-cmakelists() {
326 debug-print-function ${FUNCNAME} "$@" 342 debug-print-function ${FUNCNAME} "$@"
354} 370}
355 371
356enable_cmake-utils_src_prepare() { 372enable_cmake-utils_src_prepare() {
357 debug-print-function ${FUNCNAME} "$@" 373 debug-print-function ${FUNCNAME} "$@"
358 374
359 base_src_prepare 375 debug-print "$FUNCNAME: PATCHES=$PATCHES"
376
377 pushd "${S}" > /dev/null
378 [[ ${PATCHES[@]} ]] && epatch "${PATCHES[@]}"
379
380 debug-print "$FUNCNAME: applying user patches"
381 epatch_user
382
383 popd > /dev/null
384
360} 385}
386
387# @VARIABLE: mycmakeargs
388# @DEFAULT_UNSET
389# @DESCRIPTION:
390# Optional cmake defines as a bash array. Should be defined before calling
391# src_configure.
392# @CODE
393# src_configure() {
394# local mycmakeargs=(
395# $(cmake-utils_use_with openconnect)
396# )
397# cmake-utils_src_configure
398# }
399
361 400
362enable_cmake-utils_src_configure() { 401enable_cmake-utils_src_configure() {
363 debug-print-function ${FUNCNAME} "$@" 402 debug-print-function ${FUNCNAME} "$@"
364 403
365 [[ "${CMAKE_REMOVE_MODULES}" == "yes" ]] && { 404 [[ "${CMAKE_REMOVE_MODULES}" == "yes" ]] && {
447 local mycmakeargs_local=(${mycmakeargs}) 486 local mycmakeargs_local=(${mycmakeargs})
448 else 487 else
449 local mycmakeargs_local=("${mycmakeargs[@]}") 488 local mycmakeargs_local=("${mycmakeargs[@]}")
450 fi 489 fi
451 490
491 if [[ ${CMAKE_WARN_UNUSED_CLI} == no ]] ; then
492 local warn_unused_cli="--no-warn-unused-cli"
493 else
494 local warn_unused_cli=""
495 fi
496
452 # Common configure parameters (overridable) 497 # Common configure parameters (overridable)
453 # NOTE CMAKE_BUILD_TYPE can be only overriden via CMAKE_BUILD_TYPE eclass variable 498 # NOTE CMAKE_BUILD_TYPE can be only overriden via CMAKE_BUILD_TYPE eclass variable
454 # No -DCMAKE_BUILD_TYPE=xxx definitions will be in effect. 499 # No -DCMAKE_BUILD_TYPE=xxx definitions will be in effect.
455 local cmakeargs=( 500 local cmakeargs=(
456 --no-warn-unused-cli 501 ${warn_unused_cli}
457 -C "${common_config}" 502 -C "${common_config}"
458 -G "$(_generator_to_use)" 503 -G "$(_generator_to_use)"
459 -DCMAKE_INSTALL_PREFIX="${EPREFIX}${PREFIX}" 504 -DCMAKE_INSTALL_PREFIX="${EPREFIX}${PREFIX}"
460 "${mycmakeargs_local[@]}" 505 "${mycmakeargs_local[@]}"
461 -DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" 506 -DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}"
493 else 538 else
494 ninja "$@" || die 539 ninja "$@" || die
495 fi 540 fi
496} 541}
497 542
498# @FUNCTION: make_src_make 543# @FUNCTION: emake_src_make
499# @INTERNAL 544# @INTERNAL
500# @DESCRIPTION: 545# @DESCRIPTION:
501# Build the package using make generator 546# Build the package using make generator
502emake_src_make() { 547emake_src_make() {
503 debug-print-function ${FUNCNAME} "$@" 548 debug-print-function ${FUNCNAME} "$@"
530enable_cmake-utils_src_install() { 575enable_cmake-utils_src_install() {
531 debug-print-function ${FUNCNAME} "$@" 576 debug-print-function ${FUNCNAME} "$@"
532 577
533 _check_build_dir 578 _check_build_dir
534 pushd "${BUILD_DIR}" > /dev/null 579 pushd "${BUILD_DIR}" > /dev/null
535
536 DESTDIR="${D}" ${CMAKE_MAKEFILE_GENERATOR} install "$@" || die "died running ${CMAKE_MAKEFILE_GENERATOR} install" 580 DESTDIR="${D}" ${CMAKE_MAKEFILE_GENERATOR} install "$@" || die "died running ${CMAKE_MAKEFILE_GENERATOR} install"
537 base_src_install_docs
538
539 popd > /dev/null 581 popd > /dev/null
582
583 pushd "${S}" > /dev/null
584 #Install docs, copied from base_src_install_docs
585 local x
586
587 if [[ "$(declare -p DOCS 2>/dev/null 2>&1)" == "declare -a"* ]]; then
588 for x in "${DOCS[@]}"; do
589 debug-print "$FUNCNAME: docs: creating document from ${x}"
590 dodoc "${x}" || die "dodoc failed"
591 done
592 fi
593 if [[ "$(declare -p HTML_DOCS 2>/dev/null 2>&1)" == "declare -a"* ]]; then
594 for x in "${HTML_DOCS[@]}"; do
595 debug-print "$FUNCNAME: docs: creating html document from ${x}"
596 dohtml -r "${x}" || die "dohtml failed"
597 done
598 fi
540 599
541 # Backward compatibility, for non-array variables 600 # Backward compatibility, for non-array variables
542 if [[ -n "${DOCS}" ]] && [[ "$(declare -p DOCS 2>/dev/null 2>&1)" != "declare -a"* ]]; then 601 if [[ -n "${DOCS}" ]] && [[ "$(declare -p DOCS 2>/dev/null 2>&1)" != "declare -a"* ]]; then
543 dodoc ${DOCS} || die "dodoc failed" 602 dodoc ${DOCS} || die "dodoc failed"
544 fi 603 fi
545 if [[ -n "${HTML_DOCS}" ]] && [[ "$(declare -p HTML_DOCS 2>/dev/null 2>&1)" != "declare -a"* ]]; then 604 if [[ -n "${HTML_DOCS}" ]] && [[ "$(declare -p HTML_DOCS 2>/dev/null 2>&1)" != "declare -a"* ]]; then
546 dohtml -r ${HTML_DOCS} || die "dohtml failed" 605 dohtml -r ${HTML_DOCS} || die "dohtml failed"
547 fi 606 fi
607
608 popd > /dev/null
548} 609}
549 610
550enable_cmake-utils_src_test() { 611enable_cmake-utils_src_test() {
551 debug-print-function ${FUNCNAME} "$@" 612 debug-print-function ${FUNCNAME} "$@"
552 613
578 fi 639 fi
579} 640}
580 641
581# @FUNCTION: cmake-utils_src_prepare 642# @FUNCTION: cmake-utils_src_prepare
582# @DESCRIPTION: 643# @DESCRIPTION:
583# Wrapper function around base_src_prepare, just to expand the eclass API. 644# Apply ebuild and user patches.
584cmake-utils_src_prepare() { 645cmake-utils_src_prepare() {
585 _execute_optionaly "src_prepare" "$@" 646 _execute_optionaly "src_prepare" "$@"
586} 647}
587 648
588# @FUNCTION: cmake-utils_src_configure 649# @FUNCTION: cmake-utils_src_configure

Legend:
Removed from v.1.94  
changed lines
  Added in v.1.101

  ViewVC Help
Powered by ViewVC 1.1.20