forked from ahmadia/homebrew-science
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ceres-solver.rb
58 lines (50 loc) · 1.97 KB
/
ceres-solver.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
class CeresSolver < Formula
desc "C++ library for large-scale optimization"
homepage "http://ceres-solver.org/"
url "http://ceres-solver.org/ceres-solver-1.11.0.tar.gz"
sha256 "4d666cc33296b4c5cd77bad18ffc487b3223d4bbb7d1dfb342ed9a87dc9af844"
revision 3
head "https://ceres-solver.googlesource.com/ceres-solver.git"
bottle do
cellar :any
sha256 "e50faf144f225f9a92449a3a3786010bc5738cdae984db786d478e6f3d74cb1a" => :el_capitan
sha256 "3f73e43083400efe8bf5b0fddd2124d4a1b25a9d0b7aa7e218d45fdb7915b315" => :yosemite
sha256 "6d8828601c655e452a438defa67bee0462ac415ee4240072291f1e6bc7262390" => :mavericks
end
option "without-test", "Do not build and run the tests (not recommended)."
deprecated_option "without-tests" => "without-test"
depends_on "cmake" => :run
depends_on "glog"
depends_on "gflags"
depends_on "eigen"
depends_on "suite-sparse" => :recommended
def suite_sparse_options
Tab.for_formula(Formula["suite-sparse"])
end
def install
cmake_args = std_cmake_args + ["-DBUILD_SHARED_LIBS=ON"]
cmake_args << "-DMETIS_LIBRARY=#{Formula["metis4"].opt_lib}/libmetis.dylib" if suite_sparse_options.with? "metis4"
cmake_args << "-DEIGEN_INCLUDE_DIR=#{Formula["eigen"].opt_include}/eigen3"
system "cmake", ".", *cmake_args
system "make"
system "make", "test" if build.with? "test"
system "make", "install"
pkgshare.install "examples"
pkgshare.install "data"
doc.install "docs/html"
end
test do
cp pkgshare/"examples/helloworld.cc", testpath
(testpath/"CMakeLists.txt").write <<-EOS.undent
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