all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dariqq <dariqq@posteo.net>
To: 72751@debbugs.gnu.org
Cc: Dariqq <dariqq@posteo.net>
Subject: [bug#72751] [PATCH 1/2] guix: build-system: cmake: Rework cross compilation.
Date: Wed, 21 Aug 2024 18:34:50 +0000	[thread overview]
Message-ID: <a961b691eaea3d4c7b530ccf6c1bcf9586dd57aa.1724262137.git.dariqq@posteo.net> (raw)
In-Reply-To: <cover.1724262137.git.dariqq@posteo.net>

Move the extra configure flags for cross building out from the build side code and instead
prepend them to the configure-flags.

Use new procedure cmake-system-name-for-target to add support for hurd and
bare-metal targets.

* guix/build/cmake-build-system.scm (configure): Move cross build flags from
here ...
* guix/build-system/cmake.scm (cmake-cross-build): ... to here.
(cmake-system-name-for-target): New procedure.

Change-Id: Ic68acc246e543491ed147e53d47cec5de46b82cb
---
 guix/build-system/cmake.scm       | 19 ++++++++++++++++++-
 guix/build/cmake-build-system.scm | 11 -----------
 2 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/guix/build-system/cmake.scm b/guix/build-system/cmake.scm
index aa187c9844..fd32548342 100644
--- a/guix/build-system/cmake.scm
+++ b/guix/build-system/cmake.scm
@@ -39,6 +39,15 @@ (define-module (guix build-system cmake)
 ;;
 ;; Code:
 
+(define* (cmake-system-name-for-target
+          #:optional (target (or (%current-target-system)
+                                 (%current-system))))
+  (cond ((target-hurd? target)  "GNU")
+        ((target-linux? target) "Linux")
+        ((target-mingw? target) "Windows")
+        ;; For avr, or1k-elf, xtensa-ath9k-elf
+        (else "Generic")))
+
 (define %cmake-build-system-modules
   ;; Build-side modules imported by default.
   `((guix build cmake-build-system)
@@ -228,7 +237,15 @@ (define* (cmake-cross-build name
                                                  search-path-specification->sexp
                                                  native-search-paths)
                        #:phases #$phases
-                       #:configure-flags #$configure-flags
+                       #:configure-flags `(#$(string-append "-DCMAKE_C_COMPILER="
+                                                            (cc-for-target target))
+                                           #$(string-append "-DCMAKE_CXX_COMPILER="
+                                                            (cxx-for-target target))
+                                           #$(string-append "-DCMAKE_SYSTEM_NAME="
+                                                            (cmake-system-name-for-target target))
+                                           ,@#$(if (pair? configure-flags)
+                                                   (sexp->gexp configure-flags)
+                                                   configure-flags))
                        #:make-flags #$make-flags
                        #:out-of-source? #$out-of-source?
                        #:build-type #$build-type
diff --git a/guix/build/cmake-build-system.scm b/guix/build/cmake-build-system.scm
index d1ff5071be..61033061c6 100644
--- a/guix/build/cmake-build-system.scm
+++ b/guix/build/cmake-build-system.scm
@@ -62,17 +62,6 @@ (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"
-
-                  ;;  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))))
-- 
2.45.2





  reply	other threads:[~2024-08-21 18:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-21 18:05 [bug#72751] [PATCH 0/2] Rework cmake cross compiling Dariqq
2024-08-21 18:34 ` Dariqq [this message]
2024-08-21 18:34 ` [bug#72751] [PATCH 2/2] gnu: ath9k-firmware: Remove CMAKE_SYSTEM_NAME override Dariqq

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a961b691eaea3d4c7b530ccf6c1bcf9586dd57aa.1724262137.git.dariqq@posteo.net \
    --to=dariqq@posteo.net \
    --cc=72751@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.