gnu: CMake: Update to 3.16.0.
[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 ;;; Copyright © 2015 Sou Bunnbu <iyzsong@gmail.com>
7 ;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
8 ;;; Copyright © 2017, 2018 Marius Bakke <mbakke@fastmail.com>
9 ;;; Copyright © 2018 Arun Isaac <arunisaac@systemreboot.net>
10 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
11 ;;; Copyright © 2019 Maxim Cournoyer <maxim.cournoyer@gmail.com>
12 ;;; Copyright © 2019 Pierre-Moana Levesque <pierre.moana.levesque@gmail.com>
13 ;;;
14 ;;; This file is part of GNU Guix.
15 ;;;
16 ;;; GNU Guix is free software; you can redistribute it and/or modify it
17 ;;; under the terms of the GNU General Public License as published by
18 ;;; the Free Software Foundation; either version 3 of the License, or (at
19 ;;; your option) any later version.
20 ;;;
21 ;;; GNU Guix is distributed in the hope that it will be useful, but
22 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
23 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 ;;; GNU General Public License for more details.
25 ;;;
26 ;;; You should have received a copy of the GNU General Public License
27 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
28
29 (define-module (gnu packages cmake)
30 #:use-module ((guix licenses) #:prefix license:)
31 #:use-module (guix packages)
32 #:use-module (guix download)
33 #:use-module (guix utils)
34 #:use-module (guix build-system gnu)
35 #:use-module (guix build-system emacs)
36 #:use-module (gnu packages)
37 #:use-module (gnu packages backup)
38 #:use-module (gnu packages compression)
39 #:use-module (gnu packages crypto)
40 #:use-module (gnu packages curl)
41 #:use-module (gnu packages file)
42 #:use-module (gnu packages libevent)
43 #:use-module (gnu packages ncurses)
44 #:use-module (gnu packages sphinx)
45 #:use-module (gnu packages texinfo)
46 #:use-module (gnu packages xml)
47 #:use-module (srfi srfi-1))
48
49 ;;; This minimal variant of CMake does not include the documentation. It is
50 ;;; used by the cmake-build-system.
51 (define-public cmake-minimal
52 (package
53 (name "cmake-minimal")
54 (version "3.16.0")
55 (source (origin
56 (method url-fetch)
57 (uri (string-append "https://www.cmake.org/files/v"
58 (version-major+minor version)
59 "/cmake-" version ".tar.gz"))
60 (sha256
61 (base32
62 "0pwcgvk75577rdizpzjrk2n43a6l7rvfhmhn7sd6xarwqrb6b9bd"))
63 (modules '((guix build utils)))
64 (snippet
65 '(begin
66 ;; Drop bundled software.
67 (with-directory-excursion "Utilities"
68 (for-each delete-file-recursively
69 '("cmbzip2"
70 ;; "cmcompress"
71 "cmcurl"
72 "cmexpat"
73 ;; "cmjsoncpp"
74 ;; "cmlibarchive"
75 "cmliblzma"
76 ;; "cmlibuv"
77 "cmzlib"))
78 #t)))
79 (patches (search-patches "cmake-curl-certificates.patch"))))
80 (build-system gnu-build-system)
81 (arguments
82 `(#:test-target "test"
83 #:configure-flags
84 (let ((out (assoc-ref %outputs "out"))
85 (parallel-job-count (number->string (parallel-job-count))))
86 (list "--verbose"
87 (string-append "--parallel=" parallel-job-count)
88 (string-append "--prefix=" out)
89 "--system-libs"
90 "--no-system-jsoncpp" ; FIXME: Circular dependency.
91 ;; By default, the man pages and other docs land
92 ;; in PREFIX/man and PREFIX/doc, but we want them
93 ;; in share/{man,doc}. Note that unlike
94 ;; autoconf-generated configure scripts, cmake's
95 ;; configure prepends "PREFIX/" to what we pass
96 ;; to --mandir and --docdir.
97 "--mandir=share/man"
98 ,(string-append "--docdir=share/doc/cmake-"
99 (version-major+minor version))))
100 #:make-flags
101 (let ((skipped-tests
102 (list "BundleUtilities" ; This test fails on Guix.
103 "CTestTestSubdir" ; This test fails to build 2 of the 3 tests.
104 ;; This test requires 'ldconfig' which is not available in Guix.
105 "RunCMake.install"
106 ;; These tests requires network access.
107 "CTestCoverageCollectGCOV"
108 "CTestTestUpload")))
109 (list
110 (string-append
111 ;; These arguments apply for the tests only.
112 "ARGS=-j " (number->string (parallel-job-count))
113 " --output-on-failure"
114 " --exclude-regex ^\\(" (string-join skipped-tests "\\|") "\\)$")))
115 #:phases
116 (modify-phases %standard-phases
117 (add-after 'unpack 'split-package
118 ;; Remove files that have been packaged in other package recipes.
119 (lambda _
120 (delete-file "Auxiliary/cmake-mode.el")
121 (substitute* "Auxiliary/CMakeLists.txt"
122 ((".*cmake-mode.el.*") ""))
123 #t))
124 (add-before 'configure 'patch-bin-sh
125 (lambda _
126 ;; Replace "/bin/sh" by the right path in... a lot of
127 ;; files.
128 (substitute*
129 '("Modules/CompilerId/Xcode-3.pbxproj.in"
130 "Modules/Internal/CPack/CPack.RuntimeScript.in"
131 "Source/cmGlobalXCodeGenerator.cxx"
132 "Source/cmLocalUnixMakefileGenerator3.cxx"
133 "Source/cmExecProgramCommand.cxx"
134 "Utilities/Release/release_cmake.cmake"
135 "Utilities/cmlibarchive/libarchive/archive_write_set_format_shar.c"
136 "Tests/CMakeLists.txt"
137 "Tests/RunCMake/File_Generate/RunCMakeTest.cmake")
138 (("/bin/sh") (which "sh")))
139 #t))
140 (add-before 'configure 'set-paths
141 (lambda _
142 ;; Help cmake's bootstrap process to find system libraries
143 (begin
144 (setenv "CMAKE_LIBRARY_PATH" (getenv "LIBRARY_PATH"))
145 (setenv "CMAKE_INCLUDE_PATH" (or (getenv "CPATH")
146 (getenv "C_INCLUDE_PATH")))
147 #t)))
148 ;; CMake uses its own configure script.
149 (replace 'configure
150 (lambda* (#:key (configure-flags '()) #:allow-other-keys)
151 (apply invoke "./configure" configure-flags))))))
152 (native-inputs
153 `(("bzip2" ,bzip2)
154 ("curl" ,curl)
155 ("expat" ,expat)
156 ("file" ,file)
157 ("libarchive" ,libarchive)
158 ("libuv" ,libuv)
159 ("rhash" ,rhash)
160 ("zlib" ,zlib)))
161 (inputs
162 `(("ncurses" ,ncurses))) ; required for ccmake
163 (native-search-paths
164 (list (search-path-specification
165 (variable "CMAKE_PREFIX_PATH")
166 (files '("")))))
167 (home-page "https://cmake.org/")
168 (synopsis "Cross-platform build system")
169 (description
170 "CMake is a family of tools designed to build, test and package software.
171 CMake is used to control the software compilation process using simple platform
172 and compiler independent configuration files. CMake generates native makefiles
173 and workspaces that can be used in the compiler environment of your choice.")
174 (properties '((hidden? . #t)))
175 (license (list license:bsd-3 ; cmake
176 license:bsd-4 ; cmcompress
177 license:bsd-2 ; cmlibarchive
178 license:expat ; cmjsoncpp is dual MIT/public domain
179 license:public-domain)))) ; cmlibarchive/archive_getdate.c
180
181 (define-public cmake
182 (package
183 (inherit cmake-minimal)
184 (name "cmake")
185 (arguments
186 (substitute-keyword-arguments (package-arguments cmake-minimal)
187 ((#:configure-flags configure-flags ''())
188 `(append ,configure-flags
189 ;; Extra configure flags used to generate the documentation.
190 '("--sphinx-info"
191 "--sphinx-man"
192 "--sphinx-html")))
193 ((#:phases phases)
194 `(modify-phases ,phases
195 (add-after 'install 'move-html-doc
196 (lambda* (#:key outputs #:allow-other-keys)
197 (let ((out (assoc-ref outputs "out"))
198 (doc (assoc-ref outputs "doc"))
199 (html (string-append "/share/doc/cmake-"
200 ,(version-major+minor
201 (package-version cmake-minimal))
202 "/html")))
203 (copy-recursively (string-append out html)
204 (string-append doc html))
205 (delete-file-recursively (string-append out html))
206 #t)))))))
207 ;; Extra inputs required to build the documentation.
208 (native-inputs
209 `(,@(package-native-inputs cmake-minimal)
210 ("python-sphinx" ,python-sphinx)
211 ("texinfo" ,texinfo)))
212 (outputs '("out" "doc"))
213 (properties (alist-delete 'hidden? (package-properties cmake-minimal)))))
214
215 (define-public cmake-minimal-cross
216 (package
217 (inherit cmake-minimal)
218 (name "cmake-minimal-cross")
219 (native-search-paths '())
220 (search-paths
221 (package-native-search-paths cmake-minimal))))
222
223 (define-public emacs-cmake-mode
224 (package
225 (inherit cmake)
226 (name "emacs-cmake-mode")
227 (native-inputs '())
228 (inputs '())
229 (outputs '("out"))
230 (build-system emacs-build-system)
231 (arguments
232 `(#:phases
233 (modify-phases %standard-phases
234 (add-after 'unpack 'chdir-elisp
235 ;; Elisp directory is not in root of the source.
236 (lambda _
237 (chdir "Auxiliary")
238 #t)))))
239 (synopsis "Emacs major mode for editing Cmake expressions")
240 (description "@code{cmakeos-mode} provides an Emacs major mode for editing
241 Cmake files. It supports syntax highlighting, indenting and refilling of
242 comments.")))