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>
13 ;;; This file is part of GNU Guix.
15 ;;; GNU Guix is free software; you can redistribute it and/or modify it
16 ;;; under the terms of the GNU General Public License as published by
17 ;;; the Free Software Foundation; either version 3 of the License, or (at
18 ;;; your option) any later version.
20 ;;; GNU Guix is distributed in the hope that it will be useful, but
21 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
22 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 ;;; GNU General Public License for more details.
25 ;;; You should have received a copy of the GNU General Public License
26 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
28 (define-module (gnu packages cmake)
29 #:use-module ((guix licenses) #:prefix license:)
30 #:use-module (guix packages)
31 #:use-module (guix download)
32 #:use-module (guix utils)
33 #:use-module (guix deprecation)
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))
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
53 (name "cmake-minimal")
57 (uri (string-append "https://www.cmake.org/files/v"
58 (version-major+minor version)
59 "/cmake-" version ".tar.gz"))
62 "1xyprly3sf4wi0n1x79k4n22yxm6pb7fv70gqr9lvc7qv14cbphq"))
63 (modules '((guix build utils)))
66 ;; Drop bundled software.
67 (with-directory-excursion "Utilities"
68 (for-each delete-file-recursively
79 (build-system gnu-build-system)
81 `(#:test-target "test"
83 (let ((out (assoc-ref %outputs "out"))
84 (parallel-job-count (number->string (parallel-job-count))))
86 (string-append "--parallel=" parallel-job-count)
87 (string-append "--prefix=" out)
89 "--no-system-jsoncpp" ; FIXME: Circular dependency.
90 ;; By default, the man pages and other docs land
91 ;; in PREFIX/man and PREFIX/doc, but we want them
92 ;; in share/{man,doc}. Note that unlike
93 ;; autoconf-generated configure scripts, cmake's
94 ;; configure prepends "PREFIX/" to what we pass
95 ;; to --mandir and --docdir.
97 ,(string-append "--docdir=share/doc/cmake-"
98 (version-major+minor version))))
101 (list "BundleUtilities" ; This test fails on Guix.
102 "CTestTestSubdir" ; This test fails to build 2 of the 3 tests.
103 ;; These tests requires network access.
104 "CTestCoverageCollectGCOV"
108 ;; These arguments apply for the tests only.
109 "ARGS=-j " (number->string (parallel-job-count))
110 " --output-on-failure"
111 " --exclude-regex ^\\(" (string-join skipped-tests "\\|") "\\)$")))
113 (modify-phases %standard-phases
114 (add-after 'unpack 'split-package
115 ;; Remove files that have been packaged in other package recipes.
117 (delete-file "Auxiliary/cmake-mode.el")
118 (substitute* "Auxiliary/CMakeLists.txt"
119 ((".*cmake-mode.el.*") ""))
121 (add-before 'configure 'patch-bin-sh
123 ;; Replace "/bin/sh" by the right path in... a lot of
126 '("Modules/CompilerId/Xcode-3.pbxproj.in"
127 "Modules/CPack.RuntimeScript.in"
128 "Source/cmGlobalXCodeGenerator.cxx"
129 "Source/cmLocalUnixMakefileGenerator3.cxx"
130 "Source/cmExecProgramCommand.cxx"
131 "Utilities/Release/release_cmake.cmake"
132 "Utilities/cmlibarchive/libarchive/archive_write_set_format_shar.c"
133 "Tests/CMakeLists.txt"
134 "Tests/RunCMake/File_Generate/RunCMakeTest.cmake")
135 (("/bin/sh") (which "sh")))
137 (add-before 'configure 'set-paths
139 ;; Help cmake's bootstrap process to find system libraries
141 (setenv "CMAKE_LIBRARY_PATH" (getenv "LIBRARY_PATH"))
142 (setenv "CMAKE_INCLUDE_PATH" (or (getenv "CPATH")
143 (getenv "C_INCLUDE_PATH")))
145 ;; CMake uses its own configure script.
147 (lambda* (#:key (configure-flags '()) #:allow-other-keys)
148 (apply invoke "./configure" configure-flags))))))
154 ("libarchive" ,libarchive)
156 ("ncurses" ,ncurses) ; required for ccmake
160 (list (search-path-specification
161 (variable "CMAKE_PREFIX_PATH")
163 (home-page "https://cmake.org/")
164 (synopsis "Cross-platform build system")
166 "CMake is a family of tools designed to build, test and package software.
167 CMake is used to control the software compilation process using simple platform
168 and compiler independent configuration files. CMake generates native makefiles
169 and workspaces that can be used in the compiler environment of your choice.")
170 (properties '((hidden? . #t)))
171 (license (list license:bsd-3 ; cmake
172 license:bsd-4 ; cmcompress
173 license:bsd-2 ; cmlibarchive
174 license:expat ; cmjsoncpp is dual MIT/public domain
175 license:public-domain)))) ; cmlibarchive/archive_getdate.c
179 (inherit cmake-minimal)
182 (substitute-keyword-arguments (package-arguments cmake-minimal)
183 ((#:configure-flags configure-flags ''())
184 `(append ,configure-flags
185 ;; Extra configure flags used to generate the documentation.
190 `(modify-phases ,phases
191 (add-after 'install 'move-html-doc
192 (lambda* (#:key outputs #:allow-other-keys)
193 (let ((out (assoc-ref outputs "out"))
194 (doc (assoc-ref outputs "doc"))
195 (html (string-append "/share/doc/cmake-"
196 ,(version-major+minor
197 (package-version cmake-minimal))
199 (copy-recursively (string-append out html)
200 (string-append doc html))
201 (delete-file-recursively (string-append out html))
203 ;; Extra inputs required to build the documentation.
205 `(,@(package-native-inputs cmake-minimal)
206 ("python-sphinx" ,python-sphinx)
207 ("texinfo" ,texinfo)))
208 (outputs '("out" "doc"))
209 (properties (alist-delete 'hidden? (package-properties cmake-minimal)))))
211 (define-public cmake-3.15.5
212 ;; CMake 3.15.5 fixes some issues, but declare another version to
213 ;; avoid triggering the rebuild of all CMake-based packages.
214 ;; See <https://issues.guix.gnu.org/issue/38060>.
216 ;; Furthermore, this variant fixes X.509 certificate lookup:
217 ;; <https://issues.guix.gnu.org/issue/37371>.
222 (inherit (package-source cmake))
223 (uri (string-append "https://www.cmake.org/files/v"
224 (version-major+minor version)
225 "/cmake-" version ".tar.gz"))
228 "1d5y8d92axcc6rfqlsxamayfs3fc1vdby91hn5mx1kn02ppprpgv"))
230 (append (search-patches "cmake-curl-certificates.patch")
231 (origin-patches (package-source cmake))))))
234 ;; "cmake-curl-certificates.patch" changes CMake to honor 'SSL_CERT_DIR'
235 ;; and 'SSL_CERT_FILE', hence these search path entries.
236 (append (list (search-path-specification
237 (variable "SSL_CERT_DIR")
238 (separator #f) ;single entry
239 (files '("etc/ssl/certs")))
240 (search-path-specification
241 (variable "SSL_CERT_FILE")
243 (separator #f) ;single entry
244 (files '("etc/ssl/certs/ca-certificates.crt"))))
245 (package-native-search-paths cmake)))))
247 ;; This was cmake@3.15.1 plus "cmake-curl-certificates.patch".
248 (define-deprecated cmake/fixed cmake-3.15.5)
251 (define-public emacs-cmake-mode
254 (name "emacs-cmake-mode")
258 (build-system emacs-build-system)
261 (modify-phases %standard-phases
262 (add-after 'unpack 'chdir-elisp
263 ;; Elisp directory is not in root of the source.
267 (synopsis "Emacs major mode for editing Cmake expressions")
268 (description "@code{cmakeos-mode} provides an Emacs major mode for editing
269 Cmake files. It supports syntax highlighting, indenting and refilling of