homebrew-core/Formula/cpprestsdk.rb
2019-03-21 08:34:16 +01:00

45 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.11",
:revision => "a325079f7e1976e0485a212d8921ce9b837c1f2f"
head "https://github.com/Microsoft/cpprestsdk.git", :branch => "development"
bottle do
cellar :any
sha256 "34978844867a32a49d8a8bc67a74ecde0e6701e4a3654df7483fc63d16ed06a5" => :mojave
sha256 "6a6fdef0fa6f0fe7bd72d483478be0d09b56beba4829dc2d9e549ccf39c4ae1b" => :high_sierra
sha256 "1b2f27ce343b8bddc60a1b04b52a518b486c35cc2dc614628efebb95390281a1" => :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