Subject: [PATCH v2 02/65] build-system/cmake: Add generator fields.

From: Greg Hogan <[email-masked]>
Date: Tue, 22 Oct 2024 18:08:52 +0000

* guix/build-system/cmake.scm (cmake-build, cmake-cross-build):
Add generator field defaulted to the default CMake build system
generator.
* doc/guix.texi: Document generator parameter.

Change-Id: I82c8157ac865bc1ea435910421ceff36decc34ca
---
 doc/guix.texi               | 29 ++++++++++++++++++++---------
 guix/build-system/cmake.scm |  4 ++++
 2 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index ac3a7adef0..d7efec0aab 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -132,6 +132,7 @@
 Copyright @copyright{} 2024 Fabio Natali@*
 Copyright @copyright{} 2024 Arnaud Daby-Seesaram@*
 Copyright @copyright{} 2024 Nigko Yerden@*
+Copyright @copyright{} 2024 Greg Hogan@*
 
 Permission is granted to copy, distribute and/or modify this document
 under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -9443,16 +9444,26 @@ Build Systems
 implements the build procedure for packages using the
 @url{https://www.cmake.org, CMake build tool}.
 
-It automatically adds the @code{cmake} package to the set of inputs.
-Which package is used can be specified with the @code{#:cmake}
-parameter.
+This build system adds the following keyword parameters to the ones
+defined by @code{gnu-build-system}:
 
-The @code{#:configure-flags} parameter is taken as a list of flags
-passed to the @command{cmake} command.  The @code{#:build-type}
-parameter specifies in abstract terms the flags passed to the compiler;
-it defaults to @code{"RelWithDebInfo"} (short for ``release mode with
-debugging information''), which roughly means that code is compiled with
-@code{-O2 -g}, as is the case for Autoconf-based packages by default.
+@table @code
+@item #:cmake
+The @code{cmake} package is added to the set of inputs. Which package
+is used can be specified with the @code{#:cmake} parameter.
+
+@item #:build-type
+The @code{#:build-type} parameter specifies in abstract terms the flags
+passed to the compiler; it defaults to @code{"RelWithDebInfo"} (short
+for ``release mode with debugging information''), which roughly means
+that code is compiled with @code{-O2 -g}, as is the case for
+Autoconf-based packages by default.
+
+@item #:generator
+This parameter specifies the
+@url{https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html, CMake generator}
+responsible for writing the input files for the native build system.
+@end table
 @end defvar
 
 @defvar composer-build-system
diff --git a/guix/build-system/cmake.scm b/guix/build-system/cmake.scm
index 0b8a651ee0..af6d2e5c8a 100644
--- a/guix/build-system/cmake.scm
+++ b/guix/build-system/cmake.scm
@@ -101,6 +101,7 @@ (define* (cmake-build name inputs
                       (search-paths '())
                       (make-flags ''())
                       (out-of-source? #t)
+                      (generator "Unix Makefiles")
                       (build-type "RelWithDebInfo")
                       (tests? #t)
                       (test-target "test")
@@ -141,6 +142,7 @@ (define* (cmake-build name inputs
                                                      configure-flags)
                              #:make-flags #$make-flags
                              #:out-of-source? #$out-of-source?
+                             #:generator #$generator
                              #:build-type #$build-type
                              #:tests? #$tests?
                              #:test-target #$test-target
@@ -179,6 +181,7 @@ (define* (cmake-cross-build name
                             (native-search-paths '())
                             (make-flags ''())
                             (out-of-source? #t)
+                            (generator "Unix Makefiles")
                             (build-type "RelWithDebInfo")
                             (tests? #f) ; nothing can be done
                             (test-target "test")
@@ -234,6 +237,7 @@ (define* (cmake-cross-build name
                        #:configure-flags #$configure-flags
                        #:make-flags #$make-flags
                        #:out-of-source? #$out-of-source?
+                       #:generator #$generator
                        #:build-type #$build-type
                        #:tests? #$tests?
                        #:test-target #$test-target
-- 
2.46.1