homebrew-core/Formula/clhep.rb
2017-10-20 14:10:54 +01:00

56 lines
1.7 KiB
Ruby

class Clhep < Formula
desc "Class Library for High Energy Physics"
homepage "https://proj-clhep.web.cern.ch/proj-clhep/"
url "https://proj-clhep.web.cern.ch/proj-clhep/DISTRIBUTION/tarFiles/clhep-2.3.4.5.tgz"
sha256 "1199d04626cb8bc1307e282b143018691077cc61fe2f286a382030262eda8764"
bottle do
cellar :any
sha256 "ae015425dbf66a7df58e21f4997ea5c44ac82c9e3291711a77621e7ecdf4a0c3" => :high_sierra
sha256 "3a5b69586ffdc7d697a4f2dce52016f245a234819f166e7931ced97eea399117" => :sierra
sha256 "415c707d943967dde9a90fba1a740fcdbd497e01f0b51b82f31d583641e2e3dd" => :el_capitan
end
head do
url "https://gitlab.cern.ch/CLHEP/CLHEP.git"
depends_on "automake" => :build
depends_on "autoconf" => :build
end
depends_on "cmake" => :build
def install
# CLHEP is super fussy and doesn't allow source tree builds
dir = Dir.mktmpdir
cd dir do
args = std_cmake_args
if build.stable?
args << buildpath/"CLHEP"
else
args << buildpath
end
system "cmake", *args
system "make", "install"
end
end
test do
(testpath/"test.cpp").write <<~EOS
#include <iostream>
#include <Vector/ThreeVector.h>
int main() {
CLHEP::Hep3Vector aVec(1, 2, 3);
std::cout << "r: " << aVec.mag();
std::cout << " phi: " << aVec.phi();
std::cout << " cos(theta): " << aVec.cosTheta() << std::endl;
return 0;
}
EOS
system ENV.cxx, "-L#{lib}", "-lCLHEP", "-I#{include}/CLHEP",
testpath/"test.cpp", "-o", "test"
assert_equal "r: 3.74166 phi: 1.10715 cos(theta): 0.801784",
shell_output("./test").chomp
end
end