/[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.49 Revision 1.53
1# Copyright 1999-2010 Gentoo Foundation 1# Copyright 1999-2010 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.49 2010/04/10 02:20:59 reavertm Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/cmake-utils.eclass,v 1.53 2010/06/21 16:39:49 reavertm 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# 8#
9# @CODE 9# @CODE
10# Tomáš Chvátal <scarabeus@gentoo.org> 10# Tomáš Chvátal <scarabeus@gentoo.org>
11# Maciej Mrozowski <reavertm@gmail.com> 11# Maciej Mrozowski <reavertm@gentoo.org>
12# (undisclosed contributors) 12# (undisclosed contributors)
13# Original author: Zephyrus (zephyrus@mirach.it) 13# Original author: Zephyrus (zephyrus@mirach.it)
14# @CODE 14# @CODE
15# @BLURB: common ebuild functions for cmake-based packages 15# @BLURB: common ebuild functions for cmake-based packages
16# @DESCRIPTION: 16# @DESCRIPTION:
17# The cmake-utils eclass contains functions that make creating ebuilds for 17# The cmake-utils eclass is base.eclass(5) wrapper that makes creating ebuilds for
18# cmake-based packages much easier. 18# cmake-based packages much easier.
19# Its main features are support of out-of-source builds as well as in-source 19# It provides all inherited features (DOCS, HTML_DOCS, PATCHES) along with out-of-source
20# builds and an implementation of the well-known use_enable and use_with 20# builds (default), in-source builds and an implementation of the well-known use_enable
21# functions for CMake. 21# and use_with functions for CMake.
22 22
23# @ECLASS-VARIABLE: WANT_CMAKE 23# @ECLASS-VARIABLE: WANT_CMAKE
24# @DESCRIPTION: 24# @DESCRIPTION:
25# Specify if cmake-utils eclass should depend on cmake optionaly or not. 25# Specify if cmake-utils eclass should depend on cmake optionaly or not.
26# This is usefull when only part of aplication is using cmake build system. 26# This is usefull when only part of aplication is using cmake build system.
27# Valid values are: always [default], optional (where the value is the useflag 27# Valid values are: always [default], optional (where the value is the useflag
28# used for optionality) 28# used for optionality)
29WANT_CMAKE="${WANT_CMAKE:-always}" 29WANT_CMAKE="${WANT_CMAKE:-always}"
30
31# @ECLASS-VARIABLE: CMAKE_MIN_VERSION
32# @DESCRIPTION:
33# Specify the minimum allowable version of cmake. Defaults to 2.6.2-r1
34CMAKE_MIN_VERSION="${CMAKE_MIN_VERSION:-2.6.2-r1}"
35
30CMAKEDEPEND="" 36CMAKEDEPEND=""
31case ${WANT_CMAKE} in 37case ${WANT_CMAKE} in
32 always) 38 always)
33 ;; 39 ;;
34 *) 40 *)
47EXPORT_FUNCTIONS ${CMAKE_EXPF} 53EXPORT_FUNCTIONS ${CMAKE_EXPF}
48 54
49: ${DESCRIPTION:="Based on the ${ECLASS} eclass"} 55: ${DESCRIPTION:="Based on the ${ECLASS} eclass"}
50 56
51if [[ ${PN} != cmake ]]; then 57if [[ ${PN} != cmake ]]; then
52 CMAKEDEPEND+=">=dev-util/cmake-2.6.2-r1" 58 CMAKEDEPEND+=">=dev-util/cmake-${CMAKE_MIN_VERSION}"
53fi 59fi
54 60
55CMAKEDEPEND+=" userland_GNU? ( >=sys-apps/findutils-4.4.0 )" 61CMAKEDEPEND+=" userland_GNU? ( >=sys-apps/findutils-4.4.0 )"
56 62
57[[ ${WANT_CMAKE} = always ]] || CMAKEDEPEND+=" )" 63[[ ${WANT_CMAKE} = always ]] || CMAKEDEPEND+=" )"
93 echo "-D$1$x=$(use $2 && echo OFF || echo ON) " 99 echo "-D$1$x=$(use $2 && echo OFF || echo ON) "
94 done 100 done
95 fi 101 fi
96} 102}
97 103
98# @ECLASS-VARIABLE: DOCS
99# @DESCRIPTION:
100# Documents passed to dodoc command.
101
102# @ECLASS-VARIABLE: HTML_DOCS
103# @DESCRIPTION:
104# Documents passed to dohtml command.
105
106# @ECLASS-VARIABLE: PREFIX 104# @ECLASS-VARIABLE: PREFIX
107# @DESCRIPTION: 105# @DESCRIPTION:
108# Eclass respects PREFIX variable, though it's not recommended way to set 106# Eclass respects PREFIX variable, though it's not recommended way to set
109# install/lib/bin prefixes. 107# install/lib/bin prefixes.
110# Use -DCMAKE_INSTALL_PREFIX=... CMake variable instead. 108# Use -DCMAKE_INSTALL_PREFIX=... CMake variable instead.
124# If about to be set - needs to be set before invoking cmake-utils_src_configure. 122# If about to be set - needs to be set before invoking cmake-utils_src_configure.
125# You usualy do *NOT* want nor need to set it as it pulls CMake default build-type 123# You usualy do *NOT* want nor need to set it as it pulls CMake default build-type
126# specific compiler flags overriding make.conf. 124# specific compiler flags overriding make.conf.
127: ${CMAKE_BUILD_TYPE:=Gentoo} 125: ${CMAKE_BUILD_TYPE:=Gentoo}
128 126
129# @FUNCTION: _check_build_dir
130# @DESCRIPTION:
131# Determine using IN or OUT source build 127# Determine using IN or OUT source build
132_check_build_dir() { 128_check_build_dir() {
133 # @ECLASS-VARIABLE: CMAKE_USE_DIR 129 # @ECLASS-VARIABLE: CMAKE_USE_DIR
134 # @DESCRIPTION: 130 # @DESCRIPTION:
135 # Sets the directory where we are working with cmake. 131 # Sets the directory where we are working with cmake.
255 Module \${CMAKE_MODULE_LINKER_FLAGS} 251 Module \${CMAKE_MODULE_LINKER_FLAGS}
256 Shared \${CMAKE_SHARED_LINKER_FLAGS}\n") 252 Shared \${CMAKE_SHARED_LINKER_FLAGS}\n")
257 _EOF_ 253 _EOF_
258} 254}
259 255
260# @FUNCTION: enable_cmake-utils_src_configure
261# @DESCRIPTION:
262# General function for configuring with cmake. Default behaviour is to start an
263# out-of-source build.
264enable_cmake-utils_src_configure() { 256enable_cmake-utils_src_configure() {
265 debug-print-function ${FUNCNAME} "$@" 257 debug-print-function ${FUNCNAME} "$@"
266 258
267 _check_build_dir init 259 _check_build_dir init
268 260
314 local libdir=$(get_libdir) 306 local libdir=$(get_libdir)
315 cat > "${common_config}" <<- _EOF_ 307 cat > "${common_config}" <<- _EOF_
316 SET (LIB_SUFFIX ${libdir/lib} CACHE STRING "library path suffix" FORCE) 308 SET (LIB_SUFFIX ${libdir/lib} CACHE STRING "library path suffix" FORCE)
317 SET (CMAKE_INSTALL_LIBDIR ${libdir} CACHE PATH "Output directory for libraries") 309 SET (CMAKE_INSTALL_LIBDIR ${libdir} CACHE PATH "Output directory for libraries")
318 _EOF_ 310 _EOF_
319 [[ -n ${NOCOLOR} ]] || echo 'SET (CMAKE_COLOR_MAKEFILE OFF CACHE BOOL "pretty colors during make" FORCE)' >> "${common_config}" 311 [[ -n ${NOCOLOR} ]] && echo 'SET (CMAKE_COLOR_MAKEFILE OFF CACHE BOOL "pretty colors during make" FORCE)' >> "${common_config}"
320 312
321 # Convert mycmakeargs to an array, for backwards compatibility 313 # Convert mycmakeargs to an array, for backwards compatibility
322 # Make the array a local variable since <=portage-2.1.6.x does not 314 # Make the array a local variable since <=portage-2.1.6.x does not
323 # support global arrays (see bug #297255). 315 # support global arrays (see bug #297255).
324 if [[ $(declare -p mycmakeargs 2>&-) != "declare -a mycmakeargs="* ]]; then 316 if [[ $(declare -p mycmakeargs 2>&-) != "declare -a mycmakeargs="* ]]; then
349 cmake "${cmakeargs[@]}" "${CMAKE_USE_DIR}" || die "cmake failed" 341 cmake "${cmakeargs[@]}" "${CMAKE_USE_DIR}" || die "cmake failed"
350 342
351 popd > /dev/null 343 popd > /dev/null
352} 344}
353 345
354# @FUNCTION: enable_cmake-utils_src_compile
355# @DESCRIPTION:
356# General function for compiling with cmake. Default behaviour is to check for
357# EAPI and respectively to configure as well or just compile.
358enable_cmake-utils_src_compile() { 346enable_cmake-utils_src_compile() {
359 debug-print-function ${FUNCNAME} "$@" 347 debug-print-function ${FUNCNAME} "$@"
360 348
361 has src_configure ${CMAKE_EXPF} || cmake-utils_src_configure 349 has src_configure ${CMAKE_EXPF} || cmake-utils_src_configure
362 cmake-utils_src_make "$@" 350 cmake-utils_src_make "$@"
379 emake "$@" || die "Make failed!" 367 emake "$@" || die "Make failed!"
380 fi 368 fi
381 popd &> /dev/null 369 popd &> /dev/null
382} 370}
383 371
384# @FUNCTION: enable_cmake-utils_src_install
385# @DESCRIPTION:
386# Function for installing the package. Automatically detects the build type.
387enable_cmake-utils_src_install() { 372enable_cmake-utils_src_install() {
388 debug-print-function ${FUNCNAME} "$@" 373 debug-print-function ${FUNCNAME} "$@"
389 374
390 _check_build_dir 375 _check_build_dir
391 pushd "${CMAKE_BUILD_DIR}" &> /dev/null 376 pushd "${CMAKE_BUILD_DIR}" &> /dev/null
392 emake install DESTDIR="${D}" || die "Make install failed" 377 base_src_install
393 popd &> /dev/null 378 popd &> /dev/null
394 379
395 # Manual document installation 380 # Backward compatibility, for non-array variables
396 [[ -n "${DOCS}" ]] && { dodoc ${DOCS} || die "dodoc failed" ; } 381 if [[ -n "${DOCS}" ]] && [[ "$(declare -p DOCS 2>/dev/null 2>&1)" != "declare -a"* ]]; then
397 [[ -n "${HTML_DOCS}" ]] && { dohtml -r ${HTML_DOCS} || die "dohtml failed" ; } 382 dodoc ${DOCS} || die "dodoc failed"
383 fi
384 if [[ -n "${HTML_DOCS}" ]] && [[ "$(declare -p HTML_DOCS 2>/dev/null 2>&1)" != "declare -a"* ]]; then
385 dohtml -r ${HTML_DOCS} || die "dohtml failed"
386 fi
398} 387}
399 388
400# @FUNCTION: enable_cmake-utils_src_test
401# @DESCRIPTION:
402# Function for testing the package. Automatically detects the build type.
403enable_cmake-utils_src_test() { 389enable_cmake-utils_src_test() {
404 debug-print-function ${FUNCNAME} "$@" 390 debug-print-function ${FUNCNAME} "$@"
405 391
406 _check_build_dir 392 _check_build_dir
407 pushd "${CMAKE_BUILD_DIR}" &> /dev/null 393 pushd "${CMAKE_BUILD_DIR}" &> /dev/null
420 einfo ">>> Test phase [none]: ${CATEGORY}/${PF}" 406 einfo ">>> Test phase [none]: ${CATEGORY}/${PF}"
421 fi 407 fi
422 popd &> /dev/null 408 popd &> /dev/null
423} 409}
424 410
425## Wrappers for calls bellow this line
426# @FUNCTION: cmake-utils_src_configure 411# @FUNCTION: cmake-utils_src_configure
427# @DESCRIPTION: 412# @DESCRIPTION:
428# Wrapper for detection if we want to run enable_ prefixed function with same name 413# General function for configuring with cmake. Default behaviour is to start an
429# unconditionaly or only when some useflag is enabled. 414# out-of-source build.
430cmake-utils_src_configure() { 415cmake-utils_src_configure() {
431 _execute_optionaly "src_configure" "$@" 416 _execute_optionaly "src_configure" "$@"
432} 417}
433 418
434# @FUNCTION: cmake-utils_src_compile 419# @FUNCTION: cmake-utils_src_compile
435# @DESCRIPTION: 420# @DESCRIPTION:
436# Wrapper for detection if we want to run enable_ prefixed function with same name 421# General function for compiling with cmake. Default behaviour is to check for
437# unconditionaly or only when some useflag is enabled. 422# EAPI and respectively to configure as well or just compile.
423# Automatically detects the build type. All arguments are passed to emake.
438cmake-utils_src_compile() { 424cmake-utils_src_compile() {
439 _execute_optionaly "src_compile" "$@" 425 _execute_optionaly "src_compile" "$@"
440} 426}
441 427
442# @FUNCTION: cmake-utils_src_install 428# @FUNCTION: cmake-utils_src_install
443# @DESCRIPTION: 429# @DESCRIPTION:
444# Wrapper for detection if we want to run enable_ prefixed function with same name 430# Function for installing the package. Automatically detects the build type.
445# unconditionaly or only when some useflag is enabled.
446cmake-utils_src_install() { 431cmake-utils_src_install() {
447 _execute_optionaly "src_install" "$@" 432 _execute_optionaly "src_install" "$@"
448} 433}
449 434
450# @FUNCTION: cmake-utils_src_test 435# @FUNCTION: cmake-utils_src_test
451# @DESCRIPTION: 436# @DESCRIPTION:
452# Wrapper for detection if we want to run enable_ prefixed function with same name 437# Function for testing the package. Automatically detects the build type.
453# unconditionaly or only when some useflag is enabled.
454cmake-utils_src_test() { 438cmake-utils_src_test() {
455 _execute_optionaly "src_test" "$@" 439 _execute_optionaly "src_test" "$@"
456} 440}
457 441
458 442# Optionally executes phases based on WANT_CMAKE variable/USE flag.
459_execute_optionaly() { 443_execute_optionaly() {
460 local phase="$1" ; shift 444 local phase="$1" ; shift
461 if [[ ${WANT_CMAKE} = always ]]; then 445 if [[ ${WANT_CMAKE} = always ]]; then
462 enable_cmake-utils_${phase} "$@" 446 enable_cmake-utils_${phase} "$@"
463 else 447 else

Legend:
Removed from v.1.49  
changed lines
  Added in v.1.53

  ViewVC Help
Powered by ViewVC 1.1.20