homebrew-core/Formula/cgal.rb
2019-01-17 15:24:28 +08:00

58 lines
1.9 KiB
Ruby

class Cgal < Formula
desc "Computational Geometry Algorithm Library"
homepage "https://www.cgal.org/"
url "https://github.com/CGAL/cgal/releases/download/releases%2FCGAL-4.13/CGAL-4.13.tar.xz"
sha256 "3e3dd7a64febda58be54c3cbeba329ab6a73b72d4d7647ba4931ecd1fad0e3bc"
bottle do
cellar :any
rebuild 1
sha256 "10d0ab35e7ce05e43212ece94de295f0e9e65697f4487850d23b3a1872946e02" => :mojave
sha256 "71758829c6fe7cde95dddef2832a9dd1eda51bc3b5a2cc60b8f3b330f629efb2" => :high_sierra
sha256 "0a368594840007d0a433b702ef5392f332d38e7bc68a83ffc4771f8ca5fa5877" => :sierra
end
depends_on "cmake" => :build
depends_on "boost"
depends_on "eigen"
depends_on "gmp"
depends_on "mpfr"
def install
args = std_cmake_args + %W[
-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON
-DCMAKE_INSTALL_NAME_DIR=#{HOMEBREW_PREFIX}/lib
-DWITH_Eigen3=ON
-DWITH_LAPACK=ON
-DWITH_CGAL_Qt5=OFF
-DWITH_CGAL_ImageIO=OFF
]
system "cmake", ".", *args
system "make", "install"
end
test do
# https://doc.cgal.org/latest/Algebraic_foundations/Algebraic_foundations_2interoperable_8cpp-example.html
(testpath/"surprise.cpp").write <<~EOS
#include <CGAL/basic.h>
#include <CGAL/Coercion_traits.h>
#include <CGAL/IO/io.h>
template <typename A, typename B>
typename CGAL::Coercion_traits<A,B>::Type
binary_func(const A& a , const B& b){
typedef CGAL::Coercion_traits<A,B> CT;
CGAL_static_assertion((CT::Are_explicit_interoperable::value));
typename CT::Cast cast;
return cast(a)*cast(b);
}
int main(){
std::cout<< binary_func(double(3), int(5)) << std::endl;
std::cout<< binary_func(int(3), double(5)) << std::endl;
return 0;
}
EOS
system ENV.cxx, "-I#{include}", "-L#{lib}", "-lCGAL",
"surprise.cpp", "-o", "test"
assert_equal "15\n15", shell_output("./test").chomp
end
end