forked from ahmadia/homebrew-science
-
Notifications
You must be signed in to change notification settings - Fork 0
/
alpscore.rb
84 lines (72 loc) · 2.63 KB
/
alpscore.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
73
74
75
76
77
78
79
80
81
82
83
84
class Alpscore < Formula
desc "Applications and Libraries for Physics Simulations"
homepage "http://alpscore.org"
url "https://github.com/ALPSCore/ALPSCore/archive/v0.5.5.tar.gz"
sha256 "23612813734e6bf8c3fdabd58f6d71cebbe9e9cbfec80e84880099761789dbc7"
head "https://github.com/ALPSCore/ALPSCore.git"
bottle do
cellar :any
sha256 "08548b76a25fe65a0f28acaa7162c68950c804b3cb12d6ef54d966ef909b1c70" => :sierra
sha256 "596fec4526c2da6ced5d5eea1faa258bca70babde767d229132e9a991f9de199" => :el_capitan
sha256 "bc752627b91140b55c3c10dc4bcb78229e651b1b068a321ed9e96b5bcc9bd6b3" => :yosemite
sha256 "a4760d15227341ea0ea77e2a7170ed9da50622cf87ba1acf8dbf0fa2957e7791" => :mavericks
end
option :cxx11
option "with-test", "Build and run shipped tests"
option "with-doc", "Build documentation"
option "with-static", "Build static instead of shared libraries"
depends_on "cmake" => :build
depends_on :mpi => [:cc, :cxx, :recommended]
boost_options = []
boost_options << "c++11" if build.cxx11?
depends_on "boost" => boost_options
depends_on "hdf5" => (build.cxx11? ? ["c++11"] : [])
def install
ENV.cxx11 if build.cxx11?
args = std_cmake_args
args.delete "-DCMAKE_BUILD_TYPE=None"
args << "-DCMAKE_BUILD_TYPE=Release"
if build.with? "static"
args << "-DALPS_BUILD_STATIC=ON"
args << "-DALPS_BUILD_SHARED=OFF"
else
args << "-DALPS_BUILD_STATIC=OFF"
args << "-DALPS_BUILD_SHARED=ON"
end
args << ("-DENABLE_MPI=" + ((build.with? "mpi") ? "ON" : "OFF"))
args << ("-DDocumentation=" + ((build.with? "doc") ? "ON" : "OFF"))
args << ("-DTesting=" + ((build.with? "test") ? "ON" : "OFF"))
mkdir "tmp" do
args << ".."
system "cmake", *args
system "make"
system "make", "test" if build.with? "test"
system "make", "install"
end
end
test do
(testpath/"test.cpp").write <<-EOS.undent
#include <alps/mc/api.hpp>
#include <alps/mc/mcbase.hpp>
#include <alps/accumulators.hpp>
#include <alps/params.hpp>
using namespace std;
int main()
{
alps::accumulators::accumulator_set set;
set << alps::accumulators::FullBinningAccumulator<double>("a");
set["a"] << 2.9 << 3.1;
alps::params p;
p["myparam"] = 1.0;
}
EOS
args_compile = [
"test.cpp",
"-lalps-accumulators", "-lalps-hdf5", "-lalps-utilities", "-lalps-params",
"-lboost_filesystem-mt", "-lboost_system-mt", "-lboost_program_options-mt"
]
args_compile << "-o" << "test"
system ((build.with? "mpi") ? "mpicxx" : ENV.cxx), *args_compile
system "./test"
end
end