summaryrefslogtreecommitdiffstats
path: root/meta/classes/cmake.bbclass
diff options
context:
space:
mode:
authorRoss Burton <ross.burton@intel.com>2018-01-05 16:39:28 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-01-19 12:37:14 +0000
commit59879f31e174366f6899acd9876355ca62e63a4a (patch)
treecbd40147aaf20537d040e59cde336bbeff5bd9cb /meta/classes/cmake.bbclass
parent9ce6fa9a8f7fc3e6e840e835e2eccff6a31096d6 (diff)
downloadpoky-59879f31e174366f6899acd9876355ca62e63a4a.tar.gz
cmake: allow the generator to be changed
Add OECMAKE_GENERATOR variable to control which generator is used by CMake, defaulting to the upstream default of Unix Makefiles for now. The other supported option is Ninja, which is faster than Make for large projects (for example, using Ninja takes three minutes off webkitgtk:do_compile for me). (From OE-Core rev: 6e3f719076cab469f56cd1555bd219a5c3fd135d) Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/cmake.bbclass')
-rw-r--r--meta/classes/cmake.bbclass20
1 files changed, 18 insertions, 2 deletions
diff --git a/meta/classes/cmake.bbclass b/meta/classes/cmake.bbclass
index 55698e60e5..74a952142f 100644
--- a/meta/classes/cmake.bbclass
+++ b/meta/classes/cmake.bbclass
@@ -7,6 +7,23 @@ B = "${WORKDIR}/build"
7# We need to unset CCACHE otherwise cmake gets too confused 7# We need to unset CCACHE otherwise cmake gets too confused
8CCACHE = "" 8CCACHE = ""
9 9
10# What CMake generator to use.
11# The supported options are "Unix Makefiles" or "Ninja".
12OECMAKE_GENERATOR ?= "Unix Makefiles"
13
14python() {
15 generator = d.getVar("OECMAKE_GENERATOR")
16 if generator == "Unix Makefiles":
17 args = "-G 'Unix Makefiles' -DCMAKE_MAKE_PROGRAM=" + d.getVar("MAKE")
18 d.setVar("OECMAKE_GENERATOR_ARGS", args)
19 d.setVarFlag("do_compile", "progress", "percent")
20 elif generator == "Ninja":
21 d.appendVar("DEPENDS", " ninja-native")
22 d.setVar("OECMAKE_GENERATOR_ARGS", "-G Ninja -DCMAKE_MAKE_PROGRAM=ninja")
23 d.setVarFlag("do_compile", "progress", "outof:^\[(\d+)/(\d+)\]\s+")
24 else:
25 bb.fatal("Unknown CMake Generator %s" % generator)
26}
10# C/C++ Compiler (without cpu arch/tune arguments) 27# C/C++ Compiler (without cpu arch/tune arguments)
11OECMAKE_C_COMPILER ?= "`echo ${CC} | sed 's/^\([^ ]*\).*/\1/'`" 28OECMAKE_C_COMPILER ?= "`echo ${CC} | sed 's/^\([^ ]*\).*/\1/'`"
12OECMAKE_CXX_COMPILER ?= "`echo ${CXX} | sed 's/^\([^ ]*\).*/\1/'`" 29OECMAKE_CXX_COMPILER ?= "`echo ${CXX} | sed 's/^\([^ ]*\).*/\1/'`"
@@ -121,9 +138,9 @@ cmake_do_configure() {
121 fi 138 fi
122 139
123 cmake \ 140 cmake \
141 ${OECMAKE_GENERATOR_ARGS} \
124 $oecmake_sitefile \ 142 $oecmake_sitefile \
125 ${OECMAKE_SOURCEPATH} \ 143 ${OECMAKE_SOURCEPATH} \
126 -DCMAKE_MAKE_PROGRAM=${MAKE} \
127 -DCMAKE_INSTALL_PREFIX:PATH=${prefix} \ 144 -DCMAKE_INSTALL_PREFIX:PATH=${prefix} \
128 -DCMAKE_INSTALL_BINDIR:PATH=${@os.path.relpath(d.getVar('bindir'), d.getVar('prefix'))} \ 145 -DCMAKE_INSTALL_BINDIR:PATH=${@os.path.relpath(d.getVar('bindir'), d.getVar('prefix'))} \
129 -DCMAKE_INSTALL_SBINDIR:PATH=${@os.path.relpath(d.getVar('sbindir'), d.getVar('prefix'))} \ 146 -DCMAKE_INSTALL_SBINDIR:PATH=${@os.path.relpath(d.getVar('sbindir'), d.getVar('prefix'))} \
@@ -142,7 +159,6 @@ cmake_do_configure() {
142 -Wno-dev 159 -Wno-dev
143} 160}
144 161
145do_compile[progress] = "percent"
146cmake_do_compile() { 162cmake_do_compile() {
147 bbnote VERBOSE=1 cmake --build '${B}' --target ${OECMAKE_TARGET_COMPILE} -- ${EXTRA_OECMAKE_BUILD} 163 bbnote VERBOSE=1 cmake --build '${B}' --target ${OECMAKE_TARGET_COMPILE} -- ${EXTRA_OECMAKE_BUILD}
148 VERBOSE=1 cmake --build '${B}' --target ${OECMAKE_TARGET_COMPILE} -- ${EXTRA_OECMAKE_BUILD} 164 VERBOSE=1 cmake --build '${B}' --target ${OECMAKE_TARGET_COMPILE} -- ${EXTRA_OECMAKE_BUILD}