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 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 "0pwcgvk75577rdizpzjrk2n43a6l7rvfhmhn7sd6xarwqrb6b9bd"))
63 (modules '((guix build utils)))
66 ;; Drop bundled software.
67 (with-directory-excursion "Utilities"
68 (for-each delete-file-recursively
79 (patches (search-patches "cmake-curl-certificates.patch"))))
80 (build-system gnu-build-system)
82 `(#:test-target "test"
84 (let ((out (assoc-ref %outputs "out"))
85 (parallel-job-count (number->string (parallel-job-count))))
87 (string-append "--parallel=" parallel-job-count)
88 (string-append "--prefix=" out)
90 "--no-system-jsoncpp" ; FIXME: Circular dependency.
91 ;; By default, the man pages and other docs land
92 ;; in PREFIX/man and PREFIX/doc, but we want them
93 ;; in share/{man,doc}. Note that unlike
94 ;; autoconf-generated configure scripts, cmake's
95 ;; configure prepends "PREFIX/" to what we pass
96 ;; to --mandir and --docdir.
98 ,(string-append "--docdir=share/doc/cmake-"
99 (version-major+minor version))))
102 (list "BundleUtilities" ; This test fails on Guix.
103 "CTestTestSubdir" ; This test fails to build 2 of the 3 tests.
104 ;; This test requires 'ldconfig' which is not available in Guix.
106 ;; These tests requires network access.
107 "CTestCoverageCollectGCOV"
111 ;; These arguments apply for the tests only.
112 "ARGS=-j " (number->string (parallel-job-count))
113 " --output-on-failure"
114 " --exclude-regex ^\\(" (string-join skipped-tests "\\|") "\\)$")))
116 (modify-phases %standard-phases
117 (add-after 'unpack 'split-package
118 ;; Remove files that have been packaged in other package recipes.
120 (delete-file "Auxiliary/cmake-mode.el")
121 (substitute* "Auxiliary/CMakeLists.txt"
122 ((".*cmake-mode.el.*") ""))
124 (add-before 'configure 'patch-bin-sh
126 ;; Replace "/bin/sh" by the right path in... a lot of
129 '("Modules/CompilerId/Xcode-3.pbxproj.in"
130 "Modules/Internal/CPack/CPack.RuntimeScript.in"
131 "Source/cmGlobalXCodeGenerator.cxx"
132 "Source/cmLocalUnixMakefileGenerator3.cxx"
133 "Source/cmExecProgramCommand.cxx"
134 "Utilities/Release/release_cmake.cmake"
135 "Utilities/cmlibarchive/libarchive/archive_write_set_format_shar.c"
136 "Tests/CMakeLists.txt"
137 "Tests/RunCMake/File_Generate/RunCMakeTest.cmake")
138 (("/bin/sh") (which "sh")))
140 (add-before 'configure 'set-paths
142 ;; Help cmake's bootstrap process to find system libraries
144 (setenv "CMAKE_LIBRARY_PATH" (getenv "LIBRARY_PATH"))
145 (setenv "CMAKE_INCLUDE_PATH" (or (getenv "CPATH")
146 (getenv "C_INCLUDE_PATH")))
148 ;; CMake uses its own configure script.
150 (lambda* (#:key (configure-flags '()) #:allow-other-keys)
151 (apply invoke "./configure" configure-flags))))))
157 ("libarchive" ,libarchive)
162 `(("ncurses" ,ncurses))) ; required for ccmake
164 (list (search-path-specification
165 (variable "CMAKE_PREFIX_PATH")
167 (home-page "https://cmake.org/")
168 (synopsis "Cross-platform build system")
170 "CMake is a family of tools designed to build, test and package software.
171 CMake is used to control the software compilation process using simple platform
172 and compiler independent configuration files. CMake generates native makefiles
173 and workspaces that can be used in the compiler environment of your choice.")
174 (properties '((hidden? . #t)))
175 (license (list license:bsd-3 ; cmake
176 license:bsd-4 ; cmcompress
177 license:bsd-2 ; cmlibarchive
178 license:expat ; cmjsoncpp is dual MIT/public domain
179 license:public-domain)))) ; cmlibarchive/archive_getdate.c
183 (inherit cmake-minimal)
186 (substitute-keyword-arguments (package-arguments cmake-minimal)
187 ((#:configure-flags configure-flags ''())
188 `(append ,configure-flags
189 ;; Extra configure flags used to generate the documentation.
194 `(modify-phases ,phases
195 (add-after 'install 'move-html-doc
196 (lambda* (#:key outputs #:allow-other-keys)
197 (let ((out (assoc-ref outputs "out"))
198 (doc (assoc-ref outputs "doc"))
199 (html (string-append "/share/doc/cmake-"
200 ,(version-major+minor
201 (package-version cmake-minimal))
203 (copy-recursively (string-append out html)
204 (string-append doc html))
205 (delete-file-recursively (string-append out html))
207 ;; Extra inputs required to build the documentation.
209 `(,@(package-native-inputs cmake-minimal)
210 ("python-sphinx" ,python-sphinx)
211 ("texinfo" ,texinfo)))
212 (outputs '("out" "doc"))
213 (properties (alist-delete 'hidden? (package-properties cmake-minimal)))))
215 (define-public cmake-minimal-cross
217 (inherit cmake-minimal)
218 (name "cmake-minimal-cross")
219 (native-search-paths '())
221 (package-native-search-paths cmake-minimal))))
223 (define-public emacs-cmake-mode
226 (name "emacs-cmake-mode")
230 (build-system emacs-build-system)
233 (modify-phases %standard-phases
234 (add-after 'unpack 'chdir-elisp
235 ;; Elisp directory is not in root of the source.
239 (synopsis "Emacs major mode for editing Cmake expressions")
240 (description "@code{cmakeos-mode} provides an Emacs major mode for editing
241 Cmake files. It supports syntax highlighting, indenting and refilling of