Merge remote-tracking branch 'origin/master' into wip-texlive
[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 ;;;
12 ;;; This file is part of GNU Guix.
13 ;;;
14 ;;; GNU Guix is free software; you can redistribute it and/or modify it
15 ;;; under the terms of the GNU General Public License as published by
16 ;;; the Free Software Foundation; either version 3 of the License, or (at
17 ;;; your option) any later version.
18 ;;;
19 ;;; GNU Guix is distributed in the hope that it will be useful, but
20 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 ;;; GNU General Public License for more details.
23 ;;;
24 ;;; You should have received a copy of the GNU General Public License
25 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
26
27 (define-module (gnu packages cmake)
28 #:use-module ((guix licenses) #:prefix license:)
29 #:use-module (guix packages)
30 #:use-module (guix download)
31 #:use-module (guix utils)
32 #:use-module (guix build-system gnu)
33 #:use-module (guix build-system emacs)
34 #:use-module (gnu packages)
35 #:use-module (gnu packages backup)
36 #:use-module (gnu packages compression)
37 #:use-module (gnu packages crypto)
38 #:use-module (gnu packages curl)
39 #:use-module (gnu packages file)
40 #:use-module (gnu packages libevent)
41 #:use-module (gnu packages ncurses)
42 #:use-module (gnu packages xml))
43
44 (define-public cmake
45 (package
46 (name "cmake")
47 (version "3.13.1")
48 (source (origin
49 (method url-fetch)
50 (uri (string-append "https://www.cmake.org/files/v"
51 (version-major+minor version)
52 "/cmake-" version ".tar.gz"))
53 (sha256
54 (base32
55 "04123d7fgnn1fs5p0nwyq397ss89r0y4wkg9a09qiwkjsvk1rzmy"))
56 (modules '((guix build utils)))
57 (snippet
58 '(begin
59 ;; Drop bundled software.
60 (with-directory-excursion "Utilities"
61 (for-each delete-file-recursively
62 '("cmbzip2"
63 ;; "cmcompress"
64 "cmcurl"
65 "cmexpat"
66 ;; "cmjsoncpp"
67 ;; "cmlibarchive"
68 "cmliblzma"
69 ;; "cmlibuv"
70 "cmzlib"))
71 #t)))))
72 (build-system gnu-build-system)
73 (arguments
74 `(#:test-target "test"
75 #:make-flags
76 (let ((skipped-tests
77 (list "BundleUtilities" ; This test fails on Guix.
78 "CTestTestSubdir" ; This test fails to build 2 of the 3 tests.
79 ;; These tests requires network access.
80 "CTestCoverageCollectGCOV"
81 "CTestTestUpload")))
82 (list
83 (string-append
84 ;; These arguments apply for the tests only.
85 "ARGS=-j " (number->string (parallel-job-count))
86 " --output-on-failure"
87 " --exclude-regex ^\\(" (string-join skipped-tests "\\|") "\\)$")))
88 #:phases
89 (modify-phases %standard-phases
90 (add-after 'unpack 'split-package
91 ;; Remove files that have been packaged in other package recipes.
92 (lambda _
93 (delete-file "Auxiliary/cmake-mode.el")
94 (substitute* "Auxiliary/CMakeLists.txt"
95 ((".*cmake-mode.el.*") ""))
96 #t))
97 (add-before 'configure 'patch-bin-sh
98 (lambda _
99 ;; Replace "/bin/sh" by the right path in... a lot of
100 ;; files.
101 (substitute*
102 '("Modules/CompilerId/Xcode-3.pbxproj.in"
103 "Modules/CPack.RuntimeScript.in"
104 "Source/cmakexbuild.cxx"
105 "Source/cmGlobalXCodeGenerator.cxx"
106 "Source/cmLocalUnixMakefileGenerator3.cxx"
107 "Source/cmExecProgramCommand.cxx"
108 "Utilities/Release/release_cmake.cmake"
109 "Utilities/cmlibarchive/libarchive/archive_write_set_format_shar.c"
110 "Tests/CMakeLists.txt"
111 "Tests/RunCMake/File_Generate/RunCMakeTest.cmake")
112 (("/bin/sh") (which "sh")))
113 #t))
114 (add-before 'configure 'set-paths
115 (lambda _
116 ;; Help cmake's bootstrap process to find system libraries
117 (begin
118 (setenv "CMAKE_LIBRARY_PATH" (getenv "LIBRARY_PATH"))
119 (setenv "CMAKE_INCLUDE_PATH" (getenv "C_INCLUDE_PATH"))
120 #t)))
121 (replace 'configure
122 (lambda* (#:key outputs #:allow-other-keys)
123 (let ((out (assoc-ref outputs "out")))
124 (invoke
125 "./configure" "--verbose"
126 (string-append "--parallel=" (number->string (parallel-job-count)))
127 (string-append "--prefix=" out)
128 "--system-libs"
129 "--no-system-jsoncpp" ; FIXME: Circular dependency.
130 ;; By default, the man pages and other docs land
131 ;; in PREFIX/man and PREFIX/doc, but we want them
132 ;; in share/{man,doc}. Note that unlike
133 ;; autoconf-generated configure scripts, cmake's
134 ;; configure prepends "PREFIX/" to what we pass
135 ;; to --mandir and --docdir.
136 "--mandir=share/man"
137 ,(string-append
138 "--docdir=share/doc/cmake-"
139 (version-major+minor version)))))))))
140 (inputs
141 `(("bzip2" ,bzip2)
142 ("curl" ,curl)
143 ("expat" ,expat)
144 ("file" ,file)
145 ("libarchive" ,libarchive)
146 ("libuv" ,libuv)
147 ("ncurses" ,ncurses) ; required for ccmake
148 ("rhash" ,rhash)
149 ("zlib" ,zlib)))
150 (native-search-paths
151 (list (search-path-specification
152 (variable "CMAKE_PREFIX_PATH")
153 (files '("")))))
154 (home-page "https://cmake.org/")
155 (synopsis "Cross-platform build system")
156 (description
157 "CMake is a family of tools designed to build, test and package software.
158 CMake is used to control the software compilation process using simple platform
159 and compiler independent configuration files. CMake generates native makefiles
160 and workspaces that can be used in the compiler environment of your choice.")
161 (license (list license:bsd-3 ; cmake
162 license:bsd-4 ; cmcompress
163 license:bsd-2 ; cmlibarchive
164 license:expat ; cmjsoncpp is dual MIT/public domain
165 license:public-domain)))) ; cmlibarchive/archive_getdate.c
166
167 (define-public cmake/fixed
168 ;; This is a variant of CMake that fixes X.509 certificate lookup:
169 ;; <https://issues.guix.gnu.org/issue/37371>.
170 (package
171 (inherit cmake)
172 (version (string-append (package-version cmake) "-1"))
173 (source (origin
174 (inherit (package-source cmake))
175 (patches
176 (append (search-patches "cmake-curl-certificates.patch")
177 (origin-patches (package-source cmake))))))))
178
179 (define-public emacs-cmake-mode
180 (package
181 (inherit cmake)
182 (name "emacs-cmake-mode")
183 (build-system emacs-build-system)
184 (arguments
185 `(#:phases
186 (modify-phases %standard-phases
187 (add-after 'unpack 'chdir-elisp
188 ;; Elisp directory is not in root of the source.
189 (lambda _
190 (chdir "Auxiliary"))))))
191 (synopsis "Emacs major mode for editing Cmake expressions")
192 (description "@code{cmakeos-mode} provides an Emacs major mode for editing
193 Cmake files. It supports syntax highlighting, indenting and refilling of
194 comments.")))