/[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.111 Revision 1.112
1# Copyright 1999-2014 Gentoo Foundation 1# Copyright 1999-2014 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.111 2014/10/15 13:44:24 kensington Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/cmake-utils.eclass,v 1.112 2014/10/27 09:49:05 aballier 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:
104# This is useful when only part of application is using cmake build system. 104# This is useful when only part of application is using cmake build system.
105# Valid values are: always [default], optional (where the value is the useflag 105# Valid values are: always [default], optional (where the value is the useflag
106# used for optionality) 106# used for optionality)
107: ${WANT_CMAKE:=always} 107: ${WANT_CMAKE:=always}
108 108
109# @ECLASS-VARIABLE: CMAKE_EXTRA_CACHE_FILE
110# @DESCRIPTION:
111# Specifies an extra cache file to pass to cmake. This is the analog of EXTRA_ECONF
112# for econf and is needed to pass TRY_RUN results when cross-compiling.
113# Should be set by user in a per-package basis in /etc/portage/package.env.
109 114
110CMAKEDEPEND="" 115CMAKEDEPEND=""
111case ${WANT_CMAKE} in 116case ${WANT_CMAKE} in
112 always) 117 always)
113 ;; 118 ;;
452 # Prepare Gentoo override rules (set valid compiler, append CPPFLAGS etc.) 457 # Prepare Gentoo override rules (set valid compiler, append CPPFLAGS etc.)
453 local build_rules=${BUILD_DIR}/gentoo_rules.cmake 458 local build_rules=${BUILD_DIR}/gentoo_rules.cmake
454 cat > "${build_rules}" <<- _EOF_ 459 cat > "${build_rules}" <<- _EOF_
455 SET (CMAKE_AR $(type -P $(tc-getAR)) CACHE FILEPATH "Archive manager" FORCE) 460 SET (CMAKE_AR $(type -P $(tc-getAR)) CACHE FILEPATH "Archive manager" FORCE)
456 SET (CMAKE_ASM_COMPILE_OBJECT "<CMAKE_C_COMPILER> <DEFINES> ${CFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "ASM compile command" FORCE) 461 SET (CMAKE_ASM_COMPILE_OBJECT "<CMAKE_C_COMPILER> <DEFINES> ${CFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "ASM compile command" FORCE)
457 SET (CMAKE_C_COMPILER $(type -P $(tc-getCC)) CACHE FILEPATH "C compiler" FORCE)
458 SET (CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> <DEFINES> ${CPPFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "C compile command" FORCE) 462 SET (CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> <DEFINES> ${CPPFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "C compile command" FORCE)
459 SET (CMAKE_CXX_COMPILER $(type -P $(tc-getCXX)) CACHE FILEPATH "C++ compiler" FORCE)
460 SET (CMAKE_CXX_COMPILE_OBJECT "<CMAKE_CXX_COMPILER> <DEFINES> ${CPPFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "C++ compile command" FORCE) 463 SET (CMAKE_CXX_COMPILE_OBJECT "<CMAKE_CXX_COMPILER> <DEFINES> ${CPPFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "C++ compile command" FORCE)
461 SET (CMAKE_RANLIB $(type -P $(tc-getRANLIB)) CACHE FILEPATH "Archive index generator" FORCE) 464 SET (CMAKE_RANLIB $(type -P $(tc-getRANLIB)) CACHE FILEPATH "Archive index generator" FORCE)
462 SET (PKG_CONFIG_EXECUTABLE $(type -P $(tc-getPKG_CONFIG)) CACHE FILEPATH "pkg-config executable" FORCE) 465 SET (PKG_CONFIG_EXECUTABLE $(type -P $(tc-getPKG_CONFIG)) CACHE FILEPATH "pkg-config executable" FORCE)
463 _EOF_ 466 _EOF_
467
468 local toolchain_file=${BUILD_DIR}/gentoo_toolchain.cmake
469 cat > ${toolchain_file} <<- _EOF_
470 SET (CMAKE_C_COMPILER $(tc-getCC))
471 SET (CMAKE_CXX_COMPILER $(tc-getCXX))
472 _EOF_
473
474 if tc-is-cross-compiler; then
475 local sysname
476 case "${KERNEL:-linux}" in
477 Cygwin) sysname="CYGWIN_NT-5.1" ;;
478 HPUX) sysname="HP-UX" ;;
479 linux) sysname="Linux" ;;
480 Winnt) sysname="Windows" ;;
481 *) sysname="${KERNEL}" ;;
482 esac
483
484 cat >> "${toolchain_file}" <<- _EOF_
485 SET (CMAKE_SYSTEM_NAME "${sysname}")
486 _EOF_
487
488 if [ "${SYSROOT:-/}" != "/" ] ; then
489 # When cross-compiling with a sysroot (e.g. with crossdev's emerge wrappers)
490 # we need to tell cmake to use libs/headers from the sysroot but programs from / only.
491 cat >> "${toolchain_file}" <<- _EOF_
492 set(CMAKE_FIND_ROOT_PATH "${SYSROOT}")
493 set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
494 set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
495 set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
496 _EOF_
497 fi
498 fi
464 499
465 has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX= 500 has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
466 501
467 if [[ ${EPREFIX} ]]; then 502 if [[ ${EPREFIX} ]]; then
468 cat >> "${build_rules}" <<- _EOF_ 503 cat >> "${build_rules}" <<- _EOF_
521 -DCMAKE_INSTALL_PREFIX="${EPREFIX}${PREFIX}" 556 -DCMAKE_INSTALL_PREFIX="${EPREFIX}${PREFIX}"
522 "${mycmakeargs_local[@]}" 557 "${mycmakeargs_local[@]}"
523 -DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" 558 -DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}"
524 -DCMAKE_INSTALL_DO_STRIP=OFF 559 -DCMAKE_INSTALL_DO_STRIP=OFF
525 -DCMAKE_USER_MAKE_RULES_OVERRIDE="${build_rules}" 560 -DCMAKE_USER_MAKE_RULES_OVERRIDE="${build_rules}"
561 -DCMAKE_TOOLCHAIN_FILE="${toolchain_file}"
526 "${MYCMAKEARGS}" 562 "${MYCMAKEARGS}"
527 ) 563 )
564
565 if [[ -n "${CMAKE_EXTRA_CACHE_FILE}" ]] ; then
566 cmakeargs+=( -C "${CMAKE_EXTRA_CACHE_FILE}" )
567 fi
528 568
529 pushd "${BUILD_DIR}" > /dev/null 569 pushd "${BUILD_DIR}" > /dev/null
530 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: mycmakeargs is ${mycmakeargs_local[*]}" 570 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: mycmakeargs is ${mycmakeargs_local[*]}"
531 echo "${CMAKE_BINARY}" "${cmakeargs[@]}" "${CMAKE_USE_DIR}" 571 echo "${CMAKE_BINARY}" "${cmakeargs[@]}" "${CMAKE_USE_DIR}"
532 "${CMAKE_BINARY}" "${cmakeargs[@]}" "${CMAKE_USE_DIR}" || die "cmake failed" 572 "${CMAKE_BINARY}" "${cmakeargs[@]}" "${CMAKE_USE_DIR}" || die "cmake failed"

Legend:
Removed from v.1.111  
changed lines
  Added in v.1.112

  ViewVC Help
Powered by ViewVC 1.1.20