[OE-core] [PATCH v2] cmake: Support Eclipse and other cmake generators

Douglas Royds douglas.royds at taitradio.com
Mon Apr 8 21:24:36 UTC 2019


From: Nikhil Pal Singh <nikhilpal.singh at taitradio.com>

Support project-file generators such as CodeBlocks, CodeLite,
Eclipse, Sublime, and Kate for both make and Ninja build systems.

The following generators are listed in cmake --help:

  Unix Makefiles               = Generates standard UNIX makefiles.
  Ninja                        = Generates build.ninja files.
  Watcom WMake                 = Generates Watcom WMake makefiles.
  CodeBlocks - Ninja           = Generates CodeBlocks project files.
  CodeBlocks - Unix Makefiles  = Generates CodeBlocks project files.
  CodeLite - Ninja             = Generates CodeLite project files.
  CodeLite - Unix Makefiles    = Generates CodeLite project files.
  Sublime Text 2 - Ninja       = Generates Sublime Text 2 project files.
  Sublime Text 2 - Unix Makefiles
                               = Generates Sublime Text 2 project files.
  Kate - Ninja                 = Generates Kate project files.
  Kate - Unix Makefiles        = Generates Kate project files.
  Eclipse CDT4 - Ninja         = Generates Eclipse CDT 4.0 project files.
  Eclipse CDT4 - Unix Makefiles= Generates Eclipse CDT 4.0 project files.

All but one of these contain one of the strings, "Unix Makefiles" or "Ninja".
In each of these cases, cmake generates the Makefiles (or ninja files respectively),
and also the appropriate project files, eg. .project and .cproject for Eclipse.

A user can set OECMAKE_GENERATOR in their local.conf to any
one of these strings, except "Watcom WMake" (not supported).

Signed-off-by: Nikhil Pal Singh <nikhilpal.singh at taitradio.com>
---
 meta/classes/cmake.bbclass | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/meta/classes/cmake.bbclass b/meta/classes/cmake.bbclass
index e16630434e..d3f0d70847 100644
--- a/meta/classes/cmake.bbclass
+++ b/meta/classes/cmake.bbclass
@@ -10,13 +10,14 @@ OECMAKE_GENERATOR ?= "Ninja"
 
 python() {
     generator = d.getVar("OECMAKE_GENERATOR")
-    if generator == "Unix Makefiles":
-        args = "-G 'Unix Makefiles' -DCMAKE_MAKE_PROGRAM=" + d.getVar("MAKE")
+    if "Unix Makefiles" in generator:
+        args = "-G '" + generator +  "' -DCMAKE_MAKE_PROGRAM=" + d.getVar("MAKE")
         d.setVar("OECMAKE_GENERATOR_ARGS", args)
         d.setVarFlag("do_compile", "progress", "percent")
-    elif generator == "Ninja":
+    elif "Ninja" in generator:
+        args = "-G '" + generator + "' -DCMAKE_MAKE_PROGRAM=ninja"
         d.appendVar("DEPENDS", " ninja-native")
-        d.setVar("OECMAKE_GENERATOR_ARGS", "-G Ninja -DCMAKE_MAKE_PROGRAM=ninja")
+        d.setVar("OECMAKE_GENERATOR_ARGS", args)
         d.setVarFlag("do_compile", "progress", r"outof:^\[(\d+)/(\d+)\]\s+")
     else:
         bb.fatal("Unknown CMake Generator %s" % generator)
-- 
2.17.1



More information about the Openembedded-core mailing list