Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions Formula/c/civetweb.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
class Civetweb < Formula
desc "C/C++ embeddable web server with optional CGI, SSL and Lua support"
homepage "https://github.com/civetweb/civetweb"
url "https://github.com/civetweb/civetweb/archive/refs/tags/v1.16.tar.gz"
sha256 "f0e471c1bf4e7804a6cfb41ea9d13e7d623b2bcc7bc1e2a4dd54951a24d60285"
license "MIT"
head "https://github.com/civetweb/civetweb.git", branch: "master"

depends_on "cmake" => :build
depends_on "openssl@3"

on_linux do
Comment thread
ferdymercury marked this conversation as resolved.
depends_on "zlib-ng-compat"
end

def install
args = %w[
-DBUILD_SHARED_LIBS=ON
-DCIVETWEB_BUILD_TESTING=FALSE
-DCIVETWEB_ENABLE_ASAN=OFF
-DCIVETWEB_ENABLE_CXX=ON
-DCIVETWEB_ENABLE_SSL=ON
-DCIVETWEB_ENABLE_SSL_DYNAMIC_LOADING=OFF
-DCIVETWEB_ENABLE_WEBSOCKETS=ON
-DCIVETWEB_ENABLE_X_DOM_SOCKET=ON
-DCIVETWEB_ENABLE_ZLIB=ON
-DCIVETWEB_SSL_OPENSSL_API_3_0=ON
-DCIVETWEB_SSL_OPENSSL_API_1_1=OFF
-DCIVETWEB_SSL_OPENSSL_API_1_0=OFF
-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=TRUE
]
odie "Remove CMake 4 workaround and -DUSE_X_DOM_SOCKET!" if version > "1.16"
# https://code.opensuse.org/package/civetweb/blob/master/f/civetweb.spec#_80
# CMake version fix: https://github.com/civetweb/civetweb/pull/1306/changes
args += %w[
-DCMAKE_C_FLAGS=-DUSE_X_DOM_SOCKET
-DCMAKE_CXX_FLAGS=-DUSE_X_DOM_SOCKET
-DCMAKE_POLICY_VERSION_MINIMUM=3.5
]
system "cmake", "-S", ".", "-B", "builddir", *args, *std_cmake_args
system "cmake", "--build", "builddir"
system "cmake", "--install", "builddir"
end

test do
(testpath/"test.c").write <<~C
#include "civetweb.h"
int main() {
printf("%d", mg_check_feature(0xFFF));
return 0;
}
C
system ENV.cc, "test.c", "-L#{lib}", "-lcivetweb", "-o", "test"
assert_match "2719", shell_output("./test")
end
end
Loading