2017-08-13 19:36:29 +00:00
|
|
|
class Dlib < Formula
|
|
|
|
desc "C++ library for machine learning"
|
|
|
|
homepage "http://dlib.net/"
|
2018-10-25 16:24:54 +00:00
|
|
|
url "http://dlib.net/files/dlib-19.16.tar.bz2"
|
|
|
|
sha256 "37308406c2b1459a70f21ec2fd7bdc922277659534c708323cb28d6e8e4764a8"
|
2017-08-13 19:36:29 +00:00
|
|
|
head "https://github.com/davisking/dlib.git"
|
|
|
|
|
2017-08-13 19:43:20 +00:00
|
|
|
bottle do
|
2018-03-20 05:35:00 +00:00
|
|
|
cellar :any_skip_relocation
|
2018-10-25 16:33:56 +00:00
|
|
|
sha256 "fea59bd6ec83be1bece0a71a691caa565403f33979aaa10dd2d84f3ff817caac" => :mojave
|
|
|
|
sha256 "0f87f8f25d8b27daa2bc02094402b120f4a7aa3aa3610a66c2cc9760eadb081f" => :high_sierra
|
|
|
|
sha256 "c748860e5d6ad042afbaacb07749d32f0a287ae2fe4097cf13f29fd8ea65cdeb" => :sierra
|
2017-08-13 19:43:20 +00:00
|
|
|
end
|
|
|
|
|
2017-08-13 19:36:29 +00:00
|
|
|
depends_on "cmake" => :build
|
|
|
|
depends_on "jpeg"
|
|
|
|
depends_on "libpng"
|
2018-09-17 09:13:37 +00:00
|
|
|
depends_on :macos => :el_capitan # needs thread-local storage
|
2017-08-13 19:36:29 +00:00
|
|
|
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"
|
2018-05-28 08:12:45 +00:00
|
|
|
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
|
2017-08-13 19:36:29 +00:00
|
|
|
|
|
|
|
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
|
2017-10-18 10:10:48 +00:00
|
|
|
(testpath/"test.cpp").write <<~EOS
|
2017-08-13 19:36:29 +00:00
|
|
|
#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
|