homebrew-core/Formula/ceres-solver.rb

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.13.0.tar.gz"
sha256 "1df490a197634d3aab0a65687decd362912869c85a61090ff66f073c967a7dcd"
revision 4
head "https://ceres-solver.googlesource.com/ceres-solver.git"
bottle do
cellar :any
sha256 "f6df97e01cf7ca228bd8c64fcd301b822146670a615e0a3b47876209cf0bb251" => :high_sierra
sha256 "fdfbceefc7aea2f89ff72ee1ff6229535a12881997a68aca4f6b983b1c3662f9" => :sierra
sha256 "14835cb26577c3385d5f75d37295d758e82c039b954c0aa38c7cf0bb99cc1215" => :el_capitan
end
depends_on "cmake" => :run
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}"
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", 0)
end
end