gnu: icecat: Update to 78.10.0-guix0-preview1 [security fixes].
[jackhill/guix/guix.git] / gnu / packages / cmake.scm
CommitLineData
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>
40e96a4f 10;;; Copyright © 2018, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
54586483 11;;; Copyright © 2019, 2020 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)
79389ac3 34 #:use-module (guix git-download)
29a7c98a 35 #:use-module (guix utils)
0de28f9e 36 #:use-module (guix deprecation)
b6a64843 37 #:use-module (guix build-system gnu)
013c5c23 38 #:use-module (guix build-system cmake)
aa4818c3 39 #:use-module (guix build-system emacs)
b6a64843 40 #:use-module (gnu packages)
c824d34f
EB
41 #:use-module (gnu packages backup)
42 #:use-module (gnu packages compression)
1568cc14 43 #:use-module (gnu packages crypto)
c824d34f 44 #:use-module (gnu packages curl)
6212b8e5 45 #:use-module (gnu packages file)
a7c3c5dc 46 #:use-module (gnu packages hurd)
79389ac3 47 #:use-module (gnu packages kde-frameworks)
4bbb7d48 48 #:use-module (gnu packages libevent)
21e5e1e0 49 #:use-module (gnu packages ncurses)
b5fc075d 50 #:use-module (gnu packages serialization)
57df83e0 51 #:use-module (gnu packages sphinx)
2f33a732
MC
52 #:use-module (gnu packages texinfo)
53 #:use-module (gnu packages xml)
b5fc075d 54 #:use-module (ice-9 match)
2f33a732 55 #:use-module (srfi srfi-1))
b6a64843 56
79389ac3 57(define-public cmake-shared
8bd0632a
RG
58 (let ((commit "8122f2b96c8da38ea41b653cf69958e75fe2129d")
59 (revision "32"))
60 (package
61 (name "cmake-shared")
62 (version
63 (git-version "1.1.0" revision commit))
64 (source
65 (origin
66 (method git-fetch)
67 (uri
68 (git-reference
69 (url "https://github.com/lirios/cmake-shared.git")
70 (commit commit)))
71 (file-name
72 (git-file-name name version))
73 (sha256
74 (base32 "05avwzqcnliwx9h7qi1kl0iz4smqmxc4vkavyjbmlc6h2b97i58g"))
75 (modules '((guix build utils)
76 (ice-9 ftw)
77 (srfi srfi-1)))
78 (snippet
79 `(begin
80 (delete-file-recursively "3rdparty")))))
81 (build-system cmake-build-system)
82 (arguments
83 `(#:tests? #f)) ; No target
84 (native-inputs
85 `(("extra-cmake-modules" ,extra-cmake-modules)))
86 (synopsis "Shared CMake functions and macros")
87 (description "CMake-Shared are shared functions and macros for projects
79389ac3 88using the CMake build system.")
8bd0632a
RG
89 (home-page "https://github.com/lirios/cmake-shared/")
90 (license license:bsd-3))))
79389ac3 91
013c5c23
MB
92;;; Build phases shared between 'cmake-bootstrap' and the later variants
93;;; that use cmake-build-system.
94(define %common-build-phases
95 `((add-after 'unpack 'split-package
96 ;; Remove files that have been packaged in other package recipes.
97 (lambda _
98 (delete-file "Auxiliary/cmake-mode.el")
99 (substitute* "Auxiliary/CMakeLists.txt"
100 ((".*cmake-mode.el.*") ""))
101 #t))
013c5c23
MB
102 (add-before 'configure 'patch-bin-sh
103 (lambda _
104 ;; Replace "/bin/sh" by the right path in... a lot of
105 ;; files.
106 (substitute*
107 '("Modules/CompilerId/Xcode-3.pbxproj.in"
108 "Modules/Internal/CPack/CPack.RuntimeScript.in"
109 "Source/cmGlobalXCodeGenerator.cxx"
110 "Source/cmLocalUnixMakefileGenerator3.cxx"
111 "Source/cmExecProgramCommand.cxx"
112 "Utilities/Release/release_cmake.cmake"
113 "Tests/CMakeLists.txt"
114 "Tests/RunCMake/File_Generate/RunCMakeTest.cmake")
115 (("/bin/sh") (which "sh")))
116 #t))))
117
118(define %common-disabled-tests
119 '(;; This test copies libgcc_s.so.1 from GCC and tries to modify its RPATH,
120 ;; but does not cope with the file being read-only.
121 "BundleUtilities"
122 ;; This test requires network access.
123 "CTestTestUpload"
124 ;; This test requires 'ldconfig' which is not available in Guix.
125 "RunCMake.install"))
126
f9dcc39a
MB
127(define %preserved-third-party-files
128 '(;; 'Source/cm_getdate.c' includes archive_getdate.c wholesale, so it must
129 ;; be available along with the required headers.
130 "Utilities/cmlibarchive/libarchive/archive_getdate.c"
131 "Utilities/cmlibarchive/libarchive/archive_getdate.h"))
132
013c5c23
MB
133;;; The "bootstrap" CMake. It is used to build 'cmake-minimal' below, as well
134;;; as any dependencies that need cmake-build-system.
7c1ea931 135(define-public cmake-bootstrap
b6a64843 136 (package
7c1ea931 137 (name "cmake-bootstrap")
aca00b0a 138 (version "3.16.5")
b6a64843 139 (source (origin
12420c80 140 (method url-fetch)
b8515f72 141 (uri (string-append "https://cmake.org/files/v"
12420c80
AI
142 (version-major+minor version)
143 "/cmake-" version ".tar.gz"))
144 (sha256
145 (base32
aca00b0a 146 "1z4bb8z6b4dvq5hrvajrf1hyybqay3xybyimf71w1jgcp180nxjz"))
ed24dda7
MB
147 (modules '((guix build utils)
148 (ice-9 ftw)))
12420c80 149 (snippet
f9dcc39a
MB
150 `(begin
151 ;; CMake bundles its dependencies in the "Utilities" directory.
152 ;; Delete those to ensure the system libraries are used.
153 (define preserved-files
154 '(,@%preserved-third-party-files
155 ;; Use the bundled JsonCpp during bootstrap to work around
156 ;; a circular dependency. TODO: JsonCpp can be built with
157 ;; Meson instead of CMake, but meson-build-system currently
158 ;; does not support cross-compilation.
159 "Utilities/cmjsoncpp"
160 ;; LibUV is required to bootstrap the initial build system.
161 "Utilities/cmlibuv"))
ed24dda7 162
f9dcc39a
MB
163 (file-system-fold (lambda (dir stat result) ;enter?
164 (or (string=? "Utilities" dir) ;init
165 ;; The bundled dependencies are
166 ;; distinguished by having a "cm"
167 ;; prefix to their upstream names.
168 (and (string-prefix? "Utilities/cm" dir)
169 (not (member dir preserved-files)))))
170 (lambda (file stat result) ;leaf
171 (unless (or (member file preserved-files)
172 ;; Preserve top-level files.
173 (string=? "Utilities"
174 (dirname file)))
175 (delete-file file)))
176 (const #t) ;down
177 (lambda (dir stat result) ;up
178 (when (equal? (scandir dir) '("." ".."))
179 (rmdir dir)))
180 (const #t) ;skip
181 (lambda (file stat errno result)
182 (format (current-error-port)
183 "warning: failed to delete ~a: ~a~%"
184 file (strerror errno)))
185 #t
186 "Utilities"
187 lstat)
ed24dda7 188 #t))
a4de5cfd 189 (patches (search-patches "cmake-curl-certificates.patch"))))
b6a64843
CR
190 (build-system gnu-build-system)
191 (arguments
6212b8e5 192 `(#:test-target "test"
2f33a732
MC
193 #:configure-flags
194 (let ((out (assoc-ref %outputs "out"))
195 (parallel-job-count (number->string (parallel-job-count))))
196 (list "--verbose"
197 (string-append "--parallel=" parallel-job-count)
198 (string-append "--prefix=" out)
199 "--system-libs"
b5fc075d 200 "--no-system-jsoncpp"
2f33a732
MC
201 ;; By default, the man pages and other docs land
202 ;; in PREFIX/man and PREFIX/doc, but we want them
203 ;; in share/{man,doc}. Note that unlike
204 ;; autoconf-generated configure scripts, cmake's
205 ;; configure prepends "PREFIX/" to what we pass
206 ;; to --mandir and --docdir.
207 "--mandir=share/man"
208 ,(string-append "--docdir=share/doc/cmake-"
fa8e0a53
MB
209 (version-major+minor version))
210
211 ;; By default CMake is built without any optimizations. Use
212 ;; the recommended Release target for a ~2.5x speedup.
213 "--" "-DCMAKE_BUILD_TYPE=Release"))
89db6c6d
AI
214 #:make-flags
215 (let ((skipped-tests
013c5c23 216 (list ,@%common-disabled-tests
89db6c6d 217 "CTestTestSubdir" ; This test fails to build 2 of the 3 tests.
013c5c23
MB
218 ;; This test fails when ARGS (below) is in use, see
219 ;; <https://gitlab.kitware.com/cmake/cmake/issues/17165>.
220 "CTestCoverageCollectGCOV")))
89db6c6d
AI
221 (list
222 (string-append
12cb6c31
MB
223 ;; These arguments apply for the tests only.
224 "ARGS=-j " (number->string (parallel-job-count))
225 " --output-on-failure"
226 " --exclude-regex ^\\(" (string-join skipped-tests "\\|") "\\)$")))
6e261af1
EF
227 #:phases
228 (modify-phases %standard-phases
013c5c23 229 ,@%common-build-phases
6e261af1
EF
230 (add-before 'configure 'set-paths
231 (lambda _
232 ;; Help cmake's bootstrap process to find system libraries
233 (begin
234 (setenv "CMAKE_LIBRARY_PATH" (getenv "LIBRARY_PATH"))
546bee40
MB
235 (setenv "CMAKE_INCLUDE_PATH" (or (getenv "CPATH")
236 (getenv "C_INCLUDE_PATH")))
4bbb7d48 237 #t)))
2f33a732 238 ;; CMake uses its own configure script.
6e261af1 239 (replace 'configure
2f33a732
MC
240 (lambda* (#:key (configure-flags '()) #:allow-other-keys)
241 (apply invoke "./configure" configure-flags))))))
ac841750 242 (inputs
89db6c6d 243 `(("bzip2" ,bzip2)
7c1ea931 244 ("curl" ,curl-minimal)
89db6c6d
AI
245 ("expat" ,expat)
246 ("file" ,file)
247 ("libarchive" ,libarchive)
a7c3c5dc
JN
248 ,@(if (hurd-target?)
249 '()
250 `(("libuv" ,libuv))) ;not supported on the Hurd
ac841750 251 ("ncurses" ,ncurses) ;required for ccmake
89db6c6d
AI
252 ("rhash" ,rhash)
253 ("zlib" ,zlib)))
0d6f9360
AE
254 (native-search-paths
255 (list (search-path-specification
89db6c6d 256 (variable "CMAKE_PREFIX_PATH")
3cfe76be
MB
257 (files '("")))
258 ;; "cmake-curl-certificates.patch" changes CMake to honor 'SSL_CERT_DIR'
259 ;; and 'SSL_CERT_FILE', hence these search path entries.
260 (search-path-specification
261 (variable "SSL_CERT_DIR")
262 (separator #f) ;single entry
263 (files '("etc/ssl/certs")))
264 (search-path-specification
265 (variable "SSL_CERT_FILE")
266 (file-type 'regular)
267 (separator #f) ;single entry
268 (files '("etc/ssl/certs/ca-certificates.crt")))))
89db6c6d 269 (home-page "https://cmake.org/")
749b90a5 270 (synopsis "Cross-platform build system")
b6a64843
CR
271 (description
272 "CMake is a family of tools designed to build, test and package software.
273CMake is used to control the software compilation process using simple platform
c824d34f 274and compiler independent configuration files. CMake generates native makefiles
b6a64843 275and workspaces that can be used in the compiler environment of your choice.")
2f33a732
MC
276 (properties '((hidden? . #t)))
277 (license (list license:bsd-3 ; cmake
2f33a732 278 license:expat ; cmjsoncpp is dual MIT/public domain
db909bf2 279 license:public-domain)))) ; cmlibarchive/archive_getdate.c
1568cc14 280
7c1ea931
MB
281;;; This minimal variant of CMake does not include the documentation. It is
282;;; used by the cmake-build-system.
283(define-public cmake-minimal
284 (package
285 (inherit cmake-bootstrap)
286 (name "cmake-minimal")
b5fc075d
MB
287 (source (origin
288 (inherit (package-source cmake-bootstrap))
289 (snippet
290 (match (origin-snippet (package-source cmake-bootstrap))
f9dcc39a 291 ((_ _ exp ...)
11f4d877 292 ;; Now we can delete the remaining software bundles.
f9dcc39a
MB
293 (append `(begin
294 (define preserved-files ',%preserved-third-party-files))
b5fc075d 295 exp))))))
ac841750 296 (inputs
7c1ea931 297 `(("curl" ,curl)
b5fc075d 298 ("jsoncpp" ,jsoncpp)
ac841750 299 ,@(alist-delete "curl" (package-inputs cmake-bootstrap))))
013c5c23 300 (build-system cmake-build-system)
b5fc075d 301 (arguments
013c5c23
MB
302 `(#:configure-flags
303 (list "-DCMAKE_USE_SYSTEM_LIBRARIES=ON"
304 (string-append "-DCMAKE_DOC_DIR=share/doc/cmake-"
305 ,(version-major+minor (package-version
306 cmake-bootstrap))))
307
308 ;; This is the CMake used in cmake-build-system. Ensure compiler
309 ;; optimizations are enabled to save size and CPU cycles.
310 #:build-type "Release"
311 #:phases
312 (modify-phases %standard-phases
313 ,@%common-build-phases
314 (replace 'check
315 (lambda* (#:key tests? parallel-tests? #:allow-other-keys)
316 (let ((skipped-tests (list ,@%common-disabled-tests
317 ;; This test requires the bundled libuv.
318 "BootstrapTest")))
319 (if tests?
320 (begin
321 (invoke "ctest" "-j" (if parallel-tests?
322 (number->string (parallel-job-count))
323 "1")
324 "--exclude-regex"
325 (string-append "^(" (string-join skipped-tests "|") ")$")))
326 (format #t "test suite not run~%"))
327 #t))))
328 ,@(if (%current-target-system)
329 '()
330 `(#:cmake ,cmake-bootstrap))))))
7c1ea931
MB
331
332;;; The "user-facing" CMake, now with manuals and HTML documentation.
2f33a732
MC
333(define-public cmake
334 (package
335 (inherit cmake-minimal)
336 (name "cmake")
4969b51d 337 (version "3.19.2")
54586483
MC
338 ;; TODO: Move the following source field to the cmake-bootstrap package in
339 ;; the next rebuild cycle.
340 (source (origin
341 (inherit (package-source cmake-bootstrap))
342 (uri (string-append "https://cmake.org/files/v"
343 (version-major+minor version)
344 "/cmake-" version ".tar.gz"))
345 (sha256
346 (base32
4969b51d 347 "1w67w0ak6vf37501dlz9yhnzlvvpw1w10n2nm3hi7yxp4cxzvq73"))
54586483
MC
348 (snippet
349 (match (origin-snippet (package-source cmake-bootstrap))
350 ((_ _ exp ...)
351 ;; Now we can delete the remaining software bundles.
352 (append `(begin
353 (define preserved-files
354 '(,@%preserved-third-party-files
355 ;; TODO: Move this file to the
356 ;; %preserved-third-party-files variable in
357 ;; the next rebuild cycle.
358 "Utilities/cm3p" ;CMake header wrappers
359 ;; Use the bundled JsonCpp during bootstrap
360 ;; to work around a circular dependency.
361 ;; TODO: JsonCpp can be built with Meson
362 ;; instead of CMake, but meson-build-system
363 ;; currently does not support
364 ;; cross-compilation.
365 "Utilities/cmjsoncpp"
366 ;; LibUV is required to bootstrap the initial
367 ;; build system.
368 "Utilities/cmlibuv")))
369 exp))))))
2f33a732
MC
370 (arguments
371 (substitute-keyword-arguments (package-arguments cmake-minimal)
013c5c23
MB
372 ;; Use cmake-minimal this time.
373 ((#:cmake _ #f)
374 (if (%current-target-system)
375 cmake-minimal-cross
376 cmake-minimal))
28ba01ae
MB
377
378 ;; Enable debugging information for convenience.
379 ((#:build-type _ #f) "RelWithDebInfo")
380
013c5c23
MB
381 ((#:configure-flags flags ''())
382 `(append (list "-DSPHINX_INFO=ON" "-DSPHINX_MAN=ON" "-DSPHINX_HTML=ON"
383 (string-append "-DCMAKE_DOC_DIR=share/doc/cmake-"
384 ,(version-major+minor (package-version
385 cmake-minimal)))
386 "-DCMAKE_INFO_DIR=share/info"
387 "-DCMAKE_MAN_DIR=share/man")
388 ,flags))
2f33a732
MC
389 ((#:phases phases)
390 `(modify-phases ,phases
54586483
MC
391 ;; TODO: Remove this override in the next rebuild cycle and adjust
392 ;; the %common-build-phases variable instead: the
393 ;; Utilities/Release/release_cmake.cmake file no longer exists in
394 ;; version 3.19.0.
395 (replace 'patch-bin-sh
396 (lambda _
397 ;; Replace "/bin/sh" by the right path in... a lot of
398 ;; files.
399 (substitute*
400 '("Modules/CompilerId/Xcode-3.pbxproj.in"
401 "Modules/Internal/CPack/CPack.RuntimeScript.in"
402 "Source/cmGlobalXCodeGenerator.cxx"
403 "Source/cmLocalUnixMakefileGenerator3.cxx"
404 "Source/cmExecProgramCommand.cxx"
405 "Tests/CMakeLists.txt"
406 "Tests/RunCMake/File_Generate/RunCMakeTest.cmake")
407 (("/bin/sh") (which "sh")))
408 #t))
409 ;; TODO: Remove this override in the next rebuild cycle and adjust
410 ;; the %common-disabled-tests variable instead.
411 (replace 'check
412 (lambda* (#:key tests? parallel-tests? #:allow-other-keys)
413 (let ((skipped-tests (list ,@%common-disabled-tests
414 ;; This test fails for unknown reason.
415 "RunCMake.file-GET_RUNTIME_DEPENDENCIES"
416 ;; This test requires the bundled libuv.
417 "BootstrapTest")))
418 (if tests?
419 (begin
420 (invoke "ctest" "-j" (if parallel-tests?
421 (number->string (parallel-job-count))
422 "1")
423 "--exclude-regex"
424 (string-append "^(" (string-join skipped-tests "|") ")$")))
425 (format #t "test suite not run~%"))
426 #t)))
2f33a732
MC
427 (add-after 'install 'move-html-doc
428 (lambda* (#:key outputs #:allow-other-keys)
429 (let ((out (assoc-ref outputs "out"))
430 (doc (assoc-ref outputs "doc"))
431 (html (string-append "/share/doc/cmake-"
432 ,(version-major+minor
433 (package-version cmake-minimal))
434 "/html")))
435 (copy-recursively (string-append out html)
436 (string-append doc html))
437 (delete-file-recursively (string-append out html))
438 #t)))))))
439 ;; Extra inputs required to build the documentation.
440 (native-inputs
441 `(,@(package-native-inputs cmake-minimal)
442 ("python-sphinx" ,python-sphinx)
443 ("texinfo" ,texinfo)))
444 (outputs '("out" "doc"))
445 (properties (alist-delete 'hidden? (package-properties cmake-minimal)))))
446
534537e2
MO
447(define-public cmake-minimal-cross
448 (package
449 (inherit cmake-minimal)
450 (name "cmake-minimal-cross")
451 (native-search-paths '())
452 (search-paths
453 (package-native-search-paths cmake-minimal))))
454
bbdf3666
OP
455(define-public emacs-cmake-mode
456 (package
457 (inherit cmake)
458 (name "emacs-cmake-mode")
5a7c6d02
MB
459 (native-inputs '())
460 (inputs '())
461 (outputs '("out"))
bbdf3666
OP
462 (build-system emacs-build-system)
463 (arguments
464 `(#:phases
465 (modify-phases %standard-phases
466 (add-after 'unpack 'chdir-elisp
467 ;; Elisp directory is not in root of the source.
468 (lambda _
5a7c6d02
MB
469 (chdir "Auxiliary")
470 #t)))))
bbdf3666
OP
471 (synopsis "Emacs major mode for editing Cmake expressions")
472 (description "@code{cmakeos-mode} provides an Emacs major mode for editing
473Cmake files. It supports syntax highlighting, indenting and refilling of
474comments.")))