Merge branch 'master' into core-updates
[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
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 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))
48
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
52 (package
53 (name "cmake-minimal")
54 (version "3.14.5")
55 (source (origin
56 (method url-fetch)
57 (uri (string-append "https://www.cmake.org/files/v"
58 (version-major+minor version)
59 "/cmake-" version ".tar.gz"))
60 (sha256
61 (base32
62 "01lcl6ynxfgqn09ncfz1gr24ha5pv1slk0azzaawaqrwpsgf8njh"))
63 (modules '((guix build utils)))
64 (snippet
65 '(begin
66 ;; Drop bundled software.
67 (with-directory-excursion "Utilities"
68 (for-each delete-file-recursively
69 '("cmbzip2"
70 ;; "cmcompress"
71 "cmcurl"
72 "cmexpat"
73 ;; "cmjsoncpp"
74 ;; "cmlibarchive"
75 "cmliblzma"
76 ;; "cmlibuv"
77 "cmzlib"))
78 #t)))))
79 (build-system gnu-build-system)
80 (arguments
81 `(#:test-target "test"
82 #:configure-flags
83 (let ((out (assoc-ref %outputs "out"))
84 (parallel-job-count (number->string (parallel-job-count))))
85 (list "--verbose"
86 (string-append "--parallel=" parallel-job-count)
87 (string-append "--prefix=" out)
88 "--system-libs"
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.
96 "--mandir=share/man"
97 ,(string-append "--docdir=share/doc/cmake-"
98 (version-major+minor version))))
99 #:make-flags
100 (let ((skipped-tests
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"
105 "CTestTestUpload")))
106 (list
107 (string-append
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 "\\|") "\\)$")))
112 #:phases
113 (modify-phases %standard-phases
114 (add-after 'unpack 'split-package
115 ;; Remove files that have been packaged in other package recipes.
116 (lambda _
117 (delete-file "Auxiliary/cmake-mode.el")
118 (substitute* "Auxiliary/CMakeLists.txt"
119 ((".*cmake-mode.el.*") ""))
120 #t))
121 (add-before 'configure 'patch-bin-sh
122 (lambda _
123 ;; Replace "/bin/sh" by the right path in... a lot of
124 ;; files.
125 (substitute*
126 '("Modules/CompilerId/Xcode-3.pbxproj.in"
127 "Modules/CPack.RuntimeScript.in"
128 "Source/cmakexbuild.cxx"
129 "Source/cmGlobalXCodeGenerator.cxx"
130 "Source/cmLocalUnixMakefileGenerator3.cxx"
131 "Source/cmExecProgramCommand.cxx"
132 "Utilities/Release/release_cmake.cmake"
133 "Utilities/cmlibarchive/libarchive/archive_write_set_format_shar.c"
134 "Tests/CMakeLists.txt"
135 "Tests/RunCMake/File_Generate/RunCMakeTest.cmake")
136 (("/bin/sh") (which "sh")))
137 #t))
138 (add-before 'configure 'set-paths
139 (lambda _
140 ;; Help cmake's bootstrap process to find system libraries
141 (begin
142 (setenv "CMAKE_LIBRARY_PATH" (getenv "LIBRARY_PATH"))
143 (setenv "CMAKE_INCLUDE_PATH" (or (getenv "CPATH")
144 (getenv "C_INCLUDE_PATH")))
145 #t)))
146 ;; CMake uses its own configure script.
147 (replace 'configure
148 (lambda* (#:key (configure-flags '()) #:allow-other-keys)
149 (apply invoke "./configure" configure-flags))))))
150 (inputs
151 `(("bzip2" ,bzip2)
152 ("curl" ,curl)
153 ("expat" ,expat)
154 ("file" ,file)
155 ("libarchive" ,libarchive)
156 ("libuv" ,libuv)
157 ("ncurses" ,ncurses) ; required for ccmake
158 ("rhash" ,rhash)
159 ("zlib" ,zlib)))
160 (native-search-paths
161 (list (search-path-specification
162 (variable "CMAKE_PREFIX_PATH")
163 (files '("")))))
164 (home-page "https://cmake.org/")
165 (synopsis "Cross-platform build system")
166 (description
167 "CMake is a family of tools designed to build, test and package software.
168 CMake is used to control the software compilation process using simple platform
169 and compiler independent configuration files. CMake generates native makefiles
170 and workspaces that can be used in the compiler environment of your choice.")
171 (properties '((hidden? . #t)))
172 (license (list license:bsd-3 ; cmake
173 license:bsd-4 ; cmcompress
174 license:bsd-2 ; cmlibarchive
175 license:expat ; cmjsoncpp is dual MIT/public domain
176 license:public-domain)))) ; cmlibarchive/archive_getdate.c
177
178 (define-public cmake
179 (package
180 (inherit cmake-minimal)
181 (name "cmake")
182 (arguments
183 (substitute-keyword-arguments (package-arguments cmake-minimal)
184 ((#:configure-flags configure-flags ''())
185 `(append ,configure-flags
186 ;; Extra configure flags used to generate the documentation.
187 '("--sphinx-info"
188 "--sphinx-man"
189 "--sphinx-html")))
190 ((#:phases phases)
191 `(modify-phases ,phases
192 (add-after 'install 'move-html-doc
193 (lambda* (#:key outputs #:allow-other-keys)
194 (let ((out (assoc-ref outputs "out"))
195 (doc (assoc-ref outputs "doc"))
196 (html (string-append "/share/doc/cmake-"
197 ,(version-major+minor
198 (package-version cmake-minimal))
199 "/html")))
200 (copy-recursively (string-append out html)
201 (string-append doc html))
202 (delete-file-recursively (string-append out html))
203 #t)))))))
204 ;; Extra inputs required to build the documentation.
205 (native-inputs
206 `(,@(package-native-inputs cmake-minimal)
207 ("python-sphinx" ,python-sphinx)
208 ("texinfo" ,texinfo)))
209 (outputs '("out" "doc"))
210 (properties (alist-delete 'hidden? (package-properties cmake-minimal)))))
211
212 (define-public emacs-cmake-mode
213 (package
214 (inherit cmake)
215 (name "emacs-cmake-mode")
216 (build-system emacs-build-system)
217 (arguments
218 `(#:phases
219 (modify-phases %standard-phases
220 (add-after 'unpack 'chdir-elisp
221 ;; Elisp directory is not in root of the source.
222 (lambda _
223 (chdir "Auxiliary"))))))
224 (synopsis "Emacs major mode for editing Cmake expressions")
225 (description "@code{cmakeos-mode} provides an Emacs major mode for editing
226 Cmake files. It supports syntax highlighting, indenting and refilling of
227 comments.")))