From patchwork Mon Mar 4 22:58:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hartmut Goebel X-Patchwork-Id: 61342 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id B077327BBE9; Mon, 4 Mar 2024 22:59:50 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id B4A6627BBE2 for ; Mon, 4 Mar 2024 22:59:48 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhHHU-0002e6-96; Mon, 04 Mar 2024 17:59:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhHHR-0002dA-MT for guix-patches@gnu.org; Mon, 04 Mar 2024 17:59:33 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhHHR-00032I-Em for guix-patches@gnu.org; Mon, 04 Mar 2024 17:59:33 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rhHHv-0007yc-8e for guix-patches@gnu.org; Mon, 04 Mar 2024 18:00:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#69554] [PATCH v2] build-system: cmake: Build tests depending on `#:tests?`. References: In-Reply-To: Resent-From: Hartmut Goebel Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 04 Mar 2024 23:00:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69554 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 69554@debbugs.gnu.org Received: via spool by 69554-submit@debbugs.gnu.org id=B69554.170959315330465 (code B ref 69554); Mon, 04 Mar 2024 23:00:03 +0000 Received: (at 69554) by debbugs.gnu.org; 4 Mar 2024 22:59:13 +0000 Received: from localhost ([127.0.0.1]:45223 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rhHH6-0007vJ-FK for submit@debbugs.gnu.org; Mon, 04 Mar 2024 17:59:12 -0500 Received: from mail02.noris.net ([62.128.1.232]:44451) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rhHH1-0007ut-2s for 69554@debbugs.gnu.org; Mon, 04 Mar 2024 17:59:11 -0500 Received: from p57b08d98.dip0.t-ipconnect.de ([87.176.141.152] helo=hermia.goebel-consult.de) by mail02.noris.net with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) (envelope-from ) id 1rhHGV-0006lq-UA for 69554@debbugs.gnu.org; Mon, 04 Mar 2024 23:58:35 +0100 Received: from thisbe.goebel-consult.de (hermia.goebel-consult.de [192.168.110.7]) by hermia.goebel-consult.de (Postfix) with ESMTP id C52AC5F4DE; Mon, 4 Mar 2024 23:58:32 +0100 (CET) From: Hartmut Goebel Date: Mon, 4 Mar 2024 23:58:32 +0100 Message-ID: <7676fd973fa640750306df216feb95c335b345de.1709593063.git.h.goebel@crazy-compilers.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-Noris-IP: 87.176.141.152 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * 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(-) base-commit: 3da49b1472919a62df1fe399638f23a246aa325d 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