Skip to content

Commit

Permalink
dlib: migrate from homebrew/science
Browse files Browse the repository at this point in the history
Closes #16762.

Signed-off-by: FX Coudert <fxcoudert@gmail.com>
  • Loading branch information
fxcoudert committed Aug 13, 2017
1 parent ac30b7a commit b38ebf5
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions Formula/dlib.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
class Dlib < Formula
desc "C++ library for machine learning"
homepage "http://dlib.net/"
url "http://dlib.net/files/dlib-19.4.tar.bz2"
sha256 "003f0508fe605cf397ad678c6976e5ec7db8472faabf06508d16ead205571372"
revision 1
head "https://github.com/davisking/dlib.git"

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

0 comments on commit b38ebf5

Please sign in to comment.