homebrew-core/Formula/ipopt.rb

80 lines
2.5 KiB
Ruby
Raw Normal View History

class Ipopt < Formula
desc "Interior point optimizer"
homepage "https://projects.coin-or.org/Ipopt/"
url "https://www.coin-or.org/download/source/Ipopt/Ipopt-3.12.13.tgz"
sha256 "aac9bb4d8a257fdfacc54ff3f1cbfdf6e2d61fb0cf395749e3b0c0664d3e7e96"
head "https://github.com/coin-or/Ipopt.git"
2019-06-04 12:50:55 +00:00
bottle do
cellar :any
2019-06-04 20:22:43 +00:00
sha256 "7236024b1c9952f728d382515eb55fa5261097fe1aefac6802ef6a6b7bf27597" => :mojave
sha256 "32b9445a8cf5d73283d84ae3bb6a23004be92deda61187860edde166fb4fda2d" => :high_sierra
sha256 "d12d4f3546ab13a397c0c2e9c7420a73449463d2145c79c76d389eff2e1d1459" => :sierra
2019-06-04 12:50:55 +00:00
end
depends_on "gcc"
depends_on "openblas"
resource "mumps" do
url "http://mumps.enseeiht.fr/MUMPS_5.2.0.tar.gz"
sha256 "41f2c7cb20d69599fb47e2ad6f628f3798c429f49e72e757e70722680f70853f"
# MUMPS does not provide a Makefile.inc customized for macOS.
patch do
url "https://raw.githubusercontent.com/Homebrew/formula-patches/ab96a8b/ipopt/mumps-makefile-inc-generic-seq.patch"
sha256 "0c570ee41299073ec2232ad089d8ee10a2010e6dfc9edc28f66912dae6999d75"
end
end
def install
ENV.delete("MPICC")
ENV.delete("MPICXX")
ENV.delete("MPIFC")
resource("mumps").stage do
cp "Make.inc/Makefile.inc.generic.SEQ", "Makefile.inc"
inreplace "Makefile.inc", "@rpath/", "#{opt_lib}/"
ENV.deparallelize { system "make", "d" }
(buildpath/"mumps_include").install Dir["include/*.h", "libseq/mpi.h"]
lib.install Dir["lib/*.dylib", "libseq/*.dylib", "PORD/lib/*.dylib"]
end
args = [
"--disable-debug",
"--disable-dependency-tracking",
"--disable-silent-rules",
"--enable-shared",
"--prefix=#{prefix}",
"--with-blas=-L#{Formula["openblas"].opt_lib} -lopenblas",
"--with-mumps-incdir=#{buildpath}/mumps_include",
"--with-mumps-lib=-L#{lib} -ldmumps -lmpiseq -lmumps_common -lopenblas -lpord",
]
system "./configure", *args
system "make"
ENV.deparallelize
system "make", "install"
end
test do
(testpath/"test.cpp").write <<~EOS
#include <cassert>
#include <IpIpoptApplication.hpp>
#include <IpReturnCodes.hpp>
#include <IpSmartPtr.hpp>
int main() {
Ipopt::SmartPtr<Ipopt::IpoptApplication> app = IpoptApplicationFactory();
const Ipopt::ApplicationReturnStatus status = app->Initialize();
assert(status == Ipopt::Solve_Succeeded);
return 0;
}
EOS
system ENV.cxx, "test.cpp", "-I#{include}/coin", "-L#{lib}", "-lipopt"
system "./a.out"
end
end