formula_creator: use tool-agnostic cmake commands

New versions of CMake know how to invoke the appropriate build tool
(i.e. make or ninja), so let's try to leave that to CMake.

This also builds out-of-tree, without having to deal with the `mkdir
"build" do` business.
This commit is contained in:
Carlo Cabrera 2021-03-15 03:22:41 +00:00
parent e3b451cce8
commit 20ab54fd9f
No known key found for this signature in database
GPG Key ID: C74D447FC549A1D0

View File

@ -153,11 +153,14 @@ module Homebrew
def install def install
# ENV.deparallelize # if your formula fails when building in parallel # ENV.deparallelize # if your formula fails when building in parallel
<% if mode == :cmake %> <% if mode == :cmake %>
system "cmake", ".", *std_cmake_args system "cmake", "-S", ".", "-B", "build", *std_cmake_args
system "cmake", "--build", "build"
system "cmake", "--install", "build"
<% elsif mode == :autotools %> <% elsif mode == :autotools %>
# Remove unrecognized options if warned by configure # Remove unrecognized options if warned by configure
# https://rubydoc.brew.sh/Formula.html#std_configure_args-instance_method # https://rubydoc.brew.sh/Formula.html#std_configure_args-instance_method
system "./configure", *std_configure_args, "--disable-silent-rules" system "./configure", *std_configure_args, "--disable-silent-rules"
system "make", "install" # if this fails, try separate make/make install steps
<% elsif mode == :crystal %> <% elsif mode == :crystal %>
system "shards", "build", "--release" system "shards", "build", "--release"
bin.install "bin/#{name}" bin.install "bin/#{name}"
@ -206,10 +209,7 @@ module Homebrew
# Remove unrecognized options if warned by configure # Remove unrecognized options if warned by configure
# https://rubydoc.brew.sh/Formula.html#std_configure_args-instance_method # https://rubydoc.brew.sh/Formula.html#std_configure_args-instance_method
system "./configure", *std_configure_args, "--disable-silent-rules" system "./configure", *std_configure_args, "--disable-silent-rules"
# system "cmake", ".", *std_cmake_args # system "cmake", "-S", ".", "-B", "build", *std_cmake_args
<% end %>
<% if mode == :autotools || mode == :cmake %>
system "make", "install" # if this fails, try separate make/make install steps
<% end %> <% end %>
end end