[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#70031] [PATCH v2 10/65] build-system/cmake: Optionally build tests.
From: |
Greg Hogan |
Subject: |
[bug#70031] [PATCH v2 10/65] build-system/cmake: Optionally build tests. |
Date: |
Tue, 22 Oct 2024 18:09:00 +0000 |
* guix/build/cmake-build-system.scm (configure): Create and use CMake
variable cache file. Set the CMake variable BUILD_TESTING to the value
of TESTS? so that a package can optionally build tests. Set
CMAKE_COLOR_DIAGNOSTICS to ON.
Change-Id: Ia69de938a56733f717d4b4c6207b499bcee524ff
---
guix/build/cmake-build-system.scm | 75 ++++++++++++++++++-------------
1 file changed, 44 insertions(+), 31 deletions(-)
diff --git a/guix/build/cmake-build-system.scm
b/guix/build/cmake-build-system.scm
index b90a0c14a9..0933801ecb 100644
--- a/guix/build/cmake-build-system.scm
+++ b/guix/build/cmake-build-system.scm
@@ -35,7 +35,7 @@ (define-module (guix build cmake-build-system)
;; Code:
(define* (configure #:key outputs (configure-flags '()) (out-of-source? #t)
- build-type target generator
+ build-type target generator (tests? #t)
#:allow-other-keys)
"Configure the given package."
(let* ((out (assoc-ref outputs "out"))
@@ -50,37 +50,50 @@ (define* (configure #:key outputs (configure-flags '())
(out-of-source? #t)
(chdir "../build"))
(format #t "build directory: ~s~%" (getcwd))
- (let ((args `(,srcdir
- ,@(if generator
- (list (string-append "-G" generator))
- '())
- ,@(if build-type
- (list (string-append "-DCMAKE_BUILD_TYPE="
- build-type))
- '())
- ,(string-append "-DCMAKE_INSTALL_PREFIX=" out)
- ;; ensure that the libraries are installed into /lib
- "-DCMAKE_INSTALL_LIBDIR=lib"
- ;; add input libraries to rpath
- "-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE"
- ;; add (other) libraries of the project itself to rpath
- ,(string-append "-DCMAKE_INSTALL_RPATH=" out "/lib")
- ;; enable verbose output from builds
- "-DCMAKE_VERBOSE_MAKEFILE=ON"
+ (call-with-temporary-output-file
+ (lambda (temp port)
+ (let ((args `(,srcdir
+ ;; Load variables into the the cache to prevent
+ ;; warnings about unused manually-specified variables.
+ ,(string-append "-C " temp)
+ ,@(if generator
+ (list (string-append "-G" generator))
+ '())
+ ,@configure-flags)))
- ;; Cross-build
- ,@(if target
- (list (string-append "-DCMAKE_C_COMPILER="
- target "-gcc")
- (string-append "-DCMAKE_CXX_COMPILER="
- target "-g++")
- (if (string-contains target "mingw")
- "-DCMAKE_SYSTEM_NAME=Windows"
- "-DCMAKE_SYSTEM_NAME=Linux"))
- '())
- ,@configure-flags)))
- (format #t "running 'cmake' with arguments ~s~%" args)
- (apply invoke "cmake" args))))
+ (define save-to-cache
+ (lambda* (name value)
+ ;; <type> and <docstring> arguments are used only by CMake GUIs.
+ (format port "set(~a \"~a\" CACHE STRING \"\")~%" name value)))
+
+ (if build-type
+ (save-to-cache "CMAKE_BUILD_TYPE" build-type))
+ (save-to-cache "CMAKE_INSTALL_PREFIX" out)
+ ;; Ensure that the libraries are installed into /lib.
+ (save-to-cache "CMAKE_INSTALL_LIBDIR" "lib")
+ ;; Add input libraries to rpath.
+ (save-to-cache "CMAKE_INSTALL_RPATH_USE_LINK_PATH" "TRUE")
+ ;; Add (other) libraries of the project itself to rpath.
+ (save-to-cache "CMAKE_INSTALL_RPATH" (string-append out "/lib"))
+ ;; Enable verbose output from builds.
+ (save-to-cache "CMAKE_VERBOSE_MAKEFILE" "ON")
+ ;; Enable colored compiler diagnostics.
+ (save-to-cache "CMAKE_COLOR_DIAGNOSTICS" "ON")
+ ;; BUILD_TESTING in an option of CMake's CTest module.
+ (save-to-cache "BUILD_TESTING" (if tests? "ON" "OFF"))
+
+ ;; Cross-build
+ (if target
+ (begin
+ (save-to-cache "CMAKE_C_COMPILER" (string-append target
"-gcc"))
+ (save-to-cache "CMAKE_CXX_COMPILER" (string-append target
"-g++"))
+ (if (string-contains target "mingw")
+ (save-to-cache "CMAKE_SYSTEM_NAME" "Windows")
+ (save-to-cache "CMAKE_SYSTEM_NAME" "Linux"))))
+
+ (close-port port)
+ (format #t "running 'cmake' with arguments ~s~%" args)
+ (apply invoke "cmake" args))))))
(define* (build #:key (parallel-build? #t) #:allow-other-keys)
(apply invoke "cmake"
--
2.46.1
- [bug#70031] [PATCH v2 12/65] build-system/qt: Include ninja., (continued)
- [bug#70031] [PATCH v2 12/65] build-system/qt: Include ninja., Greg Hogan, 2024/10/22
- [bug#70031] [PATCH v2 14/65] gnu: rdma-core: Remove custom phases., Greg Hogan, 2024/10/22
- [bug#70031] [PATCH v2 16/65] gnu: igraph: Fix tests., Greg Hogan, 2024/10/22
- [bug#70031] [PATCH v2 19/65] gnu: kirigami: Fix tests., Greg Hogan, 2024/10/22
- [bug#70031] [PATCH v2 13/65] gnu: astroid: Remove custom phases., Greg Hogan, 2024/10/22
- [bug#70031] [PATCH v2 18/65] gnu: inkscape/stable: Fix tests., Greg Hogan, 2024/10/22
- [bug#70031] [PATCH v2 22/65] gnu: cpp-httplib: Disable parallel tests., Greg Hogan, 2024/10/22
- [bug#70031] [PATCH v2 23/65] gnu: evolution-data-server: Disable parallel tests., Greg Hogan, 2024/10/22
- [bug#70031] [PATCH v2 24/65] gnu: kservice: Disable parallel tests., Greg Hogan, 2024/10/22
- [bug#70031] [PATCH v2 30/65] gnu: vulkan-loader: Disable parallel tests., Greg Hogan, 2024/10/22
- [bug#70031] [PATCH v2 10/65] build-system/cmake: Optionally build tests.,
Greg Hogan <=
- [bug#70031] [PATCH v2 15/65] gnu: fish: Fix tests., Greg Hogan, 2024/10/22
- [bug#70031] [PATCH v2 35/65] gnu: nextcloud-client: Use #:test-exclude., Greg Hogan, 2024/10/22
- [bug#70031] [PATCH v2 37/65] gnu: qxmpp: Use #:test-exclude., Greg Hogan, 2024/10/22
- [bug#70031] [PATCH v2 42/65] gnu: entangle: Pin CMake dependency., Greg Hogan, 2024/10/22
- [bug#70031] [PATCH v2 38/65] gnu: simgear: Use #:test-exclude., Greg Hogan, 2024/10/22
- [bug#70031] [PATCH v2 43/65] gnu: go-mvdan-cc-editorconfig: Pin CMake dependency., Greg Hogan, 2024/10/22
- [bug#70031] [PATCH v2 46/65] gnu: lxi-tools: Pin CMake dependency., Greg Hogan, 2024/10/22
- [bug#70031] [PATCH v2 17/65] gnu: inkscape: Fix tests., Greg Hogan, 2024/10/22
- [bug#70031] [PATCH v2 20/65] gnu: kirigami-5: Disable tests., Greg Hogan, 2024/10/22
- [bug#70031] [PATCH v2 21/65] gnu: vigra: Fix tests., Greg Hogan, 2024/10/22