1 |
commit: fb9a15dcaa9714692d2f33f51464158fe7a14ca6 |
2 |
Author: Johannes Huber <johu <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Aug 23 09:14:22 2012 +0000 |
4 |
Commit: Johannes Huber <johu <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Aug 23 09:14:22 2012 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/kde.git;a=commit;h=fb9a15dc |
7 |
|
8 |
[eclass] Add support for dev-util/ninja by Christoph Junghans |
9 |
<ottxor <AT> gentoo.org> wrt bug #430608. |
10 |
|
11 |
--- |
12 |
eclass/cmake-utils.eclass | 43 +++++++++++++++++++++++++++++++++++++------ |
13 |
1 files changed, 37 insertions(+), 6 deletions(-) |
14 |
|
15 |
diff --git a/eclass/cmake-utils.eclass b/eclass/cmake-utils.eclass |
16 |
index dbe73e9..a0f6e6b 100644 |
17 |
--- a/eclass/cmake-utils.eclass |
18 |
+++ b/eclass/cmake-utils.eclass |
19 |
@@ -42,6 +42,12 @@ CMAKE_REMOVE_MODULES_LIST="${CMAKE_REMOVE_MODULES_LIST:-FindBLAS FindLAPACK}" |
20 |
# Do we want to remove anything? yes or whatever else for no |
21 |
CMAKE_REMOVE_MODULES="${CMAKE_REMOVE_MODULES:-yes}" |
22 |
|
23 |
+# @ECLASS-VARIABLE: CMAKE_MAKEFILE_GENERATOR |
24 |
+# @DESCRIPTION: |
25 |
+# Specify a makefile generator to be used by cmake. At this point only "make" |
26 |
+# and "ninja" is supported. |
27 |
+CMAKE_MAKEFILE_GENERATOR="${CMAKE_MAKEFILE_GENERATOR:-make}" |
28 |
+ |
29 |
CMAKEDEPEND="" |
30 |
case ${WANT_CMAKE} in |
31 |
always) |
32 |
@@ -166,6 +172,15 @@ _check_build_dir() { |
33 |
mkdir -p "${CMAKE_BUILD_DIR}" |
34 |
echo ">>> Working in BUILD_DIR: \"$CMAKE_BUILD_DIR\"" |
35 |
} |
36 |
+ |
37 |
+# Determine which generator to use |
38 |
+_generator_to_use() { |
39 |
+ if [[ ${CMAKE_MAKEFILE_GENERATOR} = "ninja" ]]; then |
40 |
+ has_version dev-util/ninja && echo "Ninja" && return |
41 |
+ fi |
42 |
+ echo "Unix Makefiles" |
43 |
+} |
44 |
+ |
45 |
# @FUNCTION: cmake-utils_use_with |
46 |
# @USAGE: <USE flag> [flag name] |
47 |
# @DESCRIPTION: |
48 |
@@ -372,6 +387,7 @@ enable_cmake-utils_src_configure() { |
49 |
local cmakeargs=( |
50 |
--no-warn-unused-cli |
51 |
-C "${common_config}" |
52 |
+ -G "$(_generator_to_use)" |
53 |
-DCMAKE_INSTALL_PREFIX="${EPREFIX}${PREFIX}" |
54 |
"${mycmakeargs_local[@]}" |
55 |
-DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" |
56 |
@@ -403,12 +419,23 @@ cmake-utils_src_make() { |
57 |
|
58 |
_check_build_dir |
59 |
pushd "${CMAKE_BUILD_DIR}" > /dev/null |
60 |
- # first check if Makefile exist otherwise die |
61 |
- [[ -e Makefile ]] || die "Makefile not found. Error during configure stage." |
62 |
- if [[ "${CMAKE_VERBOSE}" != "OFF" ]]; then |
63 |
- emake VERBOSE=1 "$@" || die "Make failed!" |
64 |
+ if [[ $(_generator_to_use) = Ninja ]]; then |
65 |
+ # first check if Makefile exist otherwise die |
66 |
+ [[ -e build.ninja ]] || die "Makefile not found. Error during configure stage." |
67 |
+ if [[ "${CMAKE_VERBOSE}" != "OFF" ]]; then |
68 |
+ #TODO get load average from portage (-l option) |
69 |
+ ninja ${MAKEOPTS} -v "$@" |
70 |
+ else |
71 |
+ ninja "$@" |
72 |
+ fi || die "ninja failed!" |
73 |
else |
74 |
- emake "$@" || die "Make failed!" |
75 |
+ # first check if Makefile exist otherwise die |
76 |
+ [[ -e Makefile ]] || die "Makefile not found. Error during configure stage." |
77 |
+ if [[ "${CMAKE_VERBOSE}" != "OFF" ]]; then |
78 |
+ emake VERBOSE=1 "$@" || die "Make failed!" |
79 |
+ else |
80 |
+ emake "$@" || die "Make failed!" |
81 |
+ fi |
82 |
fi |
83 |
popd > /dev/null |
84 |
} |
85 |
@@ -418,7 +445,11 @@ enable_cmake-utils_src_install() { |
86 |
|
87 |
_check_build_dir |
88 |
pushd "${CMAKE_BUILD_DIR}" > /dev/null |
89 |
- base_src_install "$@" |
90 |
+ if [[ $(_generator_to_use) = Ninja ]]; then |
91 |
+ DESTDIR=${D} ninja install "$@" |
92 |
+ else |
93 |
+ base_src_install "$@" |
94 |
+ fi |
95 |
popd > /dev/null |
96 |
|
97 |
# Backward compatibility, for non-array variables |