【问题标题】:OS X Homebrew needs to create build directory for cmakeOS X Homebrew 需要为 cmake 创建构建目录
【发布时间】:2015-08-12 00:19:17
【问题描述】:

我有一个简单的自制脚本,我正在尝试使用它来构建库 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

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

# 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 &amp;&amp; mkdir build &amp;&amp; cd build 的等效操作,以便为我创建一个单独的目录来运行 cmake?

【问题讨论】:

    标签: ruby macos cmake homebrew


    【解决方案1】:

    感谢自制软件的DomT4 提供解决方案:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-10-24
      • 1970-01-01
      • 2011-07-12
      • 2013-09-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多