From 977f03ffd31a3b754c26be7bed0f5ef7e063b843 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Wed, 27 Nov 2013 23:50:37 +0100 Subject: [PATCH] build-system/cmake: Build out of source tree by default. * guix/build-system/cmake.scm (cmake-build): Change 'out-of-source?' to default to #t. * guix/build/cmake-build-system.scm (configure): Add 'out-of-source?' keyword parameter and honor it. --- guix/build-system/cmake.scm | 2 +- guix/build/cmake-build-system.scm | 30 ++++++++++++++++++++---------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/guix/build-system/cmake.scm b/guix/build-system/cmake.scm index e09f165b97fda6df19491dd5908e6805a3bced48..1a5f4b6ad1d02a8996556eab1e6d50a7877b3246 100644 --- a/guix/build-system/cmake.scm +++ b/guix/build-system/cmake.scm @@ -48,7 +48,7 @@ (search-paths '()) (make-flags ''()) (cmake (default-cmake)) - (out-of-source? #f) + (out-of-source? #t) (tests? #t) (test-target "test") (parallel-build? #t) (parallel-tests? #f) diff --git a/guix/build/cmake-build-system.scm b/guix/build/cmake-build-system.scm index 449c6093980e152371d90839d791df41ede3d064..75998568bc4e36f7cb7a0fa61b85283e8b4e8fd0 100644 --- a/guix/build/cmake-build-system.scm +++ b/guix/build/cmake-build-system.scm @@ -31,18 +31,28 @@ ;; ;; Code: -(define* (configure #:key outputs (configure-flags '()) +(define* (configure #:key outputs (configure-flags '()) (out-of-source? #t) #:allow-other-keys) "Configure the given package." - (let ((out (assoc-ref outputs "out"))) - (if (file-exists? "CMakeLists.txt") - (let ((args `(,(string-append "-DCMAKE_INSTALL_PREFIX=" out) - ,@configure-flags))) - (setenv "CMAKE_LIBRARY_PATH" (getenv "LIBRARY_PATH")) - (setenv "CMAKE_INCLUDE_PATH" (getenv "CPATH")) - (format #t "running 'cmake' with arguments ~s~%" args) - (zero? (apply system* "cmake" args))) - (error "no CMakeLists.txt found")))) + (let* ((out (assoc-ref outputs "out")) + (abs-srcdir (getcwd)) + (srcdir (if out-of-source? + (string-append "../" (basename abs-srcdir)) + "."))) + (format #t "source directory: ~s (relative from build: ~s)~%" + abs-srcdir srcdir) + (when out-of-source? + (mkdir "../build") + (chdir "../build")) + (format #t "build directory: ~s~%" (getcwd)) + + (let ((args `(,srcdir + ,(string-append "-DCMAKE_INSTALL_PREFIX=" out) + ,@configure-flags))) + (setenv "CMAKE_LIBRARY_PATH" (getenv "LIBRARY_PATH")) + (setenv "CMAKE_INCLUDE_PATH" (getenv "CPATH")) + (format #t "running 'cmake' with arguments ~s~%" args) + (zero? (apply system* "cmake" args))))) (define* (check #:key (tests? #t) (parallel-tests? #t) (test-target "test") #:allow-other-keys)