homebrew-core/Formula/cpprestsdk.rb
2018-11-08 23:08:26 +01:00

46 lines
1.8 KiB
Ruby

class Cpprestsdk < Formula
desc "C++ libraries for cloud-based client-server communication"
homepage "https://github.com/Microsoft/cpprestsdk"
# pull from git tag to get submodules
url "https://github.com/Microsoft/cpprestsdk.git",
:tag => "v2.10.7",
:revision => "c4cef129e880a3f9c23a480e8c983793963173bb"
revision 1
head "https://github.com/Microsoft/cpprestsdk.git", :branch => "development"
bottle do
cellar :any
sha256 "957e6be91b28107937d54275967f1db883aa293cd260089a9221d945bab18636" => :mojave
sha256 "f017c3a42823f5d5674ddbcb68a913b54122370a6d851eebb0747d1b1ac3b7bc" => :high_sierra
sha256 "62e771a147bc57ab1a9168e14d68d5b187e07f4dae348704f44e8b589f4ff495" => :sierra
end
depends_on "cmake" => :build
depends_on "boost"
depends_on "openssl"
def install
system "cmake", "-DBUILD_SAMPLES=OFF", "-DBUILD_TESTS=OFF", "Release", *std_cmake_args
system "make", "install"
end
test do
(testpath/"test.cc").write <<~EOS
#include <iostream>
#include <cpprest/http_client.h>
int main() {
web::http::client::http_client client(U("https://github.com/"));
std::cout << client.request(web::http::methods::GET).get().extract_string().get() << std::endl;
}
EOS
flags = ["-stdlib=libc++", "-std=c++11", "-I#{include}",
"-I#{Formula["boost"].include}",
"-I#{Formula["openssl"].include}", "-L#{lib}",
"-L#{Formula["openssl"].lib}", "-L#{Formula["boost"].lib}",
"-lssl", "-lcrypto", "-lboost_random", "-lboost_chrono",
"-lboost_thread-mt", "-lboost_system-mt", "-lboost_regex",
"-lboost_filesystem", "-lcpprest"] + ENV.cflags.to_s.split
system ENV.cxx, "-o", "test_cpprest", "test.cc", *flags
system "./test_cpprest"
end
end