gnu: Add 'version-prefix' and 'version-major+minor'; use them.
[jackhill/guix/guix.git] / gnu / packages / cmake.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013 Cyril Roelandt <tipecaml@gmail.com>
3 ;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
4 ;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org>
5 ;;; Copyright © 2014 Ian Denhardt <ian@zenhack.net>
6 ;;;
7 ;;; This file is part of GNU Guix.
8 ;;;
9 ;;; GNU Guix is free software; you can redistribute it and/or modify it
10 ;;; under the terms of the GNU General Public License as published by
11 ;;; the Free Software Foundation; either version 3 of the License, or (at
12 ;;; your option) any later version.
13 ;;;
14 ;;; GNU Guix is distributed in the hope that it will be useful, but
15 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;;; GNU General Public License for more details.
18 ;;;
19 ;;; You should have received a copy of the GNU General Public License
20 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
21
22 (define-module (gnu packages cmake)
23 #:use-module ((guix licenses) #:select (bsd-3))
24 #:use-module (guix packages)
25 #:use-module (guix download)
26 #:use-module (guix utils)
27 #:use-module (guix build-system gnu)
28 #:use-module (gnu packages)
29 #:use-module (gnu packages backup)
30 #:use-module (gnu packages compression)
31 #:use-module (gnu packages curl)
32 #:use-module (gnu packages file)
33 #:use-module (gnu packages xml))
34
35 (define-public cmake
36 (package
37 (name "cmake")
38 (version "2.8.12")
39 (source (origin
40 (method url-fetch)
41 (uri (string-append
42 "http://www.cmake.org/files/v"
43 (version-major+minor version)
44 "/cmake-" version ".tar.gz"))
45 (sha256
46 (base32 "11q21vyrr6c6smyjy81k2k07zmn96ggjia9im9cxwvj0n88bm1fq"))
47 (patches (list (search-patch "cmake-fix-tests.patch")))))
48 (build-system gnu-build-system)
49 (arguments
50 `(#:test-target "test"
51 #:phases (alist-cons-before
52 'configure 'patch-bin-sh
53 (lambda _
54 ;; Replace "/bin/sh" by the right path in... a lot of
55 ;; files.
56 (substitute*
57 '("Modules/CompilerId/Xcode-3.pbxproj.in"
58 "Modules/CompilerId/Xcode-1.pbxproj.in"
59 "Modules/CompilerId/Xcode-2.pbxproj.in"
60 "Modules/CPack.RuntimeScript.in"
61 "Source/cmakexbuild.cxx"
62 "Source/cmGlobalXCodeGenerator.cxx"
63 "Source/CTest/cmCTestBatchTestHandler.cxx"
64 "Source/cmLocalUnixMakefileGenerator3.cxx"
65 "Utilities/cmbzip2/Makefile-libbz2_so"
66 "Utilities/Release/release_cmake.cmake"
67 "Utilities/cmlibarchive/libarchive/archive_write_set_format_shar.c"
68 "Tests/CMakeLists.txt")
69 (("/bin/sh") (which "sh"))))
70 (alist-cons-before
71 'configure 'set-paths
72 (lambda _
73 ;; Help cmake's bootstrap process to find system libraries
74 (begin
75 (setenv "CMAKE_LIBRARY_PATH" (getenv "LIBRARY_PATH"))
76 (setenv "CMAKE_INCLUDE_PATH" (getenv "CPATH"))))
77 (alist-replace
78 'configure
79 (lambda* (#:key outputs #:allow-other-keys)
80 (let ((out (assoc-ref outputs "out")))
81 (zero? (system*
82 "./configure"
83 (string-append "--prefix=" out)
84 "--system-libs"
85 ;; By default, the man pages and other docs land
86 ;; in PREFIX/man and PREFIX/doc, but we want them
87 ;; in share/{man,doc}. Note that unlike
88 ;; autoconf-generated configure scripts, cmake's
89 ;; configure prepends "PREFIX/" to what we pass
90 ;; to --mandir and --docdir.
91 "--mandir=share/man"
92 ,(string-append
93 "--docdir=share/doc/cmake-"
94 (version-major+minor version))))))
95 %standard-phases)))))
96 (inputs
97 `(("file" ,file)
98 ("curl" ,curl)
99 ("zlib" ,zlib)
100 ("expat" ,expat)
101 ("bzip2" ,bzip2)
102 ("libarchive" ,libarchive)))
103 (home-page "http://www.cmake.org/")
104 (synopsis "Cross-platform build system")
105 (description
106 "CMake is a family of tools designed to build, test and package software.
107 CMake is used to control the software compilation process using simple platform
108 and compiler independent configuration files. CMake generates native makefiles
109 and workspaces that can be used in the compiler environment of your choice.")
110 (license bsd-3)))