homebrew-core/Formula/dlib.rb
2018-05-28 10:30:09 +02:00

65 lines
2.1 KiB
Ruby

class Dlib < Formula
desc "C++ library for machine learning"
homepage "http://dlib.net/"
url "http://dlib.net/files/dlib-19.13.tar.bz2"
sha256 "fe90b94677f837c8f0bcb0bb450b313a422a9171ac682583a75052c58f80ba54"
head "https://github.com/davisking/dlib.git"
bottle do
cellar :any_skip_relocation
rebuild 1
sha256 "850809bf6ddc1db7c180d6ef4673b00fdf271790757097e2dbffe18be06d8d13" => :high_sierra
sha256 "d312a53d3b3a10ff658401fd0cf1fe9f2c37d4aa46c8b84d817ca355a89ad31b" => :sierra
sha256 "88778a5e22c7fb5e39c4c45359e0c19d28aae054363a666cd39aed3bb44ad161" => :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"
args << "-DUSE_SSE2_INSTRUCTIONS=ON" # SSE2 is present on all modern macOS hardware
unless build.bottle?
args << "-DUSE_AVX_INSTRUCTIONS=ON" if Hardware::CPU.avx?
args << "-DUSE_SSE4_INSTRUCTIONS=ON" if Hardware::CPU.sse4?
end
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