forked from ahmadia/homebrew-science
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ceres-solver.rb
72 lines (64 loc) · 2.32 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
70
71
72
class CeresSolver < Formula
desc "C++ library for large-scale optimization"
homepage "http://ceres-solver.org/"
# Using the RC as stable for the sake of compatibility with the current eigen
# https://github.com/ceres-solver/ceres-solver/issues/240
url "http://ceres-solver.org/ceres-solver-1.12.0rc4.tar.gz"
sha256 "ea8f161a110dd3a0bc563f8d13e5a04a0d34867303b309e2a07c73583e59d66d"
revision 1
bottle do
cellar :any
sha256 "77723c42225faa0f8a43899d919c00ae6fdcf64318e044a6f301b65479e6654c" => :sierra
sha256 "3a99821bed8ea5dae32c307adb85c9877dec57f66367f7dee11a8a7c43dd0559" => :el_capitan
sha256 "94a0a2b56ac5702e1a0b6e260c2a6876185578504a7f24acac1e084fe1af74cf" => :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