/[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.85 Revision 1.86
1# Copyright 1999-2012 Gentoo Foundation 1# Copyright 1999-2012 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.85 2012/10/25 12:48:58 scarabeus Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/cmake-utils.eclass,v 1.86 2012/12/01 16:26:03 mgorny 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:
112 echo "-D$1$x=$(use $2 && echo OFF || echo ON) " 112 echo "-D$1$x=$(use $2 && echo OFF || echo ON) "
113 done 113 done
114 fi 114 fi
115} 115}
116 116
117# @ECLASS-VARIABLE: CMAKE_BUILD_DIR 117# @ECLASS-VARIABLE: BUILD_DIR
118# @DESCRIPTION: 118# @DESCRIPTION:
119# Build directory where all cmake processed files should be generated. 119# Build directory where all cmake processed files should be generated.
120# For in-source build it's fixed to ${CMAKE_USE_DIR}. 120# 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 121# For out-of-source build it can be overriden, by default it uses
122# ${WORKDIR}/${P}_build. 122# ${WORKDIR}/${P}_build.
123#
124# This variable has been called CMAKE_BUILD_DIR formerly.
125# It is set under that name for compatibility.
123 126
124# @ECLASS-VARIABLE: CMAKE_BUILD_TYPE 127# @ECLASS-VARIABLE: CMAKE_BUILD_TYPE
125# @DESCRIPTION: 128# @DESCRIPTION:
126# Set to override default CMAKE_BUILD_TYPE. Only useful for packages 129# Set to override default CMAKE_BUILD_TYPE. Only useful for packages
127# known to make use of "if (CMAKE_BUILD_TYPE MATCHES xxx)". 130# known to make use of "if (CMAKE_BUILD_TYPE MATCHES xxx)".
161# Determine using IN or OUT source build 164# Determine using IN or OUT source build
162_check_build_dir() { 165_check_build_dir() {
163 : ${CMAKE_USE_DIR:=${S}} 166 : ${CMAKE_USE_DIR:=${S}}
164 if [[ -n ${CMAKE_IN_SOURCE_BUILD} ]]; then 167 if [[ -n ${CMAKE_IN_SOURCE_BUILD} ]]; then
165 # we build in source dir 168 # we build in source dir
166 CMAKE_BUILD_DIR="${CMAKE_USE_DIR}" 169 BUILD_DIR="${CMAKE_USE_DIR}"
167 else 170 else
168 : ${CMAKE_BUILD_DIR:=${WORKDIR}/${P}_build} 171 : ${BUILD_DIR:=${CMAKE_BUILD_DIR:-${WORKDIR}/${P}_build}}
169 fi 172 fi
173 CMAKE_BUILD_DIR=${BUILD_DIR}
174
170 mkdir -p "${CMAKE_BUILD_DIR}" 175 mkdir -p "${BUILD_DIR}"
171 echo ">>> Working in BUILD_DIR: \"$CMAKE_BUILD_DIR\"" 176 echo ">>> Working in BUILD_DIR: \"$BUILD_DIR\""
172} 177}
173 178
174# Determine which generator to use 179# Determine which generator to use
175_generator_to_use() { 180_generator_to_use() {
176 if [[ ${CMAKE_MAKEFILE_GENERATOR} = "ninja" ]]; then 181 if [[ ${CMAKE_MAKEFILE_GENERATOR} = "ninja" ]]; then
326 append-cppflags -DNDEBUG 331 append-cppflags -DNDEBUG
327 fi 332 fi
328 fi 333 fi
329 334
330 # Prepare Gentoo override rules (set valid compiler, append CPPFLAGS etc.) 335 # Prepare Gentoo override rules (set valid compiler, append CPPFLAGS etc.)
331 local build_rules=${CMAKE_BUILD_DIR}/gentoo_rules.cmake 336 local build_rules=${BUILD_DIR}/gentoo_rules.cmake
332 cat > "${build_rules}" <<- _EOF_ 337 cat > "${build_rules}" <<- _EOF_
333 SET (CMAKE_AR $(type -P $(tc-getAR)) CACHE FILEPATH "Archive manager" FORCE) 338 SET (CMAKE_AR $(type -P $(tc-getAR)) CACHE FILEPATH "Archive manager" FORCE)
334 SET (CMAKE_C_COMPILER $(type -P $(tc-getCC)) CACHE FILEPATH "C compiler" FORCE) 339 SET (CMAKE_C_COMPILER $(type -P $(tc-getCC)) CACHE FILEPATH "C compiler" FORCE)
335 SET (CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> <DEFINES> ${CPPFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "C compile command" FORCE) 340 SET (CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> <DEFINES> ${CPPFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "C compile command" FORCE)
336 SET (CMAKE_CXX_COMPILER $(type -P $(tc-getCXX)) CACHE FILEPATH "C++ compiler" FORCE) 341 SET (CMAKE_CXX_COMPILER $(type -P $(tc-getCXX)) CACHE FILEPATH "C++ compiler" FORCE)
362 ENDIF (NOT APPLE) 367 ENDIF (NOT APPLE)
363 _EOF_ 368 _EOF_
364 fi 369 fi
365 370
366 # Common configure parameters (invariants) 371 # Common configure parameters (invariants)
367 local common_config=${CMAKE_BUILD_DIR}/gentoo_common_config.cmake 372 local common_config=${BUILD_DIR}/gentoo_common_config.cmake
368 local libdir=$(get_libdir) 373 local libdir=$(get_libdir)
369 cat > "${common_config}" <<- _EOF_ 374 cat > "${common_config}" <<- _EOF_
370 SET (LIB_SUFFIX ${libdir/lib} CACHE STRING "library path suffix" FORCE) 375 SET (LIB_SUFFIX ${libdir/lib} CACHE STRING "library path suffix" FORCE)
371 SET (CMAKE_INSTALL_LIBDIR ${libdir} CACHE PATH "Output directory for libraries") 376 SET (CMAKE_INSTALL_LIBDIR ${libdir} CACHE PATH "Output directory for libraries")
372 _EOF_ 377 _EOF_
394 -DCMAKE_INSTALL_DO_STRIP=OFF 399 -DCMAKE_INSTALL_DO_STRIP=OFF
395 -DCMAKE_USER_MAKE_RULES_OVERRIDE="${build_rules}" 400 -DCMAKE_USER_MAKE_RULES_OVERRIDE="${build_rules}"
396 "${MYCMAKEARGS}" 401 "${MYCMAKEARGS}"
397 ) 402 )
398 403
399 pushd "${CMAKE_BUILD_DIR}" > /dev/null 404 pushd "${BUILD_DIR}" > /dev/null
400 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: mycmakeargs is ${mycmakeargs_local[*]}" 405 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: mycmakeargs is ${mycmakeargs_local[*]}"
401 echo "${CMAKE_BINARY}" "${cmakeargs[@]}" "${CMAKE_USE_DIR}" 406 echo "${CMAKE_BINARY}" "${cmakeargs[@]}" "${CMAKE_USE_DIR}"
402 "${CMAKE_BINARY}" "${cmakeargs[@]}" "${CMAKE_USE_DIR}" || die "cmake failed" 407 "${CMAKE_BINARY}" "${cmakeargs[@]}" "${CMAKE_USE_DIR}" || die "cmake failed"
403 popd > /dev/null 408 popd > /dev/null
404} 409}
416# All arguments are passed to emake. 421# All arguments are passed to emake.
417cmake-utils_src_make() { 422cmake-utils_src_make() {
418 debug-print-function ${FUNCNAME} "$@" 423 debug-print-function ${FUNCNAME} "$@"
419 424
420 _check_build_dir 425 _check_build_dir
421 pushd "${CMAKE_BUILD_DIR}" > /dev/null 426 pushd "${BUILD_DIR}" > /dev/null
422 if [[ $(_generator_to_use) = Ninja ]]; then 427 if [[ $(_generator_to_use) = Ninja ]]; then
423 # first check if Makefile exist otherwise die 428 # first check if Makefile exist otherwise die
424 [[ -e build.ninja ]] || die "Makefile not found. Error during configure stage." 429 [[ -e build.ninja ]] || die "Makefile not found. Error during configure stage."
425 if [[ "${CMAKE_VERBOSE}" != "OFF" ]]; then 430 if [[ "${CMAKE_VERBOSE}" != "OFF" ]]; then
426 #TODO get load average from portage (-l option) 431 #TODO get load average from portage (-l option)
442 447
443enable_cmake-utils_src_install() { 448enable_cmake-utils_src_install() {
444 debug-print-function ${FUNCNAME} "$@" 449 debug-print-function ${FUNCNAME} "$@"
445 450
446 _check_build_dir 451 _check_build_dir
447 pushd "${CMAKE_BUILD_DIR}" > /dev/null 452 pushd "${BUILD_DIR}" > /dev/null
448 if [[ $(_generator_to_use) = Ninja ]]; then 453 if [[ $(_generator_to_use) = Ninja ]]; then
449 DESTDIR=${D} ninja install "$@" || die "died running ninja install" 454 DESTDIR=${D} ninja install "$@" || die "died running ninja install"
450 base_src_install_docs 455 base_src_install_docs
451 else 456 else
452 base_src_install "$@" 457 base_src_install "$@"
465enable_cmake-utils_src_test() { 470enable_cmake-utils_src_test() {
466 debug-print-function ${FUNCNAME} "$@" 471 debug-print-function ${FUNCNAME} "$@"
467 local ctestargs 472 local ctestargs
468 473
469 _check_build_dir 474 _check_build_dir
470 pushd "${CMAKE_BUILD_DIR}" > /dev/null 475 pushd "${BUILD_DIR}" > /dev/null
471 [[ -e CTestTestfile.cmake ]] || { echo "No tests found. Skipping."; return 0 ; } 476 [[ -e CTestTestfile.cmake ]] || { echo "No tests found. Skipping."; return 0 ; }
472 477
473 [[ -n ${TEST_VERBOSE} ]] && ctestargs="--extra-verbose --output-on-failure" 478 [[ -n ${TEST_VERBOSE} ]] && ctestargs="--extra-verbose --output-on-failure"
474 479
475 if ctest ${ctestargs} "$@" ; then 480 if ctest ${ctestargs} "$@" ; then
477 popd > /dev/null 482 popd > /dev/null
478 return 0 483 return 0
479 else 484 else
480 if [[ -n "${CMAKE_YES_I_WANT_TO_SEE_THE_TEST_LOG}" ]] ; then 485 if [[ -n "${CMAKE_YES_I_WANT_TO_SEE_THE_TEST_LOG}" ]] ; then
481 # on request from Diego 486 # on request from Diego
482 eerror "Tests failed. Test log ${CMAKE_BUILD_DIR}/Testing/Temporary/LastTest.log follows:" 487 eerror "Tests failed. Test log ${BUILD_DIR}/Testing/Temporary/LastTest.log follows:"
483 eerror "--START TEST LOG--------------------------------------------------------------" 488 eerror "--START TEST LOG--------------------------------------------------------------"
484 cat "${CMAKE_BUILD_DIR}/Testing/Temporary/LastTest.log" 489 cat "${BUILD_DIR}/Testing/Temporary/LastTest.log"
485 eerror "--END TEST LOG----------------------------------------------------------------" 490 eerror "--END TEST LOG----------------------------------------------------------------"
486 die "Tests failed." 491 die "Tests failed."
487 else 492 else
488 die "Tests failed. When you file a bug, please attach the following file: \n\t${CMAKE_BUILD_DIR}/Testing/Temporary/LastTest.log" 493 die "Tests failed. When you file a bug, please attach the following file: \n\t${BUILD_DIR}/Testing/Temporary/LastTest.log"
489 fi 494 fi
490 495
491 # die might not die due to nonfatal 496 # die might not die due to nonfatal
492 popd > /dev/null 497 popd > /dev/null
493 return 1 498 return 1

Legend:
Removed from v.1.85  
changed lines
  Added in v.1.86

  ViewVC Help
Powered by ViewVC 1.1.20