gpt4 book ai didi

ruby - OS X Homebrew 需要为 cmake 创建构建目录

转载 作者:太空宇宙 更新时间:2023-11-03 17:47:42 25 4
gpt4 key购买 nike

我有一个简单的 Homebrew 脚本,我试图用它来构建库 cmake-basis。但是,它不能用 cmake 在源代码中构建,我需要创建一个单独的构建目录。通常在 bash 中我会执行以下操作:

git clone https://github.com/schuhschuh/cmake-basis.git -b develop ~/cmake-basis 
cd ~/cmake-basis && mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local
make
make install

我正在尝试制作一个 Homebrew 脚本来自动执行此操作:

# Documentation: https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/Formula-Cookbook.md
# /usr/local/Library/Contributions/example-formula.rb
# PLEASE REMOVE ALL GENERATED COMMENTS BEFORE SUBMITTING YOUR PULL REQUEST!

class CmakeBasis < Formula
desc "cmake build and installer generation tools"
homepage "https://github.com/schuhschuh/cmake-basis"
url "https://github.com/schuhschuh/cmake-basis.git", :using => :git, :tag => "v3.1.0"
version "3.1"
#sha256 ""

depends_on "cmake" => :build
depends_on "doxygen" => :recommended
depends_on :python => :required
# todo: add sphinx python dependency
#depends_on :x11 # if your formula requires any X11/XQuartz components

# The optional devel block is only executed if the user passes `--devel`.
# Use this to specify a not-yet-released version of a software.
devel do

url "https://github.com/schuhschuh/cmake-basis.git", :using => :git, :branch => "develop"

end

head do

url "https://github.com/schuhschuh/cmake-basis.git", :using => :git, :branch => "master"

end

def install
args = %W[
]
# ENV.deparallelize # if your formula fails when building in parallel
system "cmake", "-G", "Unix Makefiles", buildpath, *(std_cmake_args + args)
system "make"
system "make", "install"
end



test do
# `test do` will create, run in and delete a temporary directory.
#
# This test will fail and we won't accept that! It's enough to just replace
# "false" with the main program this formula installs, but it'd be nice if you
# were more thorough. Run the test with `brew test cmake-basis`. Options passed
# to `brew install` such as `--HEAD` also need to be provided to `brew test`.
#
# The installed folder is not in the path, so use the entire path to any
# executables being tested: `system "#{bin}/program", "do", "something"`.
system "false"
end
end

但是报如下错误:

CMake Error at src/cmake/ProjectTools.cmake:666 (message):
This project should not be configured & build in the source directory:

/tmp/cmake-basis20150811-955-1b0sqck

You must run CMake in a separate build directory.
Call Stack (most recent call first):
src/cmake/ProjectTools.cmake:1952 (basis_buildtree_asserts)
src/cmake/ProjectTools.cmake:2156 (basis_project_begin)
CMakeLists.txt:66 (basis_project_impl)


-- Configuring incomplete, errors occurred!

我如何使用 homebrew 执行与 cd ~/cmake-basis && mkdir build && cd build 等效的操作,以便它会为我创建一个单独的目录来运行 cmake?

最佳答案

感谢DomT4在 Homebrew 软件中寻找解决方案:

def install
mkdir "build" do
system "cmake", "-G", "Unix Makefiles", "..", *std_cmake_args
system "make"
system "make", "install"
end
end

关于ruby - OS X Homebrew 需要为 cmake 创建构建目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31954088/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com