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>
14 ;;; This file is part of GNU Guix.
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.
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.
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/>.
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))
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
54 (name "cmake-minimal")
58 (uri (string-append "https://www.cmake.org/files/v"
59 (version-major+minor version)
60 "/cmake-" version ".tar.gz"))
63 "0s06wrp0jnw2l4yq94skj53hwnz7lqrmhh96sq7w7njkkggickz5"))
64 (modules '((guix build utils)))
67 ;; Drop bundled software.
68 (with-directory-excursion "Utilities"
69 (for-each delete-file-recursively
80 (patches (search-patches "cmake-curl-certificates.patch"))))
81 (build-system gnu-build-system)
83 `(#:test-target "test"
85 (let ((out (assoc-ref %outputs "out"))
86 (parallel-job-count (number->string (parallel-job-count))))
88 (string-append "--parallel=" parallel-job-count)
89 (string-append "--prefix=" out)
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.
99 ,(string-append "--docdir=share/doc/cmake-"
100 (version-major+minor version))))
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.
107 ;; These tests requires network access.
108 "CTestCoverageCollectGCOV"
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 "\\|") "\\)$")))
117 (modify-phases %standard-phases
118 (add-after 'unpack 'split-package
119 ;; Remove files that have been packaged in other package recipes.
121 (delete-file "Auxiliary/cmake-mode.el")
122 (substitute* "Auxiliary/CMakeLists.txt"
123 ((".*cmake-mode.el.*") ""))
125 (add-before 'configure 'patch-bin-sh
127 ;; Replace "/bin/sh" by the right path in... a lot of
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")))
141 (add-before 'configure 'set-paths
143 ;; Help cmake's bootstrap process to find system libraries
145 (setenv "CMAKE_LIBRARY_PATH" (getenv "LIBRARY_PATH"))
146 (setenv "CMAKE_INCLUDE_PATH" (or (getenv "CPATH")
147 (getenv "C_INCLUDE_PATH")))
149 ;; CMake uses its own configure script.
151 (lambda* (#:key (configure-flags '()) #:allow-other-keys)
152 (apply invoke "./configure" configure-flags))))))
158 ("libarchive" ,libarchive)
163 `(("ncurses" ,ncurses))) ; required for ccmake
165 (list (search-path-specification
166 (variable "CMAKE_PREFIX_PATH")
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")
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")
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
195 (inherit cmake-minimal)
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.
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))
215 (copy-recursively (string-append out html)
216 (string-append doc html))
217 (delete-file-recursively (string-append out html))
219 ;; Extra inputs required to build the documentation.
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)))))
227 (define-public cmake-minimal-cross
229 (inherit cmake-minimal)
230 (name "cmake-minimal-cross")
231 (native-search-paths '())
233 (package-native-search-paths cmake-minimal))))
235 (define-public emacs-cmake-mode
238 (name "emacs-cmake-mode")
242 (build-system emacs-build-system)
245 (modify-phases %standard-phases
246 (add-after 'unpack 'chdir-elisp
247 ;; Elisp directory is not in root of the source.
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