| 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 | ;;; This file is part of GNU Guix. |
| 14 | ;;; |
| 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. |
| 19 | ;;; |
| 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. |
| 24 | ;;; |
| 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/>. |
| 27 | |
| 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 build-system gnu) |
| 34 | #:use-module (guix build-system emacs) |
| 35 | #:use-module (gnu packages) |
| 36 | #:use-module (gnu packages backup) |
| 37 | #:use-module (gnu packages compression) |
| 38 | #:use-module (gnu packages crypto) |
| 39 | #:use-module (gnu packages curl) |
| 40 | #:use-module (gnu packages file) |
| 41 | #:use-module (gnu packages libevent) |
| 42 | #:use-module (gnu packages ncurses) |
| 43 | #:use-module (gnu packages sphinx) |
| 44 | #:use-module (gnu packages texinfo) |
| 45 | #:use-module (gnu packages xml) |
| 46 | #:use-module (srfi srfi-1)) |
| 47 | |
| 48 | ;;; This minimal variant of CMake does not include the documentation. It is |
| 49 | ;;; used by the cmake-build-system. |
| 50 | (define-public cmake-minimal |
| 51 | (package |
| 52 | (name "cmake-minimal") |
| 53 | (version "3.15.1") |
| 54 | (source (origin |
| 55 | (method url-fetch) |
| 56 | (uri (string-append "https://www.cmake.org/files/v" |
| 57 | (version-major+minor version) |
| 58 | "/cmake-" version ".tar.gz")) |
| 59 | (sha256 |
| 60 | (base32 |
| 61 | "1xyprly3sf4wi0n1x79k4n22yxm6pb7fv70gqr9lvc7qv14cbphq")) |
| 62 | (modules '((guix build utils))) |
| 63 | (snippet |
| 64 | '(begin |
| 65 | ;; Drop bundled software. |
| 66 | (with-directory-excursion "Utilities" |
| 67 | (for-each delete-file-recursively |
| 68 | '("cmbzip2" |
| 69 | ;; "cmcompress" |
| 70 | "cmcurl" |
| 71 | "cmexpat" |
| 72 | ;; "cmjsoncpp" |
| 73 | ;; "cmlibarchive" |
| 74 | "cmliblzma" |
| 75 | ;; "cmlibuv" |
| 76 | "cmzlib")) |
| 77 | #t))))) |
| 78 | (build-system gnu-build-system) |
| 79 | (arguments |
| 80 | `(#:test-target "test" |
| 81 | #:configure-flags |
| 82 | (let ((out (assoc-ref %outputs "out")) |
| 83 | (parallel-job-count (number->string (parallel-job-count)))) |
| 84 | (list "--verbose" |
| 85 | (string-append "--parallel=" parallel-job-count) |
| 86 | (string-append "--prefix=" out) |
| 87 | "--system-libs" |
| 88 | "--no-system-jsoncpp" ; FIXME: Circular dependency. |
| 89 | ;; By default, the man pages and other docs land |
| 90 | ;; in PREFIX/man and PREFIX/doc, but we want them |
| 91 | ;; in share/{man,doc}. Note that unlike |
| 92 | ;; autoconf-generated configure scripts, cmake's |
| 93 | ;; configure prepends "PREFIX/" to what we pass |
| 94 | ;; to --mandir and --docdir. |
| 95 | "--mandir=share/man" |
| 96 | ,(string-append "--docdir=share/doc/cmake-" |
| 97 | (version-major+minor version)))) |
| 98 | #:make-flags |
| 99 | (let ((skipped-tests |
| 100 | (list "BundleUtilities" ; This test fails on Guix. |
| 101 | "CTestTestSubdir" ; This test fails to build 2 of the 3 tests. |
| 102 | ;; These tests requires network access. |
| 103 | "CTestCoverageCollectGCOV" |
| 104 | "CTestTestUpload"))) |
| 105 | (list |
| 106 | (string-append |
| 107 | ;; These arguments apply for the tests only. |
| 108 | "ARGS=-j " (number->string (parallel-job-count)) |
| 109 | " --output-on-failure" |
| 110 | " --exclude-regex ^\\(" (string-join skipped-tests "\\|") "\\)$"))) |
| 111 | #:phases |
| 112 | (modify-phases %standard-phases |
| 113 | (add-after 'unpack 'split-package |
| 114 | ;; Remove files that have been packaged in other package recipes. |
| 115 | (lambda _ |
| 116 | (delete-file "Auxiliary/cmake-mode.el") |
| 117 | (substitute* "Auxiliary/CMakeLists.txt" |
| 118 | ((".*cmake-mode.el.*") "")) |
| 119 | #t)) |
| 120 | (add-before 'configure 'patch-bin-sh |
| 121 | (lambda _ |
| 122 | ;; Replace "/bin/sh" by the right path in... a lot of |
| 123 | ;; files. |
| 124 | (substitute* |
| 125 | '("Modules/CompilerId/Xcode-3.pbxproj.in" |
| 126 | "Modules/CPack.RuntimeScript.in" |
| 127 | "Source/cmGlobalXCodeGenerator.cxx" |
| 128 | "Source/cmLocalUnixMakefileGenerator3.cxx" |
| 129 | "Source/cmExecProgramCommand.cxx" |
| 130 | "Utilities/Release/release_cmake.cmake" |
| 131 | "Utilities/cmlibarchive/libarchive/archive_write_set_format_shar.c" |
| 132 | "Tests/CMakeLists.txt" |
| 133 | "Tests/RunCMake/File_Generate/RunCMakeTest.cmake") |
| 134 | (("/bin/sh") (which "sh"))) |
| 135 | #t)) |
| 136 | (add-before 'configure 'set-paths |
| 137 | (lambda _ |
| 138 | ;; Help cmake's bootstrap process to find system libraries |
| 139 | (begin |
| 140 | (setenv "CMAKE_LIBRARY_PATH" (getenv "LIBRARY_PATH")) |
| 141 | (setenv "CMAKE_INCLUDE_PATH" (or (getenv "CPATH") |
| 142 | (getenv "C_INCLUDE_PATH"))) |
| 143 | #t))) |
| 144 | ;; CMake uses its own configure script. |
| 145 | (replace 'configure |
| 146 | (lambda* (#:key (configure-flags '()) #:allow-other-keys) |
| 147 | (apply invoke "./configure" configure-flags)))))) |
| 148 | (inputs |
| 149 | `(("bzip2" ,bzip2) |
| 150 | ("curl" ,curl) |
| 151 | ("expat" ,expat) |
| 152 | ("file" ,file) |
| 153 | ("libarchive" ,libarchive) |
| 154 | ("libuv" ,libuv) |
| 155 | ("ncurses" ,ncurses) ; required for ccmake |
| 156 | ("rhash" ,rhash) |
| 157 | ("zlib" ,zlib))) |
| 158 | (native-search-paths |
| 159 | (list (search-path-specification |
| 160 | (variable "CMAKE_PREFIX_PATH") |
| 161 | (files '(""))))) |
| 162 | (home-page "https://cmake.org/") |
| 163 | (synopsis "Cross-platform build system") |
| 164 | (description |
| 165 | "CMake is a family of tools designed to build, test and package software. |
| 166 | CMake is used to control the software compilation process using simple platform |
| 167 | and compiler independent configuration files. CMake generates native makefiles |
| 168 | and workspaces that can be used in the compiler environment of your choice.") |
| 169 | (properties '((hidden? . #t))) |
| 170 | (license (list license:bsd-3 ; cmake |
| 171 | license:bsd-4 ; cmcompress |
| 172 | license:bsd-2 ; cmlibarchive |
| 173 | license:expat ; cmjsoncpp is dual MIT/public domain |
| 174 | license:public-domain)))) ; cmlibarchive/archive_getdate.c |
| 175 | |
| 176 | (define-public cmake |
| 177 | (package |
| 178 | (inherit cmake-minimal) |
| 179 | (name "cmake") |
| 180 | (arguments |
| 181 | (substitute-keyword-arguments (package-arguments cmake-minimal) |
| 182 | ((#:configure-flags configure-flags ''()) |
| 183 | `(append ,configure-flags |
| 184 | ;; Extra configure flags used to generate the documentation. |
| 185 | '("--sphinx-info" |
| 186 | "--sphinx-man" |
| 187 | "--sphinx-html"))) |
| 188 | ((#:phases phases) |
| 189 | `(modify-phases ,phases |
| 190 | (add-after 'install 'move-html-doc |
| 191 | (lambda* (#:key outputs #:allow-other-keys) |
| 192 | (let ((out (assoc-ref outputs "out")) |
| 193 | (doc (assoc-ref outputs "doc")) |
| 194 | (html (string-append "/share/doc/cmake-" |
| 195 | ,(version-major+minor |
| 196 | (package-version cmake-minimal)) |
| 197 | "/html"))) |
| 198 | (copy-recursively (string-append out html) |
| 199 | (string-append doc html)) |
| 200 | (delete-file-recursively (string-append out html)) |
| 201 | #t))))))) |
| 202 | ;; Extra inputs required to build the documentation. |
| 203 | (native-inputs |
| 204 | `(,@(package-native-inputs cmake-minimal) |
| 205 | ("python-sphinx" ,python-sphinx) |
| 206 | ("texinfo" ,texinfo))) |
| 207 | (outputs '("out" "doc")) |
| 208 | (properties (alist-delete 'hidden? (package-properties cmake-minimal))))) |
| 209 | |
| 210 | (define-public cmake/fixed |
| 211 | ;; This is a variant of CMake that fixes X.509 certificate lookup: |
| 212 | ;; <https://issues.guix.gnu.org/issue/37371>. |
| 213 | (package |
| 214 | (inherit cmake) |
| 215 | (version (string-append (package-version cmake) "-1")) |
| 216 | (source (origin |
| 217 | (inherit (package-source cmake)) |
| 218 | (patches |
| 219 | (append (search-patches "cmake-curl-certificates.patch") |
| 220 | (origin-patches (package-source cmake)))))))) |
| 221 | |
| 222 | (define-public cmake-3.15.5 |
| 223 | ;; CMake 3.15.5 fixes some issues, but declare another version to |
| 224 | ;; avoid triggering the rebuild of all CMake-based packages. |
| 225 | ;; See <https://issues.guix.gnu.org/issue/38060>. |
| 226 | (package |
| 227 | (inherit cmake) |
| 228 | (version "3.15.5") |
| 229 | (source (origin |
| 230 | (inherit (package-source cmake)) |
| 231 | (uri (string-append "https://www.cmake.org/files/v" |
| 232 | (version-major+minor version) |
| 233 | "/cmake-" version ".tar.gz")) |
| 234 | (sha256 |
| 235 | (base32 |
| 236 | "1d5y8d92axcc6rfqlsxamayfs3fc1vdby91hn5mx1kn02ppprpgv")))))) |
| 237 | |
| 238 | (define-public emacs-cmake-mode |
| 239 | (package |
| 240 | (inherit cmake) |
| 241 | (name "emacs-cmake-mode") |
| 242 | (native-inputs '()) |
| 243 | (inputs '()) |
| 244 | (outputs '("out")) |
| 245 | (build-system emacs-build-system) |
| 246 | (arguments |
| 247 | `(#:phases |
| 248 | (modify-phases %standard-phases |
| 249 | (add-after 'unpack 'chdir-elisp |
| 250 | ;; Elisp directory is not in root of the source. |
| 251 | (lambda _ |
| 252 | (chdir "Auxiliary") |
| 253 | #t))))) |
| 254 | (synopsis "Emacs major mode for editing Cmake expressions") |
| 255 | (description "@code{cmakeos-mode} provides an Emacs major mode for editing |
| 256 | Cmake files. It supports syntax highlighting, indenting and refilling of |
| 257 | comments."))) |