all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#69554] [PATCH] build-system: cmake: Build tests depending on `#:tests?`.
@ 2024-03-04 21:48 Hartmut Goebel
  2024-03-04 22:58 ` [bug#69554] [PATCH v2] " Hartmut Goebel
  0 siblings, 1 reply; 4+ messages in thread
From: Hartmut Goebel @ 2024-03-04 21:48 UTC (permalink / raw)
  To: 69554

* guix/build/cmake-build-system.scm (configure): New paremeter `#:tests?`.
  Add cmake option "-DBUILD_TESTING=" with value "ON" or "OFF" depending
  on build-system argument `#:tests?`.
* * doc/guix.texi (Inspecting Services)[cmake-build-system]: Document it.
---
 doc/guix.texi                     | 10 ++++++++++
 guix/build/cmake-build-system.scm |  7 ++++++-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 87fe9f803c..409d076d12 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -9617,6 +9617,16 @@ 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.
+
+Depending on the @code{#:tests?} parameter, the configure-flag
+@code{BUILD_TESTING} is set to @code{ON} resp. @code{OFF}.
+@code{BUILD_TESTING} is a
+@url{https://cmake.org/cmake/help/v3.28/module/CTest.html, standard
+defined by CMake} to enable or disable building tests.  This aims to
+save build time if tests are not run anyway, while trying to ensure
+tests are build if they should be run.  Anyhow, the CMakeLists.txt needs
+to implement handling this flag.
+
 @end defvar
 
 @defvar composer-build-system
diff --git a/guix/build/cmake-build-system.scm b/guix/build/cmake-build-system.scm
index d1ff5071be..71e8ca8a83 100644
--- a/guix/build/cmake-build-system.scm
+++ b/guix/build/cmake-build-system.scm
@@ -33,7 +33,7 @@ (define-module (guix build cmake-build-system)
 ;; Code:
 
 (define* (configure #:key outputs (configure-flags '()) (out-of-source? #t)
-                    build-type target
+                    (tests? #t) build-type target
                     #:allow-other-keys)
   "Configure the given package."
   (let* ((out        (assoc-ref outputs "out"))
@@ -62,6 +62,11 @@ (define* (configure #:key outputs (configure-flags '()) (out-of-source? #t)
                   ,(string-append "-DCMAKE_INSTALL_RPATH=" out "/lib")
                   ;; enable verbose output from builds
                   "-DCMAKE_VERBOSE_MAKEFILE=ON"
+                  ;; ask for (not) building tests depending on #:tests?
+                  ;; (CMakeLists.txt may or may not implement this check)
+                  ,@(if tests?
+                        '("-DBUILD_TESTING=OFF") ; not run anyway
+                        '("-DBUILD_TESTING=ON")) ; overwrite any default option
 
                   ;;  Cross-build
                   ,@(if target

base-commit: 3da49b1472919a62df1fe399638f23a246aa325d
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [bug#69554] [PATCH v2] build-system: cmake: Build tests depending on `#:tests?`.
  2024-03-04 21:48 [bug#69554] [PATCH] build-system: cmake: Build tests depending on `#:tests?` Hartmut Goebel
@ 2024-03-04 22:58 ` Hartmut Goebel
  2024-07-15  9:40   ` Ludovic Courtès
  0 siblings, 1 reply; 4+ messages in thread
From: Hartmut Goebel @ 2024-03-04 22:58 UTC (permalink / raw)
  To: 69554

* guix/build/cmake-build-system.scm (configure): New paremeter `#:tests?`.
  Add cmake option "-DBUILD_TESTING=" with value "ON" or "OFF" depending
  on build-system argument `#:tests?`.
* * doc/guix.texi (Inspecting Services)[cmake-build-system]: Document it.
---
 doc/guix.texi                     | 10 ++++++++++
 guix/build/cmake-build-system.scm |  7 ++++++-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 87fe9f803c..409d076d12 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -9617,6 +9617,16 @@ 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.
+
+Depending on the @code{#:tests?} parameter, the configure-flag
+@code{BUILD_TESTING} is set to @code{ON} resp. @code{OFF}.
+@code{BUILD_TESTING} is a
+@url{https://cmake.org/cmake/help/v3.28/module/CTest.html, standard
+defined by CMake} to enable or disable building tests.  This aims to
+save build time if tests are not run anyway, while trying to ensure
+tests are build if they should be run.  Anyhow, the CMakeLists.txt needs
+to implement handling this flag.
+
 @end defvar
 
 @defvar composer-build-system
diff --git a/guix/build/cmake-build-system.scm b/guix/build/cmake-build-system.scm
index d1ff5071be..3f5449c438 100644
--- a/guix/build/cmake-build-system.scm
+++ b/guix/build/cmake-build-system.scm
@@ -33,7 +33,7 @@ (define-module (guix build cmake-build-system)
 ;; Code:
 
 (define* (configure #:key outputs (configure-flags '()) (out-of-source? #t)
-                    build-type target
+                    (tests? #t) build-type target
                     #:allow-other-keys)
   "Configure the given package."
   (let* ((out        (assoc-ref outputs "out"))
@@ -62,6 +62,11 @@ (define* (configure #:key outputs (configure-flags '()) (out-of-source? #t)
                   ,(string-append "-DCMAKE_INSTALL_RPATH=" out "/lib")
                   ;; enable verbose output from builds
                   "-DCMAKE_VERBOSE_MAKEFILE=ON"
+                  ;; ask for (not) building tests depending on #:tests?
+                  ;; (CMakeLists.txt may or may not implement this check)
+                  ,@(if tests?
+                        '("-DBUILD_TESTING=ON") ; overwrite any default option
+                        '("-DBUILD_TESTING=OFF")) ; not run anyway
 
                   ;;  Cross-build
                   ,@(if target

base-commit: 3da49b1472919a62df1fe399638f23a246aa325d
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [bug#69554] [PATCH v2] build-system: cmake: Build tests depending on `#:tests?`.
  2024-03-04 22:58 ` [bug#69554] [PATCH v2] " Hartmut Goebel
@ 2024-07-15  9:40   ` Ludovic Courtès
  2024-07-16 15:36     ` Hartmut Goebel
  0 siblings, 1 reply; 4+ messages in thread
From: Ludovic Courtès @ 2024-07-15  9:40 UTC (permalink / raw)
  To: Hartmut Goebel; +Cc: 69554

Hi Hartmut,

Hartmut Goebel <h.goebel@crazy-compilers.com> skribis:

> * guix/build/cmake-build-system.scm (configure): New paremeter `#:tests?`.
>   Add cmake option "-DBUILD_TESTING=" with value "ON" or "OFF" depending
>   on build-system argument `#:tests?`.
> * * doc/guix.texi (Inspecting Services)[cmake-build-system]: Document it.
> ---
>  doc/guix.texi                     | 10 ++++++++++
>  guix/build/cmake-build-system.scm |  7 ++++++-
>  2 files changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/doc/guix.texi b/doc/guix.texi
> index 87fe9f803c..409d076d12 100644
> --- a/doc/guix.texi
> +++ b/doc/guix.texi
> @@ -9617,6 +9617,16 @@ 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.
> +
> +Depending on the @code{#:tests?} parameter, the configure-flag
> +@code{BUILD_TESTING} is set to @code{ON} resp. @code{OFF}.
> +@code{BUILD_TESTING} is a
> +@url{https://cmake.org/cmake/help/v3.28/module/CTest.html, standard
> +defined by CMake} to enable or disable building tests.  This aims to
> +save build time if tests are not run anyway, while trying to ensure
> +tests are build if they should be run.  Anyhow, the CMakeLists.txt needs
> +to implement handling this flag.

My understanding is that ‘BUILD_TESTING’ is not standard, as the last
sentence above suggests.  Thus I’m reluctant to passing this flag
unconditionally, as I guess it would fail for ‘CMakeLists.txt’ that do
not implement it, right?

Thanks,
Ludo’.




^ permalink raw reply	[flat|nested] 4+ messages in thread

* [bug#69554] [PATCH v2] build-system: cmake: Build tests depending on `#:tests?`.
  2024-07-15  9:40   ` Ludovic Courtès
@ 2024-07-16 15:36     ` Hartmut Goebel
  0 siblings, 0 replies; 4+ messages in thread
From: Hartmut Goebel @ 2024-07-16 15:36 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 69554

[-- Attachment #1: Type: text/plain, Size: 801 bytes --]

Am 15.07.24 um 11:40 schrieb Ludovic Courtès:
> My understanding is that ‘BUILD_TESTING’ is not standard, as the last
> sentence above suggests.  Thus I’m reluctant to passing this flag
> unconditionally, as I guess it would fail for ‘CMakeLists.txt’ that do
> not implement it, right?

I just tested it, and all you get is a warning:

$ cat CMakeLists.txt
cmake_minimum_required(VERSION 3.0)
project(doo)
$ cmake -DBUILD_TESTING=OFF .
…
-- Generating done (0.0s)
CMake Warning:
  Manually-specified variables were not used by the project:

    BUILD_TESTING


-- Build files have been written to: /tmp/xxx


-- 

Regards
Hartmut Goebel

| Hartmut Goebel          |h.goebel@crazy-compilers.com                |
|www.crazy-compilers.com  | compilers which you thought are impossible |

[-- Attachment #2: Type: text/html, Size: 2262 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-07-16 15:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-04 21:48 [bug#69554] [PATCH] build-system: cmake: Build tests depending on `#:tests?` Hartmut Goebel
2024-03-04 22:58 ` [bug#69554] [PATCH v2] " Hartmut Goebel
2024-07-15  9:40   ` Ludovic Courtès
2024-07-16 15:36     ` Hartmut Goebel

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.