简体   繁体   English

使用 Homebrew 安装 Cmake 3.19.2

[英]Install Cmake 3.19.2 with Homebrew

I'm trying to install an older version of CMake to compile a software that requires it ( https://github.com/horosproject/horos )我正在尝试安装旧版本的 CMake 来编译需要它的软件( https://github.com/horosproject/horos

If you use brew install cmake it will install 3.20 versions, but I need to install 3.19.2 to get the compilation to work.如果您使用brew install cmake它将安装 3.20 版本,但我需要安装 3.19.2 才能使编译工作。

You would think this would be easy but I have been struggling.你会认为这很容易,但我一直在努力。 Here are some things I have tried:以下是我尝试过的一些事情:

curl -O https://raw.githubusercontent.com/Homebrew/homebrew-core/481056b12a782e11b43670f406b1674b05990d0d/Formula/cmake.rb && brew install ./cmake.rb

This command downloads the raw formula and then attempts to install based on some answers I have seen since the brew versions command is deprecated.此命令下载原始公式,然后尝试根据我看到的一些答案进行安装,因为brew versions命令已被弃用。

Attempting to run the command above gives me the following errors:尝试运行上面的命令会给我以下错误:

Warning: Calling `cellar` in a bottle block is deprecated! Use `brew style --fix` on the formula to update the style or use `sha256` with a `cellar:` argument instead.
Warning: Calling `sha256 "digest" => :tag` in a bottle block is deprecated! Use `brew style --fix` on the formula to update the style or use `sha256 tag: "digest"` instead.
Warning: Calling `sha256 "digest" => :tag` in a bottle block is deprecated! Use `brew style --fix` on the formula to update the style or use `sha256 tag: "digest"` instead.
Warning: Calling `sha256 "digest" => :tag` in a bottle block is deprecated! Use `brew style --fix` on the formula to update the style or use `sha256 tag: "digest"` instead.
Warning: Calling `sha256 "digest" => :tag` in a bottle block is deprecated! Use `brew style --fix` on the formula to update the style or use `sha256 tag: "digest"` instead.
Error: Failed to load cask: ./cmake.rb
Cask 'cmake' is unreadable: wrong constant name #<Class:0x00007fe8f24621b0>
Warning: Treating ./cmake.rb as a formula.
==> Downloading https://ghcr.io/v2/homebrew/core/cmake/manifests/3.19.2
##O#- #                                                                       
curl: (22) The requested URL returned error: 404 
Error: Failed to download resource "cmake_bottle_manifest"
Download failed: https://ghcr.io/v2/homebrew/core/cmake/manifests/3.19.2

I think it's not working because I need authentication for the manifest download, but this should have worked before without any issues or anything like this required, leaving me to believe I'm probably doing something incorrect.我认为它不起作用,因为我需要对清单下载进行身份验证,但这应该在之前没有任何问题或类似要求的情况下工作,让我相信我可能做错了什么。

Any help is appreciated!任何帮助表示赞赏! A successful result would result in cmake --version saying it's version 3.19.2.成功的结果将导致cmake --version说它是版本 3.19.2。 Also I want to confirm that I know cmake is 100% the issue since I have the compilation of Horos working on my other machine.另外我想确认我知道 cmake 是 100% 的问题,因为我在我的另一台机器上编译了 Horos。

Which leaves another possibility of me copying the cmake from there but I'm not sure how to do that correctly or how hard that would be?这让我有另一种可能从那里复制 cmake 但我不确定如何正确地做到这一点或这有多难? (if that is even proper procedure, not to mention that would not help future readers of this question). (如果这甚至是正确的程序,更不用说这对这个问题的未来读者没有帮助)。

Extra Info:额外信息:

https://github.com/Homebrew/homebrew-core/blob/2be111d6b85b6a72565b4883cafb4f171c6e6b8f/Formula/cmake.rb https://github.com/Homebrew/homebrew-core/blob/2be111d6b85b6a72565b4883cafb4f171c6e6b8f/Formula/cmake.rb

Here is an example of a formula I found for an older version of cmake.这是我为旧版本的 cmake 找到的公式示例。

https://github.com/Homebrew/homebrew-core/commits/master/Formula/cmake.rb https://github.com/Homebrew/homebrew-core/commits/master/Formula/cmake.rb

above is a list of all the different versions以上是所有不同版本的列表

strange part is... if you use this method with the newest bottle 3.20 it works!奇怪的部分是......如果你在最新的瓶子 3.20 上使用这种方法,它就可以工作!

UPDATE::更新::

So I was reading another answer and it appears this error is caused by cURL being out of date.所以我正在阅读另一个答案,看来这个错误是由 cURL 过时引起的。 So I updated to the latest cURL (confirmed it still works with the newest version), then went back to the old and now I get a different error.所以我更新到最新的 cURL (确认它仍然适用于最新版本),然后回到旧版本,现在我得到了一个不同的错误。

https://superuser.com/questions/1647213/brew-install-fails-downloading-from-ghcr-io-macos-mojave https://superuser.com/questions/1647213/brew-install-fails-downloading-from-ghcr-io-macos-mojave

The above is where I learned about the cURL version fix.以上是我了解 cURL 版本修复的地方。

Now my error is this:现在我的错误是这样的:

curl -O https://raw.githubusercontent.com/Homebrew/homebrew-core/d1a6d9cec03e43ae276ab6423fba0b91b69a1945/Formula/cmake.rb && brew install ./cmake.rb
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1961  100  1961    0     0  46229      0 --:--:-- --:--:-- --:--:-- 50282
/usr/local/Homebrew/Library/Homebrew/formulary.rb:84:in `rescue in block in load_formula'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:77:in `block in load_formula'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:90:in `load_formula'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:110:in `load_formula_from_path'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:195:in `load_file'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:185:in `klass'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:180:in `get_formula'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:404:in `factory'
/usr/local/Homebrew/Library/Homebrew/cli/named_args.rb:98:in `load_formula_or_cask'
/usr/local/Homebrew/Library/Homebrew/cli/named_args.rb:57:in `block in to_formulae_and_casks'
/usr/local/Homebrew/Library/Homebrew/cli/named_args.rb:56:in `each'
/usr/local/Homebrew/Library/Homebrew/cli/named_args.rb:56:in `flat_map'
/usr/local/Homebrew/Library/Homebrew/cli/named_args.rb:56:in `to_formulae_and_casks'
/usr/local/Homebrew/Library/Homebrew/cmd/install.rb:158:in `install'
/usr/local/Homebrew/Library/Homebrew/brew.rb:122:in `<main>'
Error: cmake: Calling `cellar` in a bottle block is deprecated! Use `brew style --fix` on the formula to update the style or use `sha256` with a `cellar:` argument instead

running brew style --fix./cmake.rb will fix the error above but then I get the exact same error again!运行 brew style --fix./cmake.rb 将修复上面的错误,但我再次得到完全相同的错误!

brew install ./cmake.rb
Error: Failed to load cask: ./cmake.rb
Cask 'cmake' is unreadable: wrong constant name #<Class:0x00007fc2138b7f90>
Warning: Treating ./cmake.rb as a formula.
==> Downloading https://ghcr.io/v2/homebrew/core/cmake/manifests/3.19.2
curl: (22) The requested URL returned error: 404                              

Error: Failed to download resource "cmake_bottle_manifest"
Download failed: https://ghcr.io/v2/homebrew/core/cmake/manifests/3.19.2

I'm at wits end in frustration and seem to be going in circles.我在沮丧中束手无策,似乎在兜圈子。 Any help is greatly appreciated!任何帮助是极大的赞赏!

brew install./cmake.rb will try to install a bottle, which obviously doesn't exist anymore. brew install./cmake.rb会尝试安装一个瓶子,它显然已经不存在了。 Try installing from source with brew install -s./cmake.rb .尝试使用brew install -s./cmake.rb从源代码安装。

❯ cmake --version
zsh: command not found: cmake

❯ curl -O https://raw.githubusercontent.com/Homebrew/homebrew-core/481056b12a782e11b43670f406b1674b05990d0d/Formula/cmake.rb
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2006  100  2006    0     0  26394      0 --:--:-- --:--:-- --:--:-- 26394

❯ brew install -s ./cmake.rb
Warning: Calling `cellar` in a bottle block is deprecated! Use `brew style --fix` on the formula to update the style or use `sha256` with a `cellar:` argument instead.
Warning: Calling `sha256 "digest" => :tag` in a bottle block is deprecated! Use `brew style --fix` on the formula to update the style or use `sha256 tag: "digest"` instead.
Warning: Calling `sha256 "digest" => :tag` in a bottle block is deprecated! Use `brew style --fix` on the formula to update the style or use `sha256 tag: "digest"` instead.
Warning: Calling `sha256 "digest" => :tag` in a bottle block is deprecated! Use `brew style --fix` on the formula to update the style or use `sha256 tag: "digest"` instead.
Warning: Calling `sha256 "digest" => :tag` in a bottle block is deprecated! Use `brew style --fix` on the formula to update the style or use `sha256 tag: "digest"` instead.
Error: Failed to load cask: ./cmake.rb
Cask 'cmake' is unreadable: wrong constant name #<Class:0x00007ffab488a5c0>
Warning: Treating ./cmake.rb as a formula.
==> Downloading https://ghcr.io/v2/homebrew/core/sphinx-doc/manifests/4.0.2
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/sphinx-doc/blobs/sha256:df254b910ef155cbf68f614a903a7601c583b108252dd2d3a21d304577ceec42
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:df254b910ef155cbf68f614a903a7601c583b108252dd2d3a21d304577ceec42?se=2021-06-07T01%3A15%3A00Z&sig=qO3%2Be9wjDZFGb8G0TMkWRdx%2FsSzXGGmIoQoVXBSKTLc%3D&sp=
######################################################################## 100.0%
==> Downloading https://github.com/Kitware/CMake/releases/download/v3.19.2/cmake-3.19.2.tar.gz
==> Downloading from https://github-releases.githubusercontent.com/537699/e5e69f80-3f8c-11eb-8f66-b847f2092348?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20210607%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=
######################################################################## 100.0%
Warning: cmake 3.20.3 is available and more recent than version 3.19.2.
==> Installing dependencies for cmake: sphinx-doc
==> Installing cmake dependency: sphinx-doc
==> Pouring sphinx-doc--4.0.2.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/sphinx-doc/4.0.2: 3,885 files, 55.9MB
==> Installing cmake
Warning: Calling `cellar` in a bottle block is deprecated! Use `brew style --fix` on the formula to update the style or use `sha256` with a `cellar:` argument instead.
Warning: Calling `sha256 "digest" => :tag` in a bottle block is deprecated! Use `brew style --fix` on the formula to update the style or use `sha256 tag: "digest"` instead.
Warning: Calling `sha256 "digest" => :tag` in a bottle block is deprecated! Use `brew style --fix` on the formula to update the style or use `sha256 tag: "digest"` instead.
Warning: Calling `sha256 "digest" => :tag` in a bottle block is deprecated! Use `brew style --fix` on the formula to update the style or use `sha256 tag: "digest"` instead.
Warning: Calling `sha256 "digest" => :tag` in a bottle block is deprecated! Use `brew style --fix` on the formula to update the style or use `sha256 tag: "digest"` instead.
==> ./bootstrap --prefix=/usr/local/Cellar/cmake/3.19.2 --no-system-libs --parallel=12 --datadir=/share/cmake --docdir=/share/doc/cmake --mandir=/share/man --sphinx-build=/usr/local/opt/sphinx-doc/bin/sphinx-build --sphinx-html --sphinx
==> make
==> make install
Warning: Calling `cellar` in a bottle block is deprecated! Use `brew style --fix` on the formula to update the style or use `sha256` with a `cellar:` argument instead.
Warning: Calling `sha256 "digest" => :tag` in a bottle block is deprecated! Use `brew style --fix` on the formula to update the style or use `sha256 tag: "digest"` instead.
Warning: Calling `sha256 "digest" => :tag` in a bottle block is deprecated! Use `brew style --fix` on the formula to update the style or use `sha256 tag: "digest"` instead.
Warning: Calling `sha256 "digest" => :tag` in a bottle block is deprecated! Use `brew style --fix` on the formula to update the style or use `sha256 tag: "digest"` instead.
Warning: Calling `sha256 "digest" => :tag` in a bottle block is deprecated! Use `brew style --fix` on the formula to update the style or use `sha256 tag: "digest"` instead.
==> Caveats
Emacs Lisp files have been installed to:
  /usr/local/share/emacs/site-lisp/cmake
==> Summary
🍺  /usr/local/Cellar/cmake/3.19.2: 6,376 files, 63.9MB, built in 4 minutes 22 seconds
Removing: /Users/nega/Library/Caches/Homebrew/cmake--3.19.2.tar.gz... (8.8MB)
==> Caveats
==> cmake
Emacs Lisp files have been installed to:
  /usr/local/share/emacs/site-lisp/cmake

❯ cmake --version
cmake version 3.19.2

CMake suite maintained and supported by Kitware (kitware.com/cmake).

❯

Of course, the next brew upgrade you do will probably wipe that out.当然,您进行的下一次brew upgrade可能会消除这种情况。

You could install the macOS app bundle that KitWare provides:您可以安装 KitWare 提供的 macOS 应用程序包:

❯ curl -O https://cmake.org/files/v3.19/cmake-3.19.2-macos-universal.dmg
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 61.6M  100 61.6M    0     0  6340k      0  0:00:09  0:00:09 --:--:-- 13.3M

❯ open cmake-3.19.2-macos-universal.dmg

Or as @the-swine suggests in their comment, install CMake via source.或者正如@the-swine 在他们的评论中所建议的那样,通过源代码安装 CMake。

❯ curl -O https://cmake.org/files/v3.19/cmake-3.19.2.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 9047k  100 9047k    0     0  1301k      0  0:00:06  0:00:06 --:--:-- 2035k

❯ tar xf cmake-3.19.2.tar.gz

❯ cd cmake-3.19.2

~/cmake-3.19.2 ❯ less README.rst

~/cmake-3.19.2 ❯ ./bootstrap --prefix=/opt/cmake && make && sudo make install

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM