summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDariqq <dariqq@posteo.net>2024-08-21 18:34:50 +0000
committerLudovic Courtès <ludo@gnu.org>2025-01-14 14:11:42 +0100
commitad672d80d72b8ee2dc9e0982d9854bf6f88fb751 (patch)
tree66606d76010ade32895b766c095ae3f192e0c431
parentf5fa65b3e99e02dcc371e9989c8b54fecc6c06c0 (diff)
build-system: cmake: Rework cross compilation.
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 Signed-off-by: Ludovic Courtès <ludo@gnu.org>
-rw-r--r--guix/build-system/cmake.scm19
-rw-r--r--guix/build/cmake-build-system.scm11
2 files changed, 18 insertions, 12 deletions
diff --git a/guix/build-system/cmake.scm b/guix/build-system/cmake.scm
index 0b8a651ee0e..9d757c0d061 100644
--- a/guix/build-system/cmake.scm
+++ b/guix/build-system/cmake.scm
@@ -39,6 +39,15 @@
;;
;; 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)
@@ -231,7 +240,15 @@ build system."
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 d1ff5071be5..61033061c6c 100644
--- a/guix/build/cmake-build-system.scm
+++ b/guix/build/cmake-build-system.scm
@@ -62,17 +62,6 @@
,(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))))