/[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.31 Revision 1.32
1# Copyright 1999-2009 Gentoo Foundation 1# Copyright 1999-2009 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.31 2009/10/16 12:24:09 ssuominen Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/cmake-utils.eclass,v 1.32 2009/10/27 14:16:49 scarabeus 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#
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# Its main features are support of out-of-source builds as well as in-source
20# builds and an implementation of the well-known use_enable and use_with 20# builds and an implementation of the well-known use_enable and use_with
21# functions for CMake. 21# functions for CMake.
22 22
23# @ECLASS-VARIABLE: WANT_CMAKE
24# @DESCRIPTION:
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.
27# Valid values are: always [default], optional (where the value is the useflag
28# used for optionality)
29WANT_CMAKE="${WANT_CMAKE:-always}"
30CMAKEDEPEND=""
31case ${WANT_CMAKE} in
32 always)
33 ;;
34 *)
35 IUSE+=" ${WANT_CMAKE}"
36 CMAKEDEPEND+="${WANT_CMAKE}? ( "
37 ;;
38esac
23inherit toolchain-funcs multilib flag-o-matic base 39inherit toolchain-funcs multilib flag-o-matic base
24 40
25EXPF="src_compile src_test src_install" 41CMAKE_EXPF="src_compile src_test src_install"
26case ${EAPI:-0} in 42case ${EAPI:-0} in
27 2) EXPF="${EXPF} src_configure" ;; 43 2) CMAKE_EXPF+=" src_configure" ;;
28 1|0) ;; 44 1|0) ;;
29 *) die "Unknown EAPI, Bug eclass maintainers." ;; 45 *) die "Unknown EAPI, Bug eclass maintainers." ;;
30esac 46esac
31EXPORT_FUNCTIONS ${EXPF} 47EXPORT_FUNCTIONS ${CMAKE_EXPF}
32 48
33: ${DESCRIPTION:="Based on the ${ECLASS} eclass"} 49: ${DESCRIPTION:="Based on the ${ECLASS} eclass"}
34 50
35if [[ ${PN} != cmake ]]; then 51if [[ ${PN} != cmake ]]; then
36 CMAKEDEPEND=">=dev-util/cmake-2.6.2-r1" 52 CMAKEDEPEND+=">=dev-util/cmake-2.6.2-r1"
37fi 53fi
38 54
55CMAKEDEPEND+="userland_GNU? ( >=sys-apps/findutils-4.4.0 )"
56
57[[ ${WANT_CMAKE} = always ]] || CMAKEDEPEND+=" )"
58
39DEPEND="${CMAKEDEPEND} 59DEPEND="${CMAKEDEPEND}"
40 userland_GNU? ( >=sys-apps/findutils-4.4.0 ) 60unset CMAKEDEPEND
41"
42 61
43# Internal functions used by cmake-utils_use_* 62# Internal functions used by cmake-utils_use_*
44_use_me_now() { 63_use_me_now() {
45 debug-print-function ${FUNCNAME} "$@" 64 debug-print-function ${FUNCNAME} "$@"
46 65
204# 223#
205# `cmake-utils_use_has foo FOO` echoes -DHAVE_FOO=ON if foo is enabled 224# `cmake-utils_use_has foo FOO` echoes -DHAVE_FOO=ON if foo is enabled
206# and -DHAVE_FOO=OFF if it is disabled. 225# and -DHAVE_FOO=OFF if it is disabled.
207cmake-utils_use_has() { _use_me_now HAVE_ "$@" ; } 226cmake-utils_use_has() { _use_me_now HAVE_ "$@" ; }
208 227
209# @FUNCTION: cmake-utils_has
210# @DESCRIPTION:
211# Deprecated, use cmake-utils_use_has, kept now for backcompat.
212cmake-utils_has() { ewarn "QA notice: using deprecated ${FUNCNAME} call, use cmake-utils_use_has instead." ; _use_me_now HAVE_ "$@" ; }
213
214# @FUNCTION: cmake-utils_use 228# @FUNCTION: cmake-utils_use
215# @USAGE: <USE flag> [flag name] 229# @USAGE: <USE flag> [flag name]
216# @DESCRIPTION: 230# @DESCRIPTION:
217# Based on use_enable. See ebuild(5). 231# Based on use_enable. See ebuild(5).
218# 232#
237MESSAGE(STATUS "<<< Gentoo configuration >>> 251MESSAGE(STATUS "<<< Gentoo configuration >>>
238Build type: ${CMAKE_BUILD_TYPE} 252Build type: ${CMAKE_BUILD_TYPE}
239Install path: ${CMAKE_INSTALL_PREFIX}\n")' >> CMakeLists.txt 253Install path: ${CMAKE_INSTALL_PREFIX}\n")' >> CMakeLists.txt
240} 254}
241 255
242# @FUNCTION: cmake-utils_src_configure 256# @FUNCTION: enable_cmake-utils_src_configure
243# @DESCRIPTION: 257# @DESCRIPTION:
244# General function for configuring with cmake. Default behaviour is to start an 258# General function for configuring with cmake. Default behaviour is to start an
245# out-of-source build. 259# out-of-source build.
246cmake-utils_src_configure() { 260enable_cmake-utils_src_configure() {
247 export XDG_CONFIG_HOME="${T}"
248
249 debug-print-function ${FUNCNAME} "$@" 261 debug-print-function ${FUNCNAME} "$@"
250 262
251 _check_build_dir init 263 _check_build_dir init
252 264
253 # check if CMakeLists.txt exist and if no then die 265 # check if CMakeLists.txt exist and if no then die
258 die "FATAL: Unable to find CMakeLists.txt" 270 die "FATAL: Unable to find CMakeLists.txt"
259 fi 271 fi
260 272
261 # Remove dangerous things. 273 # Remove dangerous things.
262 _modify-cmakelists 274 _modify-cmakelists
275
276 # Fix xdg collision with sandbox
277 export XDG_CONFIG_HOME="${T}"
263 278
264 # @SEE CMAKE_BUILD_TYPE 279 # @SEE CMAKE_BUILD_TYPE
265 if [[ ${CMAKE_BUILD_TYPE} = Gentoo ]]; then 280 if [[ ${CMAKE_BUILD_TYPE} = Gentoo ]]; then
266 # Handle release builds 281 # Handle release builds
267 if ! has debug ${IUSE//+} || ! use debug; then 282 if ! has debug ${IUSE//+} || ! use debug; then
304 cmake ${cmakeargs} "${CMAKE_USE_DIR}" || die "cmake failed" 319 cmake ${cmakeargs} "${CMAKE_USE_DIR}" || die "cmake failed"
305 320
306 popd > /dev/null 321 popd > /dev/null
307} 322}
308 323
309# @FUNCTION: cmake-utils_src_compile 324# @FUNCTION: enable_cmake-utils_src_compile
310# @DESCRIPTION: 325# @DESCRIPTION:
311# General function for compiling with cmake. Default behaviour is to check for 326# General function for compiling with cmake. Default behaviour is to check for
312# EAPI and respectively to configure as well or just compile. 327# EAPI and respectively to configure as well or just compile.
313cmake-utils_src_compile() { 328enable_cmake-utils_src_compile() {
314 debug-print-function ${FUNCNAME} "$@" 329 debug-print-function ${FUNCNAME} "$@"
315 330
316 has src_configure ${EXPF} || cmake-utils_src_configure 331 has src_configure ${CMAKE_EXPF} || cmake-utils_src_configure
317 cmake-utils_src_make "$@" 332 cmake-utils_src_make "$@"
318}
319
320# @FUNCTION: cmake-utils_src_configurein
321# @DESCRIPTION:
322# Deprecated
323cmake-utils_src_configurein() {
324 ewarn "QA notice: using deprecated ${FUNCNAME} call, set CMAKE_IN_SOURCE_BUILD=1 instead."
325 cmake-utils_src_configure
326}
327
328# @FUNCTION: cmake-utils_src_configureout
329# @DESCRIPTION:
330# Deprecated
331cmake-utils_src_configureout() {
332 ewarn "QA notice: using deprecated ${FUNCNAME} call, out of source build is enabled by default."
333 cmake-utils_src_configure
334} 333}
335 334
336# @FUNCTION: cmake-utils_src_make 335# @FUNCTION: cmake-utils_src_make
337# @DESCRIPTION: 336# @DESCRIPTION:
338# Function for building the package. Automatically detects the build type. 337# Function for building the package. Automatically detects the build type.
350 emake "$@" || die "Make failed!" 349 emake "$@" || die "Make failed!"
351 fi 350 fi
352 popd &> /dev/null 351 popd &> /dev/null
353} 352}
354 353
355# @FUNCTION: cmake-utils_src_install 354# @FUNCTION: enable_cmake-utils_src_install
356# @DESCRIPTION: 355# @DESCRIPTION:
357# Function for installing the package. Automatically detects the build type. 356# Function for installing the package. Automatically detects the build type.
358cmake-utils_src_install() { 357enable_cmake-utils_src_install() {
359 debug-print-function ${FUNCNAME} "$@" 358 debug-print-function ${FUNCNAME} "$@"
360 359
361 _check_build_dir 360 _check_build_dir
362 pushd "${CMAKE_BUILD_DIR}" &> /dev/null 361 pushd "${CMAKE_BUILD_DIR}" &> /dev/null
363 emake install DESTDIR="${D}" || die "Make install failed" 362 emake install DESTDIR="${D}" || die "Make install failed"
366 # Manual document installation 365 # Manual document installation
367 [[ -n "${DOCS}" ]] && { dodoc ${DOCS} || die "dodoc failed" ; } 366 [[ -n "${DOCS}" ]] && { dodoc ${DOCS} || die "dodoc failed" ; }
368 [[ -n "${HTML_DOCS}" ]] && { dohtml -r ${HTML_DOCS} || die "dohtml failed" ; } 367 [[ -n "${HTML_DOCS}" ]] && { dohtml -r ${HTML_DOCS} || die "dohtml failed" ; }
369} 368}
370 369
371# @FUNCTION: cmake-utils_src_test 370# @FUNCTION: enable_cmake-utils_src_test
372# @DESCRIPTION: 371# @DESCRIPTION:
373# Function for testing the package. Automatically detects the build type. 372# Function for testing the package. Automatically detects the build type.
374cmake-utils_src_test() { 373enable_cmake-utils_src_test() {
375 debug-print-function ${FUNCNAME} "$@" 374 debug-print-function ${FUNCNAME} "$@"
376 375
377 _check_build_dir 376 _check_build_dir
378 pushd "${CMAKE_BUILD_DIR}" &> /dev/null 377 pushd "${CMAKE_BUILD_DIR}" &> /dev/null
379 # Standard implementation of src_test 378 # Standard implementation of src_test
390 else 389 else
391 einfo ">>> Test phase [none]: ${CATEGORY}/${PF}" 390 einfo ">>> Test phase [none]: ${CATEGORY}/${PF}"
392 fi 391 fi
393 popd &> /dev/null 392 popd &> /dev/null
394} 393}
394
395## Wrappers for calls bellow this line
396# @FUNCTION: cmake-utils_src_configure
397# @DESCRIPTION:
398# Wrapper for detection if we want to run enable_ prefixed function with same name
399# unconditionaly or only when some useflag is enabled.
400cmake-utils_src_configure() {
401 _inherit_optionaly "src_configure"
402}
403
404# @FUNCTION: cmake-utils_src_compile
405# @DESCRIPTION:
406# Wrapper for detection if we want to run enable_ prefixed function with same name
407# unconditionaly or only when some useflag is enabled.
408cmake-utils_src_compile() {
409 _inherit_optionaly "src_compile"
410}
411
412# @FUNCTION: cmake-utils_src_install
413# @DESCRIPTION:
414# Wrapper for detection if we want to run enable_ prefixed function with same name
415# unconditionaly or only when some useflag is enabled.
416cmake-utils_src_install() {
417 _inherit_optionaly "src_install"
418}
419
420# @FUNCTION: cmake-utils_src_test
421# @DESCRIPTION:
422# Wrapper for detection if we want to run enable_ prefixed function with same name
423# unconditionaly or only when some useflag is enabled.
424cmake-utils_src_test() {
425 _inherit_optionaly "src_test"
426}
427
428
429_execute_optionaly() {
430 local phase="$1"
431 if [[ ${WANT_CMAKE} = always ]]; then
432 enable_cmake-utils_${phase}
433 else
434 use ${WANT_CMAKE} && enable_cmake-utils_${phase}
435 fi
436}

Legend:
Removed from v.1.31  
changed lines
  Added in v.1.32

  ViewVC Help
Powered by ViewVC 1.1.20