homebrew-core/Formula/jsoncpp.rb
2017-06-26 07:47:02 -07:00

46 lines
1.5 KiB
Ruby

class Jsoncpp < Formula
desc "Library for interacting with JSON"
homepage "https://github.com/open-source-parsers/jsoncpp"
url "https://github.com/open-source-parsers/jsoncpp/archive/1.8.1.tar.gz"
sha256 "858db2faf348f89fdf1062bd3e79256772e897e7f17df73e0624edf004f2f9ac"
head "https://github.com/open-source-parsers/jsoncpp.git"
bottle do
cellar :any
sha256 "fef689f5e1d886e69225bd364bcd3e8bc156b437da6d7ef15ab3a57652587405" => :sierra
sha256 "fe22dfd17f24ea45a49724ec0f733f0e0d7fe0d80c6166cef8efcedc86778b7d" => :el_capitan
sha256 "aaec56b3a60c8ea4807a3d8fc6e6a7be463cd72bcb1a33520c2aa982eb0045a0" => :yosemite
end
needs :cxx11
depends_on "cmake" => :build
def install
ENV.cxx11
system "cmake", ".", *std_cmake_args,
"-DBUILD_STATIC_LIBS=ON",
"-DBUILD_SHARED_LIBS=ON",
"-DJSONCPP_WITH_CMAKE_PACKAGE=ON",
"-DJSONCPP_WITH_TESTS=OFF",
"-DJSONCPP_WITH_POST_BUILD_UNITTEST=OFF"
system "make", "install"
end
test do
(testpath/"test.cpp").write <<-EOS.undent
#include <json/json.h>
int main() {
Json::Value root;
Json::Reader reader;
return reader.parse("[1, 2, 3]", root) ? 0: 1;
}
EOS
system ENV.cxx, "test.cpp", "-o", "test",
"-I#{include}/jsoncpp",
"-L#{lib}",
"-ljsoncpp"
system "./test"
end
end