homebrew-core/Formula/ceres-solver.rb

54 lines
2.0 KiB
Ruby

class CeresSolver < Formula
desc "C++ library for large-scale optimization"
homepage "http://ceres-solver.org/"
url "http://ceres-solver.org/ceres-solver-1.14.0.tar.gz"
sha256 "4744005fc3b902fed886ea418df70690caa8e2ff6b5a90f3dd88a3d291ef8e8e"
revision 13
head "https://ceres-solver.googlesource.com/ceres-solver.git"
bottle do
cellar :any
sha256 "719e7200bf5b4ad439dc6a7b6579e5cb00e4881371cf759655ac0c38659cf607" => :big_sur
sha256 "0f802cdf5c1bf128e7befdfae3757e35e5c114f1005622a89ac5234afc2a892e" => :catalina
sha256 "c628c78acd97e295ca6307da52731e4785fa12a9371ce9c39607f353fedb421b" => :mojave
sha256 "956d8b27b565d5021cd9fcebdc2804f5e399623cd53f3a4419722e794e9b03c5" => :high_sierra
end
depends_on "cmake"
depends_on "eigen"
depends_on "gflags"
depends_on "glog"
depends_on "metis"
depends_on "suite-sparse"
def install
system "cmake", ".", *std_cmake_args,
"-DBUILD_SHARED_LIBS=ON",
"-DEIGEN_INCLUDE_DIR=#{Formula["eigen"].opt_include}/eigen3",
"-DMETIS_LIBRARY=#{Formula["metis"].opt_lib}/#{shared_library("libmetis")}",
"-DGLOG_INCLUDE_DIR_HINTS=#{Formula["glog"].opt_include}",
"-DGLOG_LIBRARY_DIR_HINTS=#{Formula["glog"].opt_lib}",
"-DTBB=OFF", "-DBUILD_EXAMPLES=OFF"
system "make"
system "make", "install"
pkgshare.install "examples", "data"
doc.install "docs/html" unless build.head?
end
test do
cp pkgshare/"examples/helloworld.cc", testpath
(testpath/"CMakeLists.txt").write <<~EOS
cmake_minimum_required(VERSION 2.8)
project(helloworld)
find_package(Ceres REQUIRED)
include_directories(${CERES_INCLUDE_DIRS})
add_executable(helloworld helloworld.cc)
target_link_libraries(helloworld ${CERES_LIBRARIES})
EOS
system "cmake", "-DCeres_DIR=#{share}/Ceres", "."
system "make"
assert_match "CONVERGENCE", shell_output("./helloworld")
end
end