/[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.57 Revision 1.65
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.57 2010/08/12 19:27:42 reavertm Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/cmake-utils.eclass,v 1.65 2011/01/20 00:48:51 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#
28# used for optionality) 28# used for optionality)
29WANT_CMAKE="${WANT_CMAKE:-always}" 29WANT_CMAKE="${WANT_CMAKE:-always}"
30 30
31# @ECLASS-VARIABLE: CMAKE_MIN_VERSION 31# @ECLASS-VARIABLE: CMAKE_MIN_VERSION
32# @DESCRIPTION: 32# @DESCRIPTION:
33# Specify the minimum required CMake version. Default is 2.6.2-r1 33# Specify the minimum required CMake version. Default is 2.8.1
34CMAKE_MIN_VERSION="${CMAKE_MIN_VERSION:-2.6.2-r1}" 34CMAKE_MIN_VERSION="${CMAKE_MIN_VERSION:-2.8.1}"
35 35
36CMAKEDEPEND="" 36CMAKEDEPEND=""
37case ${WANT_CMAKE} in 37case ${WANT_CMAKE} in
38 always) 38 always)
39 ;; 39 ;;
136# @DESCRIPTION: 136# @DESCRIPTION:
137# Eclass respects PREFIX variable, though it's not recommended way to set 137# Eclass respects PREFIX variable, though it's not recommended way to set
138# install/lib/bin prefixes. 138# install/lib/bin prefixes.
139# Use -DCMAKE_INSTALL_PREFIX=... CMake variable instead. 139# Use -DCMAKE_INSTALL_PREFIX=... CMake variable instead.
140 140
141# @ECLASS-VARIABLE: CMAKE_BINARY
142# @DESCRIPTION:
143# Eclass can use different cmake binary than the one provided in by system.
144: ${CMAKE_BINARY:=cmake}
145
141# Determine using IN or OUT source build 146# Determine using IN or OUT source build
142_check_build_dir() { 147_check_build_dir() {
143 : ${CMAKE_USE_DIR:=${S}} 148 : ${CMAKE_USE_DIR:=${S}}
144 if [[ -n ${CMAKE_IN_SOURCE_BUILD} ]]; then 149 if [[ -n ${CMAKE_IN_SOURCE_BUILD} ]]; then
145 # we build in source dir 150 # we build in source dir
146 CMAKE_BUILD_DIR="${CMAKE_USE_DIR}" 151 CMAKE_BUILD_DIR="${CMAKE_USE_DIR}"
147 elif [[ ${CMAKE_USE_DIR} = ${WORKDIR} ]]; then
148 # out of tree build, but with $S=$WORKDIR, see bug #273949 for reason.
149 CMAKE_BUILD_DIR="${CMAKE_USE_DIR}/build"
150 else 152 else
151 # regular out of tree build 153 : ${CMAKE_BUILD_DIR:=${WORKDIR}/${P}_build}
152 [[ ${1} = init || -d ${CMAKE_USE_DIR}_build ]] && SUF="_build" || SUF=""
153 CMAKE_BUILD_DIR="${CMAKE_USE_DIR}${SUF}"
154 fi 154 fi
155 echo ">>> Working in BUILD_DIR: \"$CMAKE_BUILD_DIR\"" 155 echo ">>> Working in BUILD_DIR: \"$CMAKE_BUILD_DIR\""
156} 156}
157# @FUNCTION: cmake-utils_use_with 157# @FUNCTION: cmake-utils_use_with
158# @USAGE: <USE flag> [flag name] 158# @USAGE: <USE flag> [flag name]
266} 266}
267 267
268enable_cmake-utils_src_configure() { 268enable_cmake-utils_src_configure() {
269 debug-print-function ${FUNCNAME} "$@" 269 debug-print-function ${FUNCNAME} "$@"
270 270
271 _check_build_dir init 271 _check_build_dir
272 272
273 # check if CMakeLists.txt exist and if no then die 273 # check if CMakeLists.txt exist and if no then die
274 if [[ ! -e ${CMAKE_USE_DIR}/CMakeLists.txt ]] ; then 274 if [[ ! -e ${CMAKE_USE_DIR}/CMakeLists.txt ]] ; then
275 eerror "Unable to locate CMakeLists.txt under:" 275 eerror "Unable to locate CMakeLists.txt under:"
276 eerror "\"${CMAKE_USE_DIR}/CMakeLists.txt\"" 276 eerror "\"${CMAKE_USE_DIR}/CMakeLists.txt\""
284 # Fix xdg collision with sandbox 284 # Fix xdg collision with sandbox
285 export XDG_CONFIG_HOME="${T}" 285 export XDG_CONFIG_HOME="${T}"
286 286
287 # @SEE CMAKE_BUILD_TYPE 287 # @SEE CMAKE_BUILD_TYPE
288 if [[ ${CMAKE_BUILD_TYPE} = Gentoo ]]; then 288 if [[ ${CMAKE_BUILD_TYPE} = Gentoo ]]; then
289 # Handle debug and release codepaths 289 # Handle release builds
290 if has debug ${IUSE//+} && use debug; then 290 if ! has debug ${IUSE//+} || ! use debug; then
291 append-cppflags -DDEBUG 291 append-cppflags -DNDEBUG
292 else
293 append-cppflags -DNDEBUG -DQT_NO_DEBUG -DQT_NO_DEBUG_STREAM
294 fi 292 fi
295 fi 293 fi
296 294
297 # Prepare Gentoo override rules (set valid compiler, append CPPFLAGS) 295 # Prepare Gentoo override rules (set valid compiler, append CPPFLAGS)
298 local build_rules=${T}/gentoo_rules.cmake 296 local build_rules=${T}/gentoo_rules.cmake
309 # right ... except for Darwin hosts 307 # right ... except for Darwin hosts
310 IF (NOT APPLE) 308 IF (NOT APPLE)
311 SET (CMAKE_SKIP_RPATH OFF CACHE BOOL "" FORCE) 309 SET (CMAKE_SKIP_RPATH OFF CACHE BOOL "" FORCE)
312 SET (CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH "${EPREFIX}/usr/${CHOST}/lib/gcc;${EPREFIX}/usr/${CHOST}/lib;${EPREFIX}/usr/$(get_libdir);${EPREFIX}/$(get_libdir)" 310 SET (CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH "${EPREFIX}/usr/${CHOST}/lib/gcc;${EPREFIX}/usr/${CHOST}/lib;${EPREFIX}/usr/$(get_libdir);${EPREFIX}/$(get_libdir)"
313 CACHE STRING "" FORCE) 311 CACHE STRING "" FORCE)
312
313 ELSE ()
314
315 SET(CMAKE_PREFIX_PATH "${EPREFIX}${PREFIX:-/usr}" CACHE STRING ""FORCE)
316 SET(CMAKE_SKIP_BUILD_RPATH OFF CACHE BOOL "" FORCE)
317 SET(CMAKE_SKIP_RPATH OFF CACHE BOOL "" FORCE)
318 SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE CACHE BOOL "" FORCE)
319 SET(CMAKE_INSTALL_RPATH "${EPREFIX}${PREFIX:-/usr}/lib;${EPREFIX}/usr/${CHOST}/lib/gcc;${EPREFIX}/usr/${CHOST}/lib;${EPREFIX}/usr/$(get_libdir);${EPREFIX}/$(get_libdir)" CACHE STRING "" FORCE)
320 SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE CACHE BOOL "" FORCE)
321 SET(CMAKE_INSTALL_NAME_DIR "${EPREFIX}${PREFIX:-/usr}/lib" CACHE STRING "" FORCE)
322
314 ENDIF (NOT APPLE) 323 ENDIF (NOT APPLE)
315 _EOF_ 324 _EOF_
316 fi 325 fi
317 326
318 # Common configure parameters (invariants) 327 # Common configure parameters (invariants)
349 ) 358 )
350 359
351 mkdir -p "${CMAKE_BUILD_DIR}" 360 mkdir -p "${CMAKE_BUILD_DIR}"
352 pushd "${CMAKE_BUILD_DIR}" > /dev/null 361 pushd "${CMAKE_BUILD_DIR}" > /dev/null
353 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: mycmakeargs is ${mycmakeargs_local[*]}" 362 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: mycmakeargs is ${mycmakeargs_local[*]}"
354 echo cmake "${cmakeargs[@]}" "${CMAKE_USE_DIR}" 363 echo "${CMAKE_BINARY}" "${cmakeargs[@]}" "${CMAKE_USE_DIR}"
355 cmake "${cmakeargs[@]}" "${CMAKE_USE_DIR}" || die "cmake failed" 364 "${CMAKE_BINARY}" "${cmakeargs[@]}" "${CMAKE_USE_DIR}" || die "cmake failed"
356 popd > /dev/null 365 popd > /dev/null
357} 366}
358 367
359enable_cmake-utils_src_compile() { 368enable_cmake-utils_src_compile() {
360 debug-print-function ${FUNCNAME} "$@" 369 debug-print-function ${FUNCNAME} "$@"
385enable_cmake-utils_src_install() { 394enable_cmake-utils_src_install() {
386 debug-print-function ${FUNCNAME} "$@" 395 debug-print-function ${FUNCNAME} "$@"
387 396
388 _check_build_dir 397 _check_build_dir
389 pushd "${CMAKE_BUILD_DIR}" > /dev/null 398 pushd "${CMAKE_BUILD_DIR}" > /dev/null
390 base_src_install 399 base_src_install "$@"
391 popd > /dev/null 400 popd > /dev/null
392 401
393 # Backward compatibility, for non-array variables 402 # Backward compatibility, for non-array variables
394 if [[ -n "${DOCS}" ]] && [[ "$(declare -p DOCS 2>/dev/null 2>&1)" != "declare -a"* ]]; then 403 if [[ -n "${DOCS}" ]] && [[ "$(declare -p DOCS 2>/dev/null 2>&1)" != "declare -a"* ]]; then
395 dodoc ${DOCS} || die "dodoc failed" 404 dodoc ${DOCS} || die "dodoc failed"
404 413
405 _check_build_dir 414 _check_build_dir
406 pushd "${CMAKE_BUILD_DIR}" > /dev/null 415 pushd "${CMAKE_BUILD_DIR}" > /dev/null
407 local ctestargs 416 local ctestargs
408 [[ -n ${TEST_VERBOSE} ]] && ctestargs="--extra-verbose --output-on-failure" 417 [[ -n ${TEST_VERBOSE} ]] && ctestargs="--extra-verbose --output-on-failure"
409 ctest ${ctestargs} || die "Tests failed." 418 ctest ${ctestargs} "$@" || die "Tests failed."
410 popd > /dev/null 419 popd > /dev/null
411} 420}
412 421
413# @FUNCTION: cmake-utils_src_configure 422# @FUNCTION: cmake-utils_src_configure
414# @DESCRIPTION: 423# @DESCRIPTION:

Legend:
Removed from v.1.57  
changed lines
  Added in v.1.65

  ViewVC Help
Powered by ViewVC 1.1.20