summaryrefslogtreecommitdiff
path: root/eclass/cmake-utils.eclass
diff options
context:
space:
mode:
authorJohannes Huber <johu@gentoo.org>2012-08-23 11:14:22 +0200
committerJohannes Huber <johu@gentoo.org>2012-08-23 11:14:22 +0200
commitfb9a15dcaa9714692d2f33f51464158fe7a14ca6 (patch)
tree08991a1306bff9848fe4ac101ed3353fd179ee00 /eclass/cmake-utils.eclass
parent092cb92adf6337e666dbd09b4dc9a23fa26c0e98 (diff)
downloadkde-fb9a15dcaa9714692d2f33f51464158fe7a14ca6.tar.gz
kde-fb9a15dcaa9714692d2f33f51464158fe7a14ca6.tar.bz2
kde-fb9a15dcaa9714692d2f33f51464158fe7a14ca6.zip
[eclass] Add support for dev-util/ninja by Christoph Junghans
<ottxor@gentoo.org> wrt bug #430608.
Diffstat (limited to 'eclass/cmake-utils.eclass')
-rw-r--r--eclass/cmake-utils.eclass43
1 files changed, 37 insertions, 6 deletions
diff --git a/eclass/cmake-utils.eclass b/eclass/cmake-utils.eclass
index dbe73e92afd..a0f6e6ba1e3 100644
--- a/eclass/cmake-utils.eclass
+++ b/eclass/cmake-utils.eclass
@@ -42,6 +42,12 @@ CMAKE_REMOVE_MODULES_LIST="${CMAKE_REMOVE_MODULES_LIST:-FindBLAS FindLAPACK}"
# Do we want to remove anything? yes or whatever else for no
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}"
+
CMAKEDEPEND=""
case ${WANT_CMAKE} in
always)
@@ -166,6 +172,15 @@ _check_build_dir() {
mkdir -p "${CMAKE_BUILD_DIR}"
echo ">>> Working in BUILD_DIR: \"$CMAKE_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"
+}
+
# @FUNCTION: cmake-utils_use_with
# @USAGE: <USE flag> [flag name]
# @DESCRIPTION:
@@ -372,6 +387,7 @@ enable_cmake-utils_src_configure() {
local cmakeargs=(
--no-warn-unused-cli
-C "${common_config}"
+ -G "$(_generator_to_use)"
-DCMAKE_INSTALL_PREFIX="${EPREFIX}${PREFIX}"
"${mycmakeargs_local[@]}"
-DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}"
@@ -403,12 +419,23 @@ cmake-utils_src_make() {
_check_build_dir
pushd "${CMAKE_BUILD_DIR}" > /dev/null
- # first check if Makefile exist otherwise die
- [[ -e Makefile ]] || die "Makefile not found. Error during configure stage."
- if [[ "${CMAKE_VERBOSE}" != "OFF" ]]; then
- emake VERBOSE=1 "$@" || die "Make failed!"
+ 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!"
else
- emake "$@" || die "Make failed!"
+ # first check if Makefile exist otherwise die
+ [[ -e Makefile ]] || die "Makefile not found. Error during configure stage."
+ if [[ "${CMAKE_VERBOSE}" != "OFF" ]]; then
+ emake VERBOSE=1 "$@" || die "Make failed!"
+ else
+ emake "$@" || die "Make failed!"
+ fi
fi
popd > /dev/null
}
@@ -418,7 +445,11 @@ enable_cmake-utils_src_install() {
_check_build_dir
pushd "${CMAKE_BUILD_DIR}" > /dev/null
- base_src_install "$@"
+ if [[ $(_generator_to_use) = Ninja ]]; then
+ DESTDIR=${D} ninja install "$@"
+ else
+ base_src_install "$@"
+ fi
popd > /dev/null
# Backward compatibility, for non-array variables