summaryrefslogtreecommitdiff
path: root/guix/build/cmake-build-system.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2013-11-27 23:50:37 +0100
committerLudovic Courtès <ludo@gnu.org>2013-11-28 00:15:07 +0100
commit977f03ffd31a3b754c26be7bed0f5ef7e063b843 (patch)
treeaa7fd75088e336d8624a0c3fc9e5514997f35c3c /guix/build/cmake-build-system.scm
parentb4f0bb1771b192a559ee95560bfe553034c7e233 (diff)
downloadgnu-guix-977f03ffd31a3b754c26be7bed0f5ef7e063b843.tar
gnu-guix-977f03ffd31a3b754c26be7bed0f5ef7e063b843.tar.gz
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.
Diffstat (limited to 'guix/build/cmake-build-system.scm')
-rw-r--r--guix/build/cmake-build-system.scm30
1 files changed, 20 insertions, 10 deletions
diff --git a/guix/build/cmake-build-system.scm b/guix/build/cmake-build-system.scm
index 449c609398..75998568bc 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)