forked from ahmadia/homebrew-science
-
Notifications
You must be signed in to change notification settings - Fork 2
/
ceres-solver.rb
69 lines (61 loc) · 2.17 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
59
60
61
62
63
64
65
66
67
68
69
class CeresSolver < Formula
desc "C++ library for large-scale optimization"
homepage "http://ceres-solver.org/"
url "http://ceres-solver.org/ceres-solver-1.12.0.tar.gz"
sha256 "745bfed55111e086954126b748eb9efe20e30be5b825c6dec3c525cf20afc895"
bottle do
cellar :any
sha256 "0e96f6218a5ef289def2b4b60a4bdaa2d0f100be3c2dcb59a10c2b65b172e1e6" => :sierra
sha256 "13bb08cd1aea7a3f910c89e2405c5181da89a5ecc790b503be307ac21183d686" => :el_capitan
sha256 "97188d56181edfeaa1cb0ab3a1b5e24f5307d69108563b6f44d00808e5223a6a" => :yosemite
end
head do
url "https://ceres-solver.googlesource.com/ceres-solver.git"
depends_on "sphinx-doc" => :build
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
if build.with? "suite-sparse"
depends_on "metis"
elsif OS.linux?
depends_on "openblas" => :recommended
end
def install
so = OS.mac? ? "dylib" : "so"
cmake_args = std_cmake_args + %W[
-DBUILD_SHARED_LIBS=ON
-DEIGEN_INCLUDE_DIR=#{Formula["eigen"].opt_include}/eigen3
]
if build.with? "suite-sparse"
cmake_args << "-DMETIS_LIBRARY=#{Formula["metis"].opt_lib}/libmetis.#{so}"
else
cmake_args << "-DSUITESPARSE=OFF"
end
cmake_args << "-DBUILD_DOCUMENTATION=ON" if build.head?
system "cmake", ".", *cmake_args
system "make"
system "make", "test" if build.with? "test"
system "make", "install"
pkgshare.install "examples", "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