Skip to contentSkip to conversation

pkg-cmake: add option to select the Ninja generator

Buildroot Yann E. MORIN 1 participant 1 message Sep 7, 2023

lore
Share & tools
lore
#0 lore raw

commit: https://git.buildroot.net/buildroot/commit/?id=4cf79d9b71ff5cf2aede3f21e09ade7c7ac59606
branch: https://git.buildroot.net/buildroot/commit/?id=refs/heads/master

Cmake supports multiple generators. For now, Buildroot only uses the venerable "GNU Makefile" generator, which generates Makefiles as the build backend.

Cmake also has support for Ninja as a build backend, and provides the corresponding generator. Ninja is a small build system with a focus on speed. It is mainly used with the meson build system, but also cmake has very good support for it.

Packages that are selecting Ninja (or over time another generator), should also use the _BUILD_{ENV,OPTS} variables instead of the _MAKE variables.

No _INSTALL{,_STAGING,_TARGET}_OPTS used so far, so reuse as cmake install opts:

    $ grep '_INSTALL_OPTS' $(git grep -l -E '\$\(eval \$\((host-)?cmake-package))')
    $ grep '_INSTALL_STAGING_OPTS' $(git grep -l -E '\$\(eval \$\((host-)?cmake-package))')
    $ grep '_INSTALL_TARGET_OPTS' $(git grep -l -E '\$\(eval \$\((host-)?cmake-package))')

The _MAKE_{ENV,OPTS} are copied to _BUILD_{ENV,OPTS}, involved packages:

    $ grep '_MAKE_ENV =' $(git grep -l -E '\$\(eval \$\((host-)?cmake-package))')

package/netopeer2/netopeer2.mk:NETOPEER2_MAKE_ENV = \
package/racehound/racehound.mk:RACEHOUND_MAKE_ENV = $(LINUX_MAKE_FLAGS)

(qt6, webkitgtk, and wpewebkit also match, but already use -Gninja)

$ grep '_MAKE_OPTS =' $(git grep -l -E '\$\(eval \$\((host-)?cmake-package))')

package/mariadb/mariadb.mk:HOST_MARIADB_MAKE_OPTS = import_executables package/zeek/zeek.mk:HOST_ZEEK_MAKE_OPTS = binpac bifcl

Only "musepack" seems to overwrite MAKE to enforce -j1, so replace it:

    $ grep '_MAKE =' $(git grep -l -E '\$\(eval \$\((host-)?cmake-package))')
    package/musepack/musepack.mk:MUSEPACK_MAKE = $(MAKE1)

[[email protected]:
- switch to FOO_CMAKE_BACKEND = (make|ninja)
- use firstword of $(MAKE), not $(BR2_MAKE)
- explain why we use firstword of $(MAKE)
- update manual with the three new variables
- yweak commit log
]

---
 docs/manual/adding-packages-cmake.txt |  8 +++++++
 package/musepack/musepack.mk          |  2 +-
 package/pkg-cmake.mk                  | 41 +++++++++++++++++++++++++----------
 3 files changed, 38 insertions(+), 13 deletions(-)
docs/manual/adding-packages-cmake.txt +8 -0
index 541d7422cf..4f336db737 100644
@@ -91,6 +91,10 @@ typical packages will therefore only use a few of them.
   the tree extracted by the tarball. If +HOST_LIBFOO_SUBDIR+ is not
   specified, it defaults to +LIBFOO_SUBDIR+.
 
+* +LIBFOO_CMAKE_BACKEND+ specifies the cmake backend to use, one of
+  `make` (to use the GNU Makefiles generator, the default) or `ninja`
+  (to use the Ninja generator).
+
 * +LIBFOO_CONF_ENV+, to specify additional environment variables to
   pass to CMake. By default, empty.
 
@@ -107,6 +111,10 @@ typical packages will therefore only use a few of them.
 ** +BUILD_EXAMPLE+, +BUILD_EXAMPLES+ are disabled;
 ** +BUILD_TEST+, +BUILD_TESTS+, +BUILD_TESTING+ are disabled.
 
+* +LIBFOO_BUILD_ENV+ and +LIBFOO_BUILD_OPTS+ to specify additional
+  environment variables, or command line options, to pass to the backend
+  at build time.
+
 * +LIBFOO_SUPPORTS_IN_SOURCE_BUILD = NO+ should be set when the package
   cannot be built inside the source tree but needs a separate build
   directory.
package/musepack/musepack.mk +1 -1
index fc66c684a5..d4dd08df36 100644
@@ -9,7 +9,7 @@ MUSEPACK_SITE = http://files.musepack.net/source
 MUSEPACK_SOURCE = musepack_src_$(MUSEPACK_VERSION).tar.gz
 MUSEPACK_DEPENDENCIES = libcuefile libreplaygain
 MUSEPACK_INSTALL_STAGING = YES
-MUSEPACK_MAKE = $(MAKE1)
+MUSEPACK_BUILD_OPTS = -j1
 MUSEPACK_LICENSE = BSD-3-Clause (*mpcdec), LGPL-2.1+ (*mpcenc)
 MUSEPACK_LICENSE_FILES = libmpcdec/COPYING libmpcenc/quant.c
 
package/pkg-cmake.mk +29 -12

94 lines not on this page · raw message

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot