gnu: cmake: Update to 3.16.3.
[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 deprecation)
35 #:use-module (guix build-system gnu)
36 #:use-module (guix build-system emacs)
37 #:use-module (gnu packages)
38 #:use-module (gnu packages backup)
39 #:use-module (gnu packages compression)
40 #:use-module (gnu packages crypto)
41 #:use-module (gnu packages curl)
42 #:use-module (gnu packages file)
43 #:use-module (gnu packages libevent)
44 #:use-module (gnu packages ncurses)
45 #:use-module (gnu packages sphinx)
46 #:use-module (gnu packages texinfo)
47 #:use-module (gnu packages xml)
48 #:use-module (srfi srfi-1))
49
50 ;;; This minimal variant of CMake does not include the documentation. It is
51 ;;; used by the cmake-build-system.
52 (define-public cmake-minimal
53 (package
54 (name "cmake-minimal")
55 (version "3.16.3")
56 (source (origin
57 (method url-fetch)
58 (uri (string-append "https://www.cmake.org/files/v"
59 (version-major+minor version)
60 "/cmake-" version ".tar.gz"))
61 (sha256
62 (base32
63 "0s06wrp0jnw2l4yq94skj53hwnz7lqrmhh96sq7w7njkkggickz5"))
64 (modules '((guix build utils)))
65 (snippet
66 '(begin
67 ;; Drop bundled software.
68 (with-directory-excursion "Utilities"
69 (for-each delete-file-recursively
70 '("cmbzip2"
71 ;; "cmcompress"
72 "cmcurl"
73 "cmexpat"
74 ;; "cmjsoncpp"
75 ;; "cmlibarchive"
76 "cmliblzma"
77 ;; "cmlibuv"
78 "cmzlib"))
79 #t)))
80 (patches (search-patches "cmake-curl-certificates.patch"))))
81 (build-system gnu-build-system)
82 (arguments
83 `(#:test-target "test"
84 #:configure-flags
85 (let ((out (assoc-ref %outputs "out"))
86 (parallel-job-count (number->string (parallel-job-count))))
87 (list "--verbose"
88 (string-append "--parallel=" parallel-job-count)
89 (string-append "--prefix=" out)
90 "--system-libs"
91 "--no-system-jsoncpp" ; FIXME: Circular dependency.
92 ;; By default, the man pages and other docs land
93 ;; in PREFIX/man and PREFIX/doc, but we want them
94 ;; in share/{man,doc}. Note that unlike
95 ;; autoconf-generated configure scripts, cmake's
96 ;; configure prepends "PREFIX/" to what we pass
97 ;; to --mandir and --docdir.
98 "--mandir=share/man"
99 ,(string-append "--docdir=share/doc/cmake-"
100 (version-major+minor version))))
101 #:make-flags
102 (let ((skipped-tests
103 (list "BundleUtilities" ; This test fails on Guix.
104 "CTestTestSubdir" ; This test fails to build 2 of the 3 tests.
105 ;; This test requires 'ldconfig' which is not available in Guix.
106 "RunCMake.install"
107 ;; These tests requires network access.
108 "CTestCoverageCollectGCOV"
109 "CTestTestUpload")))
110 (list
111 (string-append
112 ;; These arguments apply for the tests only.
113 "ARGS=-j " (number->string (parallel-job-count))
114 " --output-on-failure"
115 " --exclude-regex ^\\(" (string-join skipped-tests "\\|") "\\)$")))
116 #:phases
117 (modify-phases %standard-phases
118 (add-after 'unpack 'split-package
119 ;; Remove files that have been packaged in other package recipes.
120 (lambda _
121 (delete-file "Auxiliary/cmake-mode.el")
122 (substitute* "Auxiliary/CMakeLists.txt"
123 ((".*cmake-mode.el.*") ""))
124 #t))
125 (add-before 'configure 'patch-bin-sh
126 (lambda _
127 ;; Replace "/bin/sh" by the right path in... a lot of
128 ;; files.
129 (substitute*
130 '("Modules/CompilerId/Xcode-3.pbxproj.in"
131 "Modules/Internal/CPack/CPack.RuntimeScript.in"
132 "Source/cmGlobalXCodeGenerator.cxx"
133 "Source/cmLocalUnixMakefileGenerator3.cxx"
134 "Source/cmExecProgramCommand.cxx"
135 "Utilities/Release/release_cmake.cmake"
136 "Utilities/cmlibarchive/libarchive/archive_write_set_format_shar.c"
137 "Tests/CMakeLists.txt"
138 "Tests/RunCMake/File_Generate/RunCMakeTest.cmake")
139 (("/bin/sh") (which "sh")))
140 #t))
141 (add-before 'configure 'set-paths
142 (lambda _
143 ;; Help cmake's bootstrap process to find system libraries
144 (begin
145 (setenv "CMAKE_LIBRARY_PATH" (getenv "LIBRARY_PATH"))
146 (setenv "CMAKE_INCLUDE_PATH" (or (getenv "CPATH")
147 (getenv "C_INCLUDE_PATH")))
148 #t)))
149 ;; CMake uses its own configure script.
150 (replace 'configure
151 (lambda* (#:key (configure-flags '()) #:allow-other-keys)
152 (apply invoke "./configure" configure-flags))))))
153 (native-inputs
154 `(("bzip2" ,bzip2)
155 ("curl" ,curl)
156 ("expat" ,expat)
157 ("file" ,file)
158 ("libarchive" ,libarchive)
159 ("libuv" ,libuv)
160 ("rhash" ,rhash)
161 ("zlib" ,zlib)))
162 (inputs
163 `(("ncurses" ,ncurses))) ; required for ccmake
164 (native-search-paths
165 (list (search-path-specification
166 (variable "CMAKE_PREFIX_PATH")
167 (files '("")))
168 ;; "cmake-curl-certificates.patch" changes CMake to honor 'SSL_CERT_DIR'
169 ;; and 'SSL_CERT_FILE', hence these search path entries.
170 (search-path-specification
171 (variable "SSL_CERT_DIR")
172 (separator #f) ;single entry
173 (files '("etc/ssl/certs")))
174 (search-path-specification
175 (variable "SSL_CERT_FILE")
176 (file-type 'regular)
177 (separator #f) ;single entry
178 (files '("etc/ssl/certs/ca-certificates.crt")))))
179 (home-page "https://cmake.org/")
180 (synopsis "Cross-platform build system")
181 (description
182 "CMake is a family of tools designed to build, test and package software.
183 CMake is used to control the software compilation process using simple platform
184 and compiler independent configuration files. CMake generates native makefiles
185 and workspaces that can be used in the compiler environment of your choice.")
186 (properties '((hidden? . #t)))
187 (license (list license:bsd-3 ; cmake
188 license:bsd-4 ; cmcompress
189 license:bsd-2 ; cmlibarchive
190 license:expat ; cmjsoncpp is dual MIT/public domain
191 license:public-domain)))) ; cmlibarchive/archive_getdate.c
192
193 (define-public cmake
194 (package
195 (inherit cmake-minimal)
196 (name "cmake")
197 (arguments
198 (substitute-keyword-arguments (package-arguments cmake-minimal)
199 ((#:configure-flags configure-flags ''())
200 `(append ,configure-flags
201 ;; Extra configure flags used to generate the documentation.
202 '("--sphinx-info"
203 "--sphinx-man"
204 "--sphinx-html")))
205 ((#:phases phases)
206 `(modify-phases ,phases
207 (add-after 'install 'move-html-doc
208 (lambda* (#:key outputs #:allow-other-keys)
209 (let ((out (assoc-ref outputs "out"))
210 (doc (assoc-ref outputs "doc"))
211 (html (string-append "/share/doc/cmake-"
212 ,(version-major+minor
213 (package-version cmake-minimal))
214 "/html")))
215 (copy-recursively (string-append out html)
216 (string-append doc html))
217 (delete-file-recursively (string-append out html))
218 #t)))))))
219 ;; Extra inputs required to build the documentation.
220 (native-inputs
221 `(,@(package-native-inputs cmake-minimal)
222 ("python-sphinx" ,python-sphinx)
223 ("texinfo" ,texinfo)))
224 (outputs '("out" "doc"))
225 (properties (alist-delete 'hidden? (package-properties cmake-minimal)))))
226
227 (define-public cmake-minimal-cross
228 (package
229 (inherit cmake-minimal)
230 (name "cmake-minimal-cross")
231 (native-search-paths '())
232 (search-paths
233 (package-native-search-paths cmake-minimal))))
234
235 (define-public emacs-cmake-mode
236 (package
237 (inherit cmake)
238 (name "emacs-cmake-mode")
239 (native-inputs '())
240 (inputs '())
241 (outputs '("out"))
242 (build-system emacs-build-system)
243 (arguments
244 `(#:phases
245 (modify-phases %standard-phases
246 (add-after 'unpack 'chdir-elisp
247 ;; Elisp directory is not in root of the source.
248 (lambda _
249 (chdir "Auxiliary")
250 #t)))))
251 (synopsis "Emacs major mode for editing Cmake expressions")
252 (description "@code{cmakeos-mode} provides an Emacs major mode for editing
253 Cmake files. It supports syntax highlighting, indenting and refilling of
254 comments.")))