jackett 0.22.1382
[Homebrew/homebrew-core.git] / Formula / c / curlcpp.rb
blob6dc03410310ae182d73e8c746fc612a28b39bc55
1 class Curlcpp < Formula
2   desc "Object oriented C++ wrapper for CURL (libcurl)"
3   homepage "https://josephp91.github.io/curlcpp"
4   url "https://github.com/JosephP91/curlcpp/archive/refs/tags/3.1.tar.gz"
5   sha256 "ba7aeed9fde9e5081936fbe08f7a584e452f9ac1199e5fabffbb3cfc95e85f4b"
6   license "MIT"
7   revision 1
9   bottle do
10     sha256 cellar: :any,                 arm64_sequoia: "c436767f9b31dfaf4bcb0b173c8a05c338954f2cfe310cc6a5a4b0abd07f19e1"
11     sha256 cellar: :any,                 arm64_sonoma:  "cf6ac3204eff880beee1d8e79aad0fcff5df2a9a9c7599b969a313892ea0d579"
12     sha256 cellar: :any,                 arm64_ventura: "fc4bb565327be35db477f5c94e99ac541107af06b9139a42484aba7f631c00b2"
13     sha256 cellar: :any,                 sonoma:        "38e40220123c5b9ffde970e0ba30d802b54caef5782019935677f597829ec37a"
14     sha256 cellar: :any,                 ventura:       "5676d84a6ce7dc9f2a65f19cb8752ca24f5f974c27d315e421b7ca1e82bdcdbe"
15     sha256 cellar: :any_skip_relocation, x86_64_linux:  "c7b8f28ef1d8782146a24e1687c1044b5f10149c721b098bf4514f8186b9649d"
16   end
18   depends_on "cmake" => :build
20   uses_from_macos "curl"
22   # remove use of CURLOPT_CLOSEPOLICY (removed since curl 8.10+), upstream pr ref, https://github.com/JosephP91/curlcpp/pull/159
23   patch do
24     on_linux do
25       url "https://github.com/JosephP91/curlcpp/commit/bc3800510f30ed74c90227b166d134cd13fd63cf.patch?full_index=1"
26       sha256 "0954b32d0304ad9b4acecf3f647242b2c5736f4c6576a390e665e57883dcf10f"
27     end
28   end
30   def install
31     system "cmake", "-S", ".", "-B", "build", "-DBUILD_SHARED_LIBS=SHARED", *std_cmake_args
32     system "cmake", "--build", "build"
33     system "cmake", "--install", "build"
34   end
36   test do
37     (testpath/"test.cpp").write <<~CPP
38       #include <iostream>
39       #include <ostream>
41       #include "curlcpp/curl_easy.h"
42       #include "curlcpp/curl_form.h"
43       #include "curlcpp/curl_ios.h"
44       #include "curlcpp/curl_exception.h"
46       using std::cout;
47       using std::endl;
48       using std::ostringstream;
50       using curl::curl_easy;
51       using curl::curl_ios;
52       using curl::curl_easy_exception;
53       using curl::curlcpp_traceback;
55       int main() {
56           // Create a stringstream object
57           ostringstream str;
58           // Create a curl_ios object, passing the stream object.
59           curl_ios<ostringstream> writer(str);
61           // Pass the writer to the easy constructor and watch the content returned in that variable!
62           curl_easy easy(writer);
63           easy.add<CURLOPT_URL>("https://google.com");
64           easy.add<CURLOPT_FOLLOWLOCATION>(1L);
66           try {
67               easy.perform();
68           } catch (curl_easy_exception &error) {
69               // If you want to print the last error.
70               std::cerr<<error.what()<<std::endl;
72               // If you want to print the entire error stack you can do
73               error.print_traceback();
74           }
75           return 0;
76       }
77     CPP
79     system ENV.cxx, "-std=c++11", "test.cpp", "-L#{lib}", "-lcurlcpp", "-lcurl", "-o", "test"
80     system "./test"
81   end
82 end