homebrew-core/Formula/ceres-solver.rb
2019-03-24 02:36:20 +08:00

52 lines
1.8 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 5
head "https://ceres-solver.googlesource.com/ceres-solver.git"
bottle do
cellar :any
sha256 "9aa43289999f607209096576d18176485196ddc1805519b9577c043902644cb4" => :mojave
sha256 "c5c74085f3ebaf62394c20ab4f390c0d851d1a83c8d528b46e0fbdb9b20981f3" => :high_sierra
sha256 "dec05eb9d86a2580e26e69c57768a2547fb4dd2bfba06544f25a339f56a8440d" => :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}/libmetis.dylib",
"-DGLOG_INCLUDE_DIR_HINTS=#{Formula["glog"].opt_include}",
"-DGLOG_LIBRARY_DIR_HINTS=#{Formula["glog"].opt_lib}",
"-DTBB=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