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> |
1539af46 | 8 | ;;; Copyright © 2017, 2018, 2020, 2021 Marius Bakke <marius@gnu.org> |
89db6c6d | 9 | ;;; Copyright © 2018 Arun Isaac <arunisaac@systemreboot.net> |
40e96a4f | 10 | ;;; Copyright © 2018, 2020 Tobias Geerinckx-Rice <me@tobias.gr> |
76454d9a | 11 | ;;; Copyright © 2019, 2020, 2021, 2022 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> |
c486a61c | 14 | ;;; Copyright © 2021 Ricardo Wurmus <rekado@elephly.net> |
b6a64843 CR |
15 | ;;; |
16 | ;;; This file is part of GNU Guix. | |
17 | ;;; | |
18 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | |
19 | ;;; under the terms of the GNU General Public License as published by | |
20 | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
21 | ;;; your option) any later version. | |
22 | ;;; | |
23 | ;;; GNU Guix is distributed in the hope that it will be useful, but | |
24 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
25 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
26 | ;;; GNU General Public License for more details. | |
27 | ;;; | |
28 | ;;; You should have received a copy of the GNU General Public License | |
29 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | |
30 | ||
31 | (define-module (gnu packages cmake) | |
db909bf2 | 32 | #:use-module ((guix licenses) #:prefix license:) |
b6a64843 CR |
33 | #:use-module (guix packages) |
34 | #:use-module (guix download) | |
79389ac3 | 35 | #:use-module (guix git-download) |
29a7c98a | 36 | #:use-module (guix utils) |
0de28f9e | 37 | #:use-module (guix deprecation) |
b6a64843 | 38 | #:use-module (guix build-system gnu) |
013c5c23 | 39 | #:use-module (guix build-system cmake) |
aa4818c3 | 40 | #:use-module (guix build-system emacs) |
579270c6 | 41 | #:use-module ((guix search-paths) #:select ($SSL_CERT_DIR $SSL_CERT_FILE)) |
b6a64843 | 42 | #:use-module (gnu packages) |
c824d34f EB |
43 | #:use-module (gnu packages backup) |
44 | #:use-module (gnu packages compression) | |
1568cc14 | 45 | #:use-module (gnu packages crypto) |
c824d34f | 46 | #:use-module (gnu packages curl) |
6212b8e5 | 47 | #:use-module (gnu packages file) |
a7c3c5dc | 48 | #:use-module (gnu packages hurd) |
79389ac3 | 49 | #:use-module (gnu packages kde-frameworks) |
4bbb7d48 | 50 | #:use-module (gnu packages libevent) |
21e5e1e0 | 51 | #:use-module (gnu packages ncurses) |
b5fc075d | 52 | #:use-module (gnu packages serialization) |
57df83e0 | 53 | #:use-module (gnu packages sphinx) |
2f33a732 MC |
54 | #:use-module (gnu packages texinfo) |
55 | #:use-module (gnu packages xml) | |
b5fc075d | 56 | #:use-module (ice-9 match) |
2f33a732 | 57 | #:use-module (srfi srfi-1)) |
b6a64843 | 58 | |
79389ac3 | 59 | (define-public cmake-shared |
8bd0632a RG |
60 | (let ((commit "8122f2b96c8da38ea41b653cf69958e75fe2129d") |
61 | (revision "32")) | |
62 | (package | |
63 | (name "cmake-shared") | |
64 | (version | |
65 | (git-version "1.1.0" revision commit)) | |
66 | (source | |
67 | (origin | |
68 | (method git-fetch) | |
69 | (uri | |
70 | (git-reference | |
71 | (url "https://github.com/lirios/cmake-shared.git") | |
72 | (commit commit))) | |
73 | (file-name | |
74 | (git-file-name name version)) | |
75 | (sha256 | |
76 | (base32 "05avwzqcnliwx9h7qi1kl0iz4smqmxc4vkavyjbmlc6h2b97i58g")) | |
77 | (modules '((guix build utils) | |
78 | (ice-9 ftw) | |
79 | (srfi srfi-1))) | |
80 | (snippet | |
81 | `(begin | |
82 | (delete-file-recursively "3rdparty"))))) | |
83 | (build-system cmake-build-system) | |
84 | (arguments | |
85 | `(#:tests? #f)) ; No target | |
86 | (native-inputs | |
8394619b | 87 | (list extra-cmake-modules)) |
8bd0632a RG |
88 | (synopsis "Shared CMake functions and macros") |
89 | (description "CMake-Shared are shared functions and macros for projects | |
79389ac3 | 90 | using the CMake build system.") |
8bd0632a RG |
91 | (home-page "https://github.com/lirios/cmake-shared/") |
92 | (license license:bsd-3)))) | |
79389ac3 | 93 | |
013c5c23 MB |
94 | ;;; Build phases shared between 'cmake-bootstrap' and the later variants |
95 | ;;; that use cmake-build-system. | |
f762d63e | 96 | (define (%common-build-phases) |
013c5c23 MB |
97 | `((add-after 'unpack 'split-package |
98 | ;; Remove files that have been packaged in other package recipes. | |
99 | (lambda _ | |
100 | (delete-file "Auxiliary/cmake-mode.el") | |
101 | (substitute* "Auxiliary/CMakeLists.txt" | |
102 | ((".*cmake-mode.el.*") "")) | |
103 | #t)) | |
f762d63e LC |
104 | ,@(if (target-x86-32?) |
105 | '((add-after 'unpack 'skip-cpack-txz-test | |
106 | (lambda _ | |
107 | ;; In 'RunCMake.CPack_TXZ', the 'TXZ/THREADED_ALL' test | |
108 | ;; would occasionally fail on i686 with "Internal error | |
109 | ;; initializing compression library: Cannot allocate | |
110 | ;; memory": <https://issues.guix.gnu.org/50617>. Skip it. | |
111 | (substitute* "Tests/RunCMake/CPack/RunCMakeTest.cmake" | |
112 | (("THREADED_ALL \"TXZ;DEB\"") | |
113 | "THREADED_ALL \"DEB\""))))) | |
114 | '()) | |
013c5c23 MB |
115 | (add-before 'configure 'patch-bin-sh |
116 | (lambda _ | |
117 | ;; Replace "/bin/sh" by the right path in... a lot of | |
118 | ;; files. | |
119 | (substitute* | |
120 | '("Modules/CompilerId/Xcode-3.pbxproj.in" | |
121 | "Modules/Internal/CPack/CPack.RuntimeScript.in" | |
122 | "Source/cmGlobalXCodeGenerator.cxx" | |
123 | "Source/cmLocalUnixMakefileGenerator3.cxx" | |
124 | "Source/cmExecProgramCommand.cxx" | |
013c5c23 MB |
125 | "Tests/CMakeLists.txt" |
126 | "Tests/RunCMake/File_Generate/RunCMakeTest.cmake") | |
127 | (("/bin/sh") (which "sh"))) | |
128 | #t)))) | |
129 | ||
130 | (define %common-disabled-tests | |
131 | '(;; This test copies libgcc_s.so.1 from GCC and tries to modify its RPATH, | |
132 | ;; but does not cope with the file being read-only. | |
133 | "BundleUtilities" | |
6933a32b MC |
134 | ;; These tests require network access. |
135 | "CTestTestUpload" "CMake.FileDownload" | |
013c5c23 | 136 | ;; This test requires 'ldconfig' which is not available in Guix. |
ff012063 CB |
137 | "RunCMake.install" |
138 | ;; This test fails for unknown reason. | |
1539af46 | 139 | "RunCMake.file-GET_RUNTIME_DEPENDENCIES")) |
013c5c23 | 140 | |
f9dcc39a MB |
141 | (define %preserved-third-party-files |
142 | '(;; 'Source/cm_getdate.c' includes archive_getdate.c wholesale, so it must | |
143 | ;; be available along with the required headers. | |
144 | "Utilities/cmlibarchive/libarchive/archive_getdate.c" | |
9ea8616b MC |
145 | "Utilities/cmlibarchive/libarchive/archive_getdate.h" |
146 | ;; CMake header wrappers. | |
147 | "Utilities/cm3p")) | |
f9dcc39a | 148 | |
013c5c23 MB |
149 | ;;; The "bootstrap" CMake. It is used to build 'cmake-minimal' below, as well |
150 | ;;; as any dependencies that need cmake-build-system. | |
7c1ea931 | 151 | (define-public cmake-bootstrap |
b6a64843 | 152 | (package |
7c1ea931 | 153 | (name "cmake-bootstrap") |
eda1860d | 154 | (version "3.21.4") |
b6a64843 | 155 | (source (origin |
12420c80 | 156 | (method url-fetch) |
b8515f72 | 157 | (uri (string-append "https://cmake.org/files/v" |
12420c80 AI |
158 | (version-major+minor version) |
159 | "/cmake-" version ".tar.gz")) | |
160 | (sha256 | |
161 | (base32 | |
eda1860d | 162 | "0y2rk316j9m1iqimgwah0z1ii3ggli65dw6hdn4ckx0mqaahlmyr")) |
a4de5cfd | 163 | (patches (search-patches "cmake-curl-certificates.patch")))) |
b6a64843 CR |
164 | (build-system gnu-build-system) |
165 | (arguments | |
6212b8e5 | 166 | `(#:test-target "test" |
2f33a732 MC |
167 | #:configure-flags |
168 | (let ((out (assoc-ref %outputs "out")) | |
169 | (parallel-job-count (number->string (parallel-job-count)))) | |
170 | (list "--verbose" | |
171 | (string-append "--parallel=" parallel-job-count) | |
172 | (string-append "--prefix=" out) | |
173 | "--system-libs" | |
b5fc075d | 174 | "--no-system-jsoncpp" |
2f33a732 MC |
175 | ;; By default, the man pages and other docs land |
176 | ;; in PREFIX/man and PREFIX/doc, but we want them | |
177 | ;; in share/{man,doc}. Note that unlike | |
178 | ;; autoconf-generated configure scripts, cmake's | |
179 | ;; configure prepends "PREFIX/" to what we pass | |
180 | ;; to --mandir and --docdir. | |
181 | "--mandir=share/man" | |
182 | ,(string-append "--docdir=share/doc/cmake-" | |
fa8e0a53 MB |
183 | (version-major+minor version)) |
184 | ||
185 | ;; By default CMake is built without any optimizations. Use | |
186 | ;; the recommended Release target for a ~2.5x speedup. | |
187 | "--" "-DCMAKE_BUILD_TYPE=Release")) | |
89db6c6d AI |
188 | #:make-flags |
189 | (let ((skipped-tests | |
013c5c23 | 190 | (list ,@%common-disabled-tests |
89db6c6d | 191 | "CTestTestSubdir" ; This test fails to build 2 of the 3 tests. |
013c5c23 MB |
192 | ;; This test fails when ARGS (below) is in use, see |
193 | ;; <https://gitlab.kitware.com/cmake/cmake/issues/17165>. | |
194 | "CTestCoverageCollectGCOV"))) | |
89db6c6d AI |
195 | (list |
196 | (string-append | |
12cb6c31 MB |
197 | ;; These arguments apply for the tests only. |
198 | "ARGS=-j " (number->string (parallel-job-count)) | |
199 | " --output-on-failure" | |
200 | " --exclude-regex ^\\(" (string-join skipped-tests "\\|") "\\)$"))) | |
6e261af1 EF |
201 | #:phases |
202 | (modify-phases %standard-phases | |
f762d63e | 203 | ,@(%common-build-phases) |
6e261af1 EF |
204 | (add-before 'configure 'set-paths |
205 | (lambda _ | |
206 | ;; Help cmake's bootstrap process to find system libraries | |
207 | (begin | |
208 | (setenv "CMAKE_LIBRARY_PATH" (getenv "LIBRARY_PATH")) | |
546bee40 MB |
209 | (setenv "CMAKE_INCLUDE_PATH" (or (getenv "CPATH") |
210 | (getenv "C_INCLUDE_PATH"))) | |
4bbb7d48 | 211 | #t))) |
2f33a732 | 212 | ;; CMake uses its own configure script. |
6e261af1 | 213 | (replace 'configure |
2f33a732 MC |
214 | (lambda* (#:key (configure-flags '()) #:allow-other-keys) |
215 | (apply invoke "./configure" configure-flags)))))) | |
ac841750 | 216 | (inputs |
89db6c6d | 217 | `(("bzip2" ,bzip2) |
c78964ef | 218 | ("curl" ,curl) |
89db6c6d AI |
219 | ("expat" ,expat) |
220 | ("file" ,file) | |
221 | ("libarchive" ,libarchive) | |
a7c3c5dc JN |
222 | ,@(if (hurd-target?) |
223 | '() | |
224 | `(("libuv" ,libuv))) ;not supported on the Hurd | |
89db6c6d AI |
225 | ("rhash" ,rhash) |
226 | ("zlib" ,zlib))) | |
0d6f9360 AE |
227 | (native-search-paths |
228 | (list (search-path-specification | |
89db6c6d | 229 | (variable "CMAKE_PREFIX_PATH") |
3cfe76be MB |
230 | (files '(""))) |
231 | ;; "cmake-curl-certificates.patch" changes CMake to honor 'SSL_CERT_DIR' | |
232 | ;; and 'SSL_CERT_FILE', hence these search path entries. | |
579270c6 MD |
233 | $SSL_CERT_DIR |
234 | $SSL_CERT_FILE)) | |
89db6c6d | 235 | (home-page "https://cmake.org/") |
749b90a5 | 236 | (synopsis "Cross-platform build system") |
b6a64843 CR |
237 | (description |
238 | "CMake is a family of tools designed to build, test and package software. | |
239 | CMake is used to control the software compilation process using simple platform | |
c824d34f | 240 | and compiler independent configuration files. CMake generates native makefiles |
b6a64843 | 241 | and workspaces that can be used in the compiler environment of your choice.") |
2f33a732 MC |
242 | (properties '((hidden? . #t))) |
243 | (license (list license:bsd-3 ; cmake | |
2f33a732 | 244 | license:expat ; cmjsoncpp is dual MIT/public domain |
db909bf2 | 245 | license:public-domain)))) ; cmlibarchive/archive_getdate.c |
1568cc14 | 246 | |
7c1ea931 MB |
247 | ;;; This minimal variant of CMake does not include the documentation. It is |
248 | ;;; used by the cmake-build-system. | |
249 | (define-public cmake-minimal | |
250 | (package | |
251 | (inherit cmake-bootstrap) | |
252 | (name "cmake-minimal") | |
b5fc075d MB |
253 | (source (origin |
254 | (inherit (package-source cmake-bootstrap)) | |
1539af46 MB |
255 | ;; Purge CMakes bundled dependencies as they are no longer needed. |
256 | (modules '((ice-9 ftw))) | |
b5fc075d | 257 | (snippet |
1539af46 MB |
258 | `(begin |
259 | (define preserved-files ',%preserved-third-party-files) | |
260 | ||
261 | (file-system-fold (lambda (dir stat result) ;enter? | |
262 | (or (string=? "Utilities" dir) ;init | |
263 | ;; The bundled dependencies are | |
264 | ;; distinguished by having a "cm" | |
265 | ;; prefix to their upstream names. | |
266 | (and (string-prefix? "Utilities/cm" dir) | |
267 | (not (member dir preserved-files))))) | |
268 | (lambda (file stat result) ;leaf | |
269 | (unless (or (member file preserved-files) | |
270 | ;; Preserve top-level files. | |
271 | (string=? "Utilities" | |
272 | (dirname file))) | |
273 | (delete-file file))) | |
274 | (const #t) ;down | |
275 | (lambda (dir stat result) ;up | |
276 | (when (equal? (scandir dir) '("." "..")) | |
277 | (rmdir dir))) | |
278 | (const #t) ;skip | |
279 | (lambda (file stat errno result) | |
280 | (format (current-error-port) | |
281 | "warning: failed to delete ~a: ~a~%" | |
282 | file (strerror errno))) | |
283 | #t | |
284 | "Utilities" | |
285 | lstat) | |
286 | #t)))) | |
ac841750 | 287 | (inputs |
8394619b LC |
288 | (modify-inputs (package-inputs cmake-bootstrap) |
289 | (prepend jsoncpp))) | |
013c5c23 | 290 | (build-system cmake-build-system) |
b5fc075d | 291 | (arguments |
013c5c23 MB |
292 | `(#:configure-flags |
293 | (list "-DCMAKE_USE_SYSTEM_LIBRARIES=ON" | |
294 | (string-append "-DCMAKE_DOC_DIR=share/doc/cmake-" | |
295 | ,(version-major+minor (package-version | |
296 | cmake-bootstrap)))) | |
297 | ||
298 | ;; This is the CMake used in cmake-build-system. Ensure compiler | |
299 | ;; optimizations are enabled to save size and CPU cycles. | |
300 | #:build-type "Release" | |
301 | #:phases | |
302 | (modify-phases %standard-phases | |
f762d63e | 303 | ,@(%common-build-phases) |
f6dbca83 EF |
304 | (add-after 'install 'delete-help-documentation |
305 | (lambda* (#:key outputs #:allow-other-keys) | |
306 | (delete-file-recursively | |
307 | (string-append (assoc-ref outputs "out") | |
308 | "/share/cmake-" | |
309 | ,(version-major+minor | |
310 | (package-version cmake-bootstrap)) | |
311 | "/Help")) | |
312 | #t)) | |
013c5c23 MB |
313 | (replace 'check |
314 | (lambda* (#:key tests? parallel-tests? #:allow-other-keys) | |
315 | (let ((skipped-tests (list ,@%common-disabled-tests | |
316 | ;; This test requires the bundled libuv. | |
317 | "BootstrapTest"))) | |
318 | (if tests? | |
319 | (begin | |
320 | (invoke "ctest" "-j" (if parallel-tests? | |
321 | (number->string (parallel-job-count)) | |
322 | "1") | |
323 | "--exclude-regex" | |
324 | (string-append "^(" (string-join skipped-tests "|") ")$"))) | |
325 | (format #t "test suite not run~%")) | |
326 | #t)))) | |
327 | ,@(if (%current-target-system) | |
328 | '() | |
329 | `(#:cmake ,cmake-bootstrap)))))) | |
7c1ea931 MB |
330 | |
331 | ;;; The "user-facing" CMake, now with manuals and HTML documentation. | |
2f33a732 MC |
332 | (define-public cmake |
333 | (package | |
334 | (inherit cmake-minimal) | |
335 | (name "cmake") | |
76454d9a MC |
336 | (version "3.24.2") |
337 | (source (origin | |
338 | (inherit (package-source cmake-minimal)) | |
339 | (method url-fetch) | |
340 | (uri (string-append "https://cmake.org/files/v" | |
341 | (version-major+minor version) | |
342 | "/cmake-" version ".tar.gz")) | |
343 | (snippet (match (origin-snippet (package-source cmake-minimal)) | |
344 | (('begin ('define 'preserved-files ('quote x)) | |
345 | rest ...) | |
346 | `(begin (define preserved-files | |
347 | ',(cons "Utilities/cmelf" x)) | |
348 | ,@rest)))) | |
349 | (sha256 | |
350 | (base32 | |
351 | "1ny8y2dzc6fww9gzb1ml0vjpx4kclphjihkxagxigprxdzq2140d")) | |
352 | (patches (search-patches "cmake-curl-certificates-3.24.patch")))) | |
353 | (outputs '("out" "doc")) | |
2f33a732 MC |
354 | (arguments |
355 | (substitute-keyword-arguments (package-arguments cmake-minimal) | |
013c5c23 MB |
356 | ;; Use cmake-minimal this time. |
357 | ((#:cmake _ #f) | |
358 | (if (%current-target-system) | |
359 | cmake-minimal-cross | |
360 | cmake-minimal)) | |
28ba01ae MB |
361 | |
362 | ;; Enable debugging information for convenience. | |
363 | ((#:build-type _ #f) "RelWithDebInfo") | |
364 | ||
013c5c23 MB |
365 | ((#:configure-flags flags ''()) |
366 | `(append (list "-DSPHINX_INFO=ON" "-DSPHINX_MAN=ON" "-DSPHINX_HTML=ON" | |
367 | (string-append "-DCMAKE_DOC_DIR=share/doc/cmake-" | |
368 | ,(version-major+minor (package-version | |
369 | cmake-minimal))) | |
370 | "-DCMAKE_INFO_DIR=share/info" | |
371 | "-DCMAKE_MAN_DIR=share/man") | |
372 | ,flags)) | |
2f33a732 MC |
373 | ((#:phases phases) |
374 | `(modify-phases ,phases | |
f6dbca83 | 375 | (delete 'delete-help-documentation) |
2f33a732 MC |
376 | (add-after 'install 'move-html-doc |
377 | (lambda* (#:key outputs #:allow-other-keys) | |
378 | (let ((out (assoc-ref outputs "out")) | |
379 | (doc (assoc-ref outputs "doc")) | |
380 | (html (string-append "/share/doc/cmake-" | |
381 | ,(version-major+minor | |
382 | (package-version cmake-minimal)) | |
383 | "/html"))) | |
384 | (copy-recursively (string-append out html) | |
385 | (string-append doc html)) | |
6933a32b | 386 | (delete-file-recursively (string-append out html))))))))) |
8d16f302 | 387 | (inputs |
8394619b | 388 | (modify-inputs (package-inputs cmake-minimal) |
76454d9a | 389 | (prepend ncurses))) ;required for ccmake |
2f33a732 MC |
390 | ;; Extra inputs required to build the documentation. |
391 | (native-inputs | |
76454d9a MC |
392 | (modify-inputs (package-native-inputs cmake-minimal) |
393 | (append python-sphinx | |
394 | texinfo))) | |
2f33a732 MC |
395 | (properties (alist-delete 'hidden? (package-properties cmake-minimal))))) |
396 | ||
534537e2 MO |
397 | (define-public cmake-minimal-cross |
398 | (package | |
399 | (inherit cmake-minimal) | |
400 | (name "cmake-minimal-cross") | |
401 | (native-search-paths '()) | |
402 | (search-paths | |
403 | (package-native-search-paths cmake-minimal)))) | |
404 | ||
bbdf3666 OP |
405 | (define-public emacs-cmake-mode |
406 | (package | |
407 | (inherit cmake) | |
408 | (name "emacs-cmake-mode") | |
5a7c6d02 MB |
409 | (native-inputs '()) |
410 | (inputs '()) | |
411 | (outputs '("out")) | |
bbdf3666 OP |
412 | (build-system emacs-build-system) |
413 | (arguments | |
414 | `(#:phases | |
415 | (modify-phases %standard-phases | |
416 | (add-after 'unpack 'chdir-elisp | |
417 | ;; Elisp directory is not in root of the source. | |
418 | (lambda _ | |
5a7c6d02 MB |
419 | (chdir "Auxiliary") |
420 | #t))))) | |
bbdf3666 OP |
421 | (synopsis "Emacs major mode for editing Cmake expressions") |
422 | (description "@code{cmakeos-mode} provides an Emacs major mode for editing | |
423 | Cmake files. It supports syntax highlighting, indenting and refilling of | |
424 | comments."))) |