summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorMichael Palimaka <kensington@gentoo.org>2013-02-07 15:41:34 +0000
committerMichael Palimaka <kensington@gentoo.org>2013-02-07 15:41:34 +0000
commitb71011ec4fecc9a667289fbf58083ff1dbcef852 (patch)
treed82a7b0ba4ca7bca50cd7779b597606b9a2b92f6 /eclass
parentversion bump, EAPI 5, use subslots (diff)
downloadhistorical-b71011ec4fecc9a667289fbf58083ff1dbcef852.tar.gz
historical-b71011ec4fecc9a667289fbf58083ff1dbcef852.tar.bz2
historical-b71011ec4fecc9a667289fbf58083ff1dbcef852.zip
Export src_prepare. Improve support for dev-util/ninja wrt bug #439608. Add support for CMAKE_DISABLE_FIND_PACKAGE wrt bug #453746.
Diffstat (limited to 'eclass')
-rw-r--r--eclass/ChangeLog6
-rw-r--r--eclass/cmake-utils.eclass133
2 files changed, 104 insertions, 35 deletions
diff --git a/eclass/ChangeLog b/eclass/ChangeLog
index ad64b7c6da2b..ec4bb7480f66 100644
--- a/eclass/ChangeLog
+++ b/eclass/ChangeLog
@@ -1,6 +1,10 @@
# ChangeLog for eclass directory
# Copyright 1999-2013 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.662 2013/02/07 03:38:33 alexxy Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.663 2013/02/07 15:41:34 kensington Exp $
+
+ 07 Feb 2013; Michael Palimaka <kensington@gentoo.org> cmake-utils.eclass:
+ Export src_prepare. Improve support for dev-util/ninja wrt bug #439608. Add
+ support for CMAKE_DISABLE_FIND_PACKAGE wrt bug #453746.
07 Feb 2013; Alexey Shvetsov <alexxy@gentoo.org> kde4-base.eclass,
kde4-functions.eclass, kde4-meta.eclass, kde4-meta-pkg.eclass:
diff --git a/eclass/cmake-utils.eclass b/eclass/cmake-utils.eclass
index cadabe92220e..0aa52a9e4f4f 100644
--- a/eclass/cmake-utils.eclass
+++ b/eclass/cmake-utils.eclass
@@ -1,6 +1,6 @@
-# Copyright 1999-2012 Gentoo Foundation
+# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/cmake-utils.eclass,v 1.91 2013/01/17 20:18:28 creffett Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/cmake-utils.eclass,v 1.92 2013/02/07 15:41:34 kensington Exp $
# @ECLASS: cmake-utils.eclass
# @MAINTAINER:
@@ -28,7 +28,7 @@ WANT_CMAKE="${WANT_CMAKE:-always}"
# @ECLASS-VARIABLE: CMAKE_MIN_VERSION
# @DESCRIPTION:
-# Specify the minimum required CMake version. Default is 2.8.4
+# Specify the minimum required CMake version.
CMAKE_MIN_VERSION="${CMAKE_MIN_VERSION:-2.8.8}"
# @ECLASS-VARIABLE: CMAKE_REMOVE_MODULES_LIST
@@ -44,9 +44,9 @@ CMAKE_REMOVE_MODULES="${CMAKE_REMOVE_MODULES:-yes}"
# @ECLASS-VARIABLE: CMAKE_MAKEFILE_GENERATOR
# @DESCRIPTION:
-# Specify a makefile generator to be used by cmake. At this point only "make"
-# and "ninja" is supported.
-CMAKE_MAKEFILE_GENERATOR="${CMAKE_MAKEFILE_GENERATOR:-make}"
+# Specify a makefile generator to be used by cmake.
+# At this point only "emake" and "ninja" are supported.
+CMAKE_MAKEFILE_GENERATOR="${CMAKE_MAKEFILE_GENERATOR:-emake}"
CMAKEDEPEND=""
case ${WANT_CMAKE} in
@@ -61,12 +61,25 @@ inherit toolchain-funcs multilib flag-o-matic base
CMAKE_EXPF="src_compile src_test src_install"
case ${EAPI:-0} in
- 2|3|4|5) CMAKE_EXPF+=" src_configure" ;;
+ 2|3|4|5) CMAKE_EXPF+=" src_prepare src_configure" ;;
1|0) ;;
*) die "Unknown EAPI, Bug eclass maintainers." ;;
esac
EXPORT_FUNCTIONS ${CMAKE_EXPF}
+case ${CMAKE_MAKEFILE_GENERATOR} in
+ emake)
+ CMAKEDEPEND+=" sys-devel/make"
+ ;;
+ ninja)
+ CMAKEDEPEND+=" dev-util/ninja"
+ ;;
+ *)
+ eerror "Unknown value for \${CMAKE_MAKEFILE_GENERATOR}"
+ die "Value ${CMAKE_MAKEFILE_GENERATOR} is not supported"
+ ;;
+esac
+
if [[ ${PN} != cmake ]]; then
CMAKEDEPEND+=" >=dev-util/cmake-${CMAKE_MIN_VERSION}"
fi
@@ -195,10 +208,22 @@ _check_build_dir() {
# Determine which generator to use
_generator_to_use() {
- if [[ ${CMAKE_MAKEFILE_GENERATOR} = "ninja" ]]; then
- has_version dev-util/ninja && echo "Ninja" && return
- fi
- echo "Unix Makefiles"
+ local generator_name
+
+ case ${CMAKE_MAKEFILE_GENERATOR} in
+ ninja)
+ generator_name="Ninja"
+ ;;
+ emake)
+ generator_name="Unix Makefiles"
+ ;;
+ *)
+ eerror "Unknown value for \${CMAKE_MAKEFILE_GENERATOR}"
+ die "Value ${CMAKE_MAKEFILE_GENERATOR} is not supported"
+ ;;
+ esac
+
+ echo ${generator_name}
}
# @FUNCTION: cmake-utils_use_with
@@ -219,6 +244,16 @@ cmake-utils_use_with() { _use_me_now WITH_ "$@" ; }
# and -DENABLE_FOO=OFF if it is disabled.
cmake-utils_use_enable() { _use_me_now ENABLE_ "$@" ; }
+# @FUNCTION: cmake-utils_use_find_package
+# @USAGE: <USE flag> [flag name]
+# @DESCRIPTION:
+# Based on use_enable. See ebuild(5).
+#
+# `cmake-utils_use_find_package foo FOO` echoes -DCMAKE_DISABLE_FIND_PACKAGE=OFF
+# if foo is enabled and -DCMAKE_DISABLE_FIND_PACKAGE=ON if it is disabled.
+# This can be used to make find_package optional (since cmake-2.8.6).
+cmake-utils_use_find_package() { _use_me_now_inverted CMAKE_DISABLE_FIND_PACKAGE_ "$@" ; }
+
# @FUNCTION: cmake-utils_use_disable
# @USAGE: <USE flag> [flag name]
# @DESCRIPTION:
@@ -315,6 +350,12 @@ _modify-cmakelists() {
_EOF_
}
+enable_cmake-utils_src_prepare() {
+ debug-print-function ${FUNCNAME} "$@"
+
+ base_src_prepare
+}
+
enable_cmake-utils_src_configure() {
debug-print-function ${FUNCNAME} "$@"
@@ -433,33 +474,52 @@ enable_cmake-utils_src_compile() {
cmake-utils_src_make "$@"
}
-# @FUNCTION: cmake-utils_src_make
+# @FUNCTION: ninja_src_make
+# @INTERNAL
# @DESCRIPTION:
-# Function for building the package. Automatically detects the build type.
-# All arguments are passed to emake.
-cmake-utils_src_make() {
+# Build the package using ninja generator
+ninja_src_make() {
debug-print-function ${FUNCNAME} "$@"
- _check_build_dir
- pushd "${BUILD_DIR}" > /dev/null
- if [[ $(_generator_to_use) = Ninja ]]; then
- # first check if Makefile exist otherwise die
[[ -e build.ninja ]] || die "Makefile not found. Error during configure stage."
+
if [[ "${CMAKE_VERBOSE}" != "OFF" ]]; then
- #TODO get load average from portage (-l option)
- ninja ${MAKEOPTS} -v "$@"
- else
- ninja "$@"
- fi || die "ninja failed!"
+ # TODO: get load average from portage (-l option)
+ ninja ${MAKEOPTS} -v "$@" || die
else
- # first check if Makefile exist otherwise die
+ ninja "$@" || die
+ fi
+}
+
+# @FUNCTION: make_src_make
+# @INTERNAL
+# @DESCRIPTION:
+# Build the package using make generator
+emake_src_make() {
+ debug-print-function ${FUNCNAME} "$@"
+
[[ -e Makefile ]] || die "Makefile not found. Error during configure stage."
+
if [[ "${CMAKE_VERBOSE}" != "OFF" ]]; then
- emake VERBOSE=1 "$@" || die "Make failed!"
+ emake VERBOSE=1 "$@" || die
else
- emake "$@" || die "Make failed!"
- fi
+ emake "$@" || die
fi
+
+}
+
+# @FUNCTION: cmake-utils_src_make
+# @DESCRIPTION:
+# Function for building the package. Automatically detects the build type.
+# All arguments are passed to emake.
+cmake-utils_src_make() {
+ debug-print-function ${FUNCNAME} "$@"
+
+ _check_build_dir
+ pushd "${BUILD_DIR}" > /dev/null
+
+ ${CMAKE_MAKEFILE_GENERATOR}_src_make $@
+
popd > /dev/null
}
@@ -468,12 +528,10 @@ enable_cmake-utils_src_install() {
_check_build_dir
pushd "${BUILD_DIR}" > /dev/null
- if [[ $(_generator_to_use) = Ninja ]]; then
- DESTDIR=${D} ninja install "$@" || die "died running ninja install"
- base_src_install_docs
- else
- base_src_install "$@"
- fi
+
+ DESTDIR="${D}" ${CMAKE_MAKEFILE_GENERATOR} install "$@" || die "died running ${CMAKE_MAKEFILE_GENERATOR} install"
+ base_src_install_docs
+
popd > /dev/null
# Backward compatibility, for non-array variables
@@ -516,6 +574,13 @@ enable_cmake-utils_src_test() {
fi
}
+# @FUNCTION: cmake-utils_src_prepare
+# @DESCRIPTION:
+# Wrapper function around base_src_prepare, just to expand the eclass API.
+cmake-utils_src_prepare() {
+ _execute_optionaly "src_prepare" "$@"
+}
+
# @FUNCTION: cmake-utils_src_configure
# @DESCRIPTION:
# General function for configuring with cmake. Default behaviour is to start an