homebrew-core/Formula/dlib.rb
2018-01-23 00:28:03 -08: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.9.tar.bz2"
sha256 "ec6374745d24b53568ae4d171b2ad86d102ae238dbdb093b462d5c8ae48b65b9"
head "https://github.com/davisking/dlib.git"
bottle do
cellar :any
sha256 "ef3b081c16dd4929066f2ea4612adb800aaa67a7f3bda3a229d07ecba8edb5ce" => :high_sierra
sha256 "58eea7acdbe59d13bdc7fd788f2b989700b257240eaa0cf52245c8649bde5c0a" => :sierra
sha256 "d442b43b991e78aa8961d3672007517dd11dfba480baad493307b94127bad8ea" => :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
#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