Commit | Line | Data |
---|---|---|
b6a64843 CR |
1 | ;;; GNU Guix --- Functional package management for GNU |
2 | ;;; Copyright © 2013 Cyril Roelandt <tipecaml@gmail.com> | |
6212b8e5 | 3 | ;;; Copyright © 2014 Mark H Weaver <mhw@netris.org> |
c824d34f | 4 | ;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org> |
29a7c98a | 5 | ;;; Copyright © 2014 Ian Denhardt <ian@zenhack.net> |
477a752e | 6 | ;;; Copyright © 2015 Sou Bunnbu <iyzsong@gmail.com> |
3b698589 | 7 | ;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il> |
ff5733d1 | 8 | ;;; Copyright © 2017, 2018, 2020 Marius Bakke <mbakke@fastmail.com> |
89db6c6d | 9 | ;;; Copyright © 2018 Arun Isaac <arunisaac@systemreboot.net> |
4f3958da | 10 | ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr> |
2f33a732 | 11 | ;;; Copyright © 2019 Maxim Cournoyer <maxim.cournoyer@gmail.com> |
a8446b40 | 12 | ;;; Copyright © 2019 Pierre-Moana Levesque <pierre.moana.levesque@gmail.com> |
a7c3c5dc | 13 | ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> |
b6a64843 CR |
14 | ;;; |
15 | ;;; This file is part of GNU Guix. | |
16 | ;;; | |
17 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | |
18 | ;;; under the terms of the GNU General Public License as published by | |
19 | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
20 | ;;; your option) any later version. | |
21 | ;;; | |
22 | ;;; GNU Guix is distributed in the hope that it will be useful, but | |
23 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
24 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
25 | ;;; GNU General Public License for more details. | |
26 | ;;; | |
27 | ;;; You should have received a copy of the GNU General Public License | |
28 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | |
29 | ||
30 | (define-module (gnu packages cmake) | |
db909bf2 | 31 | #:use-module ((guix licenses) #:prefix license:) |
b6a64843 CR |
32 | #:use-module (guix packages) |
33 | #:use-module (guix download) | |
29a7c98a | 34 | #:use-module (guix utils) |
0de28f9e | 35 | #:use-module (guix deprecation) |
b6a64843 | 36 | #:use-module (guix build-system gnu) |
013c5c23 | 37 | #:use-module (guix build-system cmake) |
aa4818c3 | 38 | #:use-module (guix build-system emacs) |
b6a64843 | 39 | #:use-module (gnu packages) |
c824d34f EB |
40 | #:use-module (gnu packages backup) |
41 | #:use-module (gnu packages compression) | |
1568cc14 | 42 | #:use-module (gnu packages crypto) |
c824d34f | 43 | #:use-module (gnu packages curl) |
6212b8e5 | 44 | #:use-module (gnu packages file) |
a7c3c5dc | 45 | #:use-module (gnu packages hurd) |
4bbb7d48 | 46 | #:use-module (gnu packages libevent) |
21e5e1e0 | 47 | #:use-module (gnu packages ncurses) |
b5fc075d | 48 | #:use-module (gnu packages serialization) |
57df83e0 | 49 | #:use-module (gnu packages sphinx) |
2f33a732 MC |
50 | #:use-module (gnu packages texinfo) |
51 | #:use-module (gnu packages xml) | |
b5fc075d | 52 | #:use-module (ice-9 match) |
2f33a732 | 53 | #:use-module (srfi srfi-1)) |
b6a64843 | 54 | |
013c5c23 MB |
55 | ;;; Build phases shared between 'cmake-bootstrap' and the later variants |
56 | ;;; that use cmake-build-system. | |
57 | (define %common-build-phases | |
58 | `((add-after 'unpack 'split-package | |
59 | ;; Remove files that have been packaged in other package recipes. | |
60 | (lambda _ | |
61 | (delete-file "Auxiliary/cmake-mode.el") | |
62 | (substitute* "Auxiliary/CMakeLists.txt" | |
63 | ((".*cmake-mode.el.*") "")) | |
64 | #t)) | |
013c5c23 MB |
65 | (add-before 'configure 'patch-bin-sh |
66 | (lambda _ | |
67 | ;; Replace "/bin/sh" by the right path in... a lot of | |
68 | ;; files. | |
69 | (substitute* | |
70 | '("Modules/CompilerId/Xcode-3.pbxproj.in" | |
71 | "Modules/Internal/CPack/CPack.RuntimeScript.in" | |
72 | "Source/cmGlobalXCodeGenerator.cxx" | |
73 | "Source/cmLocalUnixMakefileGenerator3.cxx" | |
74 | "Source/cmExecProgramCommand.cxx" | |
75 | "Utilities/Release/release_cmake.cmake" | |
76 | "Tests/CMakeLists.txt" | |
77 | "Tests/RunCMake/File_Generate/RunCMakeTest.cmake") | |
78 | (("/bin/sh") (which "sh"))) | |
79 | #t)))) | |
80 | ||
81 | (define %common-disabled-tests | |
82 | '(;; This test copies libgcc_s.so.1 from GCC and tries to modify its RPATH, | |
83 | ;; but does not cope with the file being read-only. | |
84 | "BundleUtilities" | |
85 | ;; This test requires network access. | |
86 | "CTestTestUpload" | |
87 | ;; This test requires 'ldconfig' which is not available in Guix. | |
88 | "RunCMake.install")) | |
89 | ||
f9dcc39a MB |
90 | (define %preserved-third-party-files |
91 | '(;; 'Source/cm_getdate.c' includes archive_getdate.c wholesale, so it must | |
92 | ;; be available along with the required headers. | |
93 | "Utilities/cmlibarchive/libarchive/archive_getdate.c" | |
94 | "Utilities/cmlibarchive/libarchive/archive_getdate.h")) | |
95 | ||
013c5c23 MB |
96 | ;;; The "bootstrap" CMake. It is used to build 'cmake-minimal' below, as well |
97 | ;;; as any dependencies that need cmake-build-system. | |
7c1ea931 | 98 | (define-public cmake-bootstrap |
b6a64843 | 99 | (package |
7c1ea931 | 100 | (name "cmake-bootstrap") |
aca00b0a | 101 | (version "3.16.5") |
b6a64843 | 102 | (source (origin |
12420c80 AI |
103 | (method url-fetch) |
104 | (uri (string-append "https://www.cmake.org/files/v" | |
105 | (version-major+minor version) | |
106 | "/cmake-" version ".tar.gz")) | |
107 | (sha256 | |
108 | (base32 | |
aca00b0a | 109 | "1z4bb8z6b4dvq5hrvajrf1hyybqay3xybyimf71w1jgcp180nxjz")) |
ed24dda7 MB |
110 | (modules '((guix build utils) |
111 | (ice-9 ftw))) | |
12420c80 | 112 | (snippet |
f9dcc39a MB |
113 | `(begin |
114 | ;; CMake bundles its dependencies in the "Utilities" directory. | |
115 | ;; Delete those to ensure the system libraries are used. | |
116 | (define preserved-files | |
117 | '(,@%preserved-third-party-files | |
118 | ;; Use the bundled JsonCpp during bootstrap to work around | |
119 | ;; a circular dependency. TODO: JsonCpp can be built with | |
120 | ;; Meson instead of CMake, but meson-build-system currently | |
121 | ;; does not support cross-compilation. | |
122 | "Utilities/cmjsoncpp" | |
123 | ;; LibUV is required to bootstrap the initial build system. | |
124 | "Utilities/cmlibuv")) | |
ed24dda7 | 125 | |
f9dcc39a MB |
126 | (file-system-fold (lambda (dir stat result) ;enter? |
127 | (or (string=? "Utilities" dir) ;init | |
128 | ;; The bundled dependencies are | |
129 | ;; distinguished by having a "cm" | |
130 | ;; prefix to their upstream names. | |
131 | (and (string-prefix? "Utilities/cm" dir) | |
132 | (not (member dir preserved-files))))) | |
133 | (lambda (file stat result) ;leaf | |
134 | (unless (or (member file preserved-files) | |
135 | ;; Preserve top-level files. | |
136 | (string=? "Utilities" | |
137 | (dirname file))) | |
138 | (delete-file file))) | |
139 | (const #t) ;down | |
140 | (lambda (dir stat result) ;up | |
141 | (when (equal? (scandir dir) '("." "..")) | |
142 | (rmdir dir))) | |
143 | (const #t) ;skip | |
144 | (lambda (file stat errno result) | |
145 | (format (current-error-port) | |
146 | "warning: failed to delete ~a: ~a~%" | |
147 | file (strerror errno))) | |
148 | #t | |
149 | "Utilities" | |
150 | lstat) | |
ed24dda7 | 151 | #t)) |
a4de5cfd | 152 | (patches (search-patches "cmake-curl-certificates.patch")))) |
b6a64843 CR |
153 | (build-system gnu-build-system) |
154 | (arguments | |
6212b8e5 | 155 | `(#:test-target "test" |
2f33a732 MC |
156 | #:configure-flags |
157 | (let ((out (assoc-ref %outputs "out")) | |
158 | (parallel-job-count (number->string (parallel-job-count)))) | |
159 | (list "--verbose" | |
160 | (string-append "--parallel=" parallel-job-count) | |
161 | (string-append "--prefix=" out) | |
162 | "--system-libs" | |
b5fc075d | 163 | "--no-system-jsoncpp" |
2f33a732 MC |
164 | ;; By default, the man pages and other docs land |
165 | ;; in PREFIX/man and PREFIX/doc, but we want them | |
166 | ;; in share/{man,doc}. Note that unlike | |
167 | ;; autoconf-generated configure scripts, cmake's | |
168 | ;; configure prepends "PREFIX/" to what we pass | |
169 | ;; to --mandir and --docdir. | |
170 | "--mandir=share/man" | |
171 | ,(string-append "--docdir=share/doc/cmake-" | |
fa8e0a53 MB |
172 | (version-major+minor version)) |
173 | ||
174 | ;; By default CMake is built without any optimizations. Use | |
175 | ;; the recommended Release target for a ~2.5x speedup. | |
176 | "--" "-DCMAKE_BUILD_TYPE=Release")) | |
89db6c6d AI |
177 | #:make-flags |
178 | (let ((skipped-tests | |
013c5c23 | 179 | (list ,@%common-disabled-tests |
89db6c6d | 180 | "CTestTestSubdir" ; This test fails to build 2 of the 3 tests. |
013c5c23 MB |
181 | ;; This test fails when ARGS (below) is in use, see |
182 | ;; <https://gitlab.kitware.com/cmake/cmake/issues/17165>. | |
183 | "CTestCoverageCollectGCOV"))) | |
89db6c6d AI |
184 | (list |
185 | (string-append | |
12cb6c31 MB |
186 | ;; These arguments apply for the tests only. |
187 | "ARGS=-j " (number->string (parallel-job-count)) | |
188 | " --output-on-failure" | |
189 | " --exclude-regex ^\\(" (string-join skipped-tests "\\|") "\\)$"))) | |
6e261af1 EF |
190 | #:phases |
191 | (modify-phases %standard-phases | |
013c5c23 | 192 | ,@%common-build-phases |
6e261af1 EF |
193 | (add-before 'configure 'set-paths |
194 | (lambda _ | |
195 | ;; Help cmake's bootstrap process to find system libraries | |
196 | (begin | |
197 | (setenv "CMAKE_LIBRARY_PATH" (getenv "LIBRARY_PATH")) | |
546bee40 MB |
198 | (setenv "CMAKE_INCLUDE_PATH" (or (getenv "CPATH") |
199 | (getenv "C_INCLUDE_PATH"))) | |
4bbb7d48 | 200 | #t))) |
2f33a732 | 201 | ;; CMake uses its own configure script. |
6e261af1 | 202 | (replace 'configure |
2f33a732 MC |
203 | (lambda* (#:key (configure-flags '()) #:allow-other-keys) |
204 | (apply invoke "./configure" configure-flags)))))) | |
ac841750 | 205 | (inputs |
89db6c6d | 206 | `(("bzip2" ,bzip2) |
7c1ea931 | 207 | ("curl" ,curl-minimal) |
89db6c6d AI |
208 | ("expat" ,expat) |
209 | ("file" ,file) | |
210 | ("libarchive" ,libarchive) | |
a7c3c5dc JN |
211 | ,@(if (hurd-target?) |
212 | '() | |
213 | `(("libuv" ,libuv))) ;not supported on the Hurd | |
ac841750 | 214 | ("ncurses" ,ncurses) ;required for ccmake |
89db6c6d AI |
215 | ("rhash" ,rhash) |
216 | ("zlib" ,zlib))) | |
0d6f9360 AE |
217 | (native-search-paths |
218 | (list (search-path-specification | |
89db6c6d | 219 | (variable "CMAKE_PREFIX_PATH") |
3cfe76be MB |
220 | (files '(""))) |
221 | ;; "cmake-curl-certificates.patch" changes CMake to honor 'SSL_CERT_DIR' | |
222 | ;; and 'SSL_CERT_FILE', hence these search path entries. | |
223 | (search-path-specification | |
224 | (variable "SSL_CERT_DIR") | |
225 | (separator #f) ;single entry | |
226 | (files '("etc/ssl/certs"))) | |
227 | (search-path-specification | |
228 | (variable "SSL_CERT_FILE") | |
229 | (file-type 'regular) | |
230 | (separator #f) ;single entry | |
231 | (files '("etc/ssl/certs/ca-certificates.crt"))))) | |
89db6c6d | 232 | (home-page "https://cmake.org/") |
749b90a5 | 233 | (synopsis "Cross-platform build system") |
b6a64843 CR |
234 | (description |
235 | "CMake is a family of tools designed to build, test and package software. | |
236 | CMake is used to control the software compilation process using simple platform | |
c824d34f | 237 | and compiler independent configuration files. CMake generates native makefiles |
b6a64843 | 238 | and workspaces that can be used in the compiler environment of your choice.") |
2f33a732 MC |
239 | (properties '((hidden? . #t))) |
240 | (license (list license:bsd-3 ; cmake | |
2f33a732 | 241 | license:expat ; cmjsoncpp is dual MIT/public domain |
db909bf2 | 242 | license:public-domain)))) ; cmlibarchive/archive_getdate.c |
1568cc14 | 243 | |
7c1ea931 MB |
244 | ;;; This minimal variant of CMake does not include the documentation. It is |
245 | ;;; used by the cmake-build-system. | |
246 | (define-public cmake-minimal | |
247 | (package | |
248 | (inherit cmake-bootstrap) | |
249 | (name "cmake-minimal") | |
b5fc075d MB |
250 | (source (origin |
251 | (inherit (package-source cmake-bootstrap)) | |
252 | (snippet | |
253 | (match (origin-snippet (package-source cmake-bootstrap)) | |
f9dcc39a | 254 | ((_ _ exp ...) |
11f4d877 | 255 | ;; Now we can delete the remaining software bundles. |
f9dcc39a MB |
256 | (append `(begin |
257 | (define preserved-files ',%preserved-third-party-files)) | |
b5fc075d | 258 | exp)))))) |
ac841750 | 259 | (inputs |
7c1ea931 | 260 | `(("curl" ,curl) |
b5fc075d | 261 | ("jsoncpp" ,jsoncpp) |
ac841750 | 262 | ,@(alist-delete "curl" (package-inputs cmake-bootstrap)))) |
013c5c23 | 263 | (build-system cmake-build-system) |
b5fc075d | 264 | (arguments |
013c5c23 MB |
265 | `(#:configure-flags |
266 | (list "-DCMAKE_USE_SYSTEM_LIBRARIES=ON" | |
267 | (string-append "-DCMAKE_DOC_DIR=share/doc/cmake-" | |
268 | ,(version-major+minor (package-version | |
269 | cmake-bootstrap)))) | |
270 | ||
271 | ;; This is the CMake used in cmake-build-system. Ensure compiler | |
272 | ;; optimizations are enabled to save size and CPU cycles. | |
273 | #:build-type "Release" | |
274 | #:phases | |
275 | (modify-phases %standard-phases | |
276 | ,@%common-build-phases | |
277 | (replace 'check | |
278 | (lambda* (#:key tests? parallel-tests? #:allow-other-keys) | |
279 | (let ((skipped-tests (list ,@%common-disabled-tests | |
280 | ;; This test requires the bundled libuv. | |
281 | "BootstrapTest"))) | |
282 | (if tests? | |
283 | (begin | |
284 | (invoke "ctest" "-j" (if parallel-tests? | |
285 | (number->string (parallel-job-count)) | |
286 | "1") | |
287 | "--exclude-regex" | |
288 | (string-append "^(" (string-join skipped-tests "|") ")$"))) | |
289 | (format #t "test suite not run~%")) | |
290 | #t)))) | |
291 | ,@(if (%current-target-system) | |
292 | '() | |
293 | `(#:cmake ,cmake-bootstrap)))))) | |
7c1ea931 MB |
294 | |
295 | ;;; The "user-facing" CMake, now with manuals and HTML documentation. | |
2f33a732 MC |
296 | (define-public cmake |
297 | (package | |
298 | (inherit cmake-minimal) | |
299 | (name "cmake") | |
300 | (arguments | |
301 | (substitute-keyword-arguments (package-arguments cmake-minimal) | |
013c5c23 MB |
302 | ;; Use cmake-minimal this time. |
303 | ((#:cmake _ #f) | |
304 | (if (%current-target-system) | |
305 | cmake-minimal-cross | |
306 | cmake-minimal)) | |
28ba01ae MB |
307 | |
308 | ;; Enable debugging information for convenience. | |
309 | ((#:build-type _ #f) "RelWithDebInfo") | |
310 | ||
013c5c23 MB |
311 | ((#:configure-flags flags ''()) |
312 | `(append (list "-DSPHINX_INFO=ON" "-DSPHINX_MAN=ON" "-DSPHINX_HTML=ON" | |
313 | (string-append "-DCMAKE_DOC_DIR=share/doc/cmake-" | |
314 | ,(version-major+minor (package-version | |
315 | cmake-minimal))) | |
316 | "-DCMAKE_INFO_DIR=share/info" | |
317 | "-DCMAKE_MAN_DIR=share/man") | |
318 | ,flags)) | |
2f33a732 MC |
319 | ((#:phases phases) |
320 | `(modify-phases ,phases | |
321 | (add-after 'install 'move-html-doc | |
322 | (lambda* (#:key outputs #:allow-other-keys) | |
323 | (let ((out (assoc-ref outputs "out")) | |
324 | (doc (assoc-ref outputs "doc")) | |
325 | (html (string-append "/share/doc/cmake-" | |
326 | ,(version-major+minor | |
327 | (package-version cmake-minimal)) | |
328 | "/html"))) | |
329 | (copy-recursively (string-append out html) | |
330 | (string-append doc html)) | |
331 | (delete-file-recursively (string-append out html)) | |
332 | #t))))))) | |
333 | ;; Extra inputs required to build the documentation. | |
334 | (native-inputs | |
335 | `(,@(package-native-inputs cmake-minimal) | |
336 | ("python-sphinx" ,python-sphinx) | |
337 | ("texinfo" ,texinfo))) | |
338 | (outputs '("out" "doc")) | |
339 | (properties (alist-delete 'hidden? (package-properties cmake-minimal))))) | |
340 | ||
534537e2 MO |
341 | (define-public cmake-minimal-cross |
342 | (package | |
343 | (inherit cmake-minimal) | |
344 | (name "cmake-minimal-cross") | |
345 | (native-search-paths '()) | |
346 | (search-paths | |
347 | (package-native-search-paths cmake-minimal)))) | |
348 | ||
bbdf3666 OP |
349 | (define-public emacs-cmake-mode |
350 | (package | |
351 | (inherit cmake) | |
352 | (name "emacs-cmake-mode") | |
5a7c6d02 MB |
353 | (native-inputs '()) |
354 | (inputs '()) | |
355 | (outputs '("out")) | |
bbdf3666 OP |
356 | (build-system emacs-build-system) |
357 | (arguments | |
358 | `(#:phases | |
359 | (modify-phases %standard-phases | |
360 | (add-after 'unpack 'chdir-elisp | |
361 | ;; Elisp directory is not in root of the source. | |
362 | (lambda _ | |
5a7c6d02 MB |
363 | (chdir "Auxiliary") |
364 | #t))))) | |
bbdf3666 OP |
365 | (synopsis "Emacs major mode for editing Cmake expressions") |
366 | (description "@code{cmakeos-mode} provides an Emacs major mode for editing | |
367 | Cmake files. It supports syntax highlighting, indenting and refilling of | |
368 | comments."))) |