homebrew-core/Formula/dlib.rb
2017-09-19 01:04:10 +02:00

58 lines
1.8 KiB
Ruby

class Dlib < Formula
desc "C++ library for machine learning"
homepage "http://dlib.net/"
url "http://dlib.net/files/dlib-19.7.tar.bz2"
sha256 "825dbe45e0d379a4e5584c2918b1e0cb37e9ed75657766fd7b2b4f3e05f892d6"
head "https://github.com/davisking/dlib.git"
bottle do
cellar :any
sha256 "49af9f842109f2d9c064a492afa6b98861cf28b22e75a63dc4e62c71661369af" => :high_sierra
sha256 "74a4d04a7b1fd715d15b7a6dfa2a9372c864f1d840f01cfbb56e7c0297cc6d04" => :sierra
sha256 "89626ef8537bb2a52362531dbe1478c826004918253bace1216ab2c4b54a5c8c" => :el_capitan
end
depends_on :macos => :el_capitan # needs thread-local storage
depends_on "cmake" => :build
depends_on "jpeg"
depends_on "libpng"
depends_on "openblas" => :optional
depends_on :x11 => :optional
needs :cxx11
def install
ENV.cxx11
args = std_cmake_args + %w[-DDLIB_USE_BLAS=ON -DDLIB_USE_LAPACK=ON]
args << "-DDLIB_NO_GUI_SUPPORT=ON" if build.without? "x11"
if build.with? "openblas"
args << "-Dcblas_lib=#{Formula["openblas"].opt_lib}/libopenblas.dylib"
args << "-Dlapack_lib=#{Formula["openblas"].opt_lib}/libopenblas.dylib"
else
args << "-Dcblas_lib=/usr/lib/libcblas.dylib"
args << "-Dlapack_lib=/usr/lib/liblapack.dylib"
end
mkdir "dlib/build" do
system "cmake", "..", *args
system "make", "install"
end
end
test do
(testpath/"test.cpp").write <<-EOS.undent
#include <dlib/logger.h>
dlib::logger dlog("example");
int main() {
dlog.set_level(dlib::LALL);
dlog << dlib::LINFO << "The answer is " << 42;
}
EOS
system ENV.cxx, "-std=c++11", "test.cpp", "-o", "test", "-I#{include}",
"-L#{lib}", "-ldlib"
assert_match /INFO.*example: The answer is 42/, shell_output("./test")
end
end