class Poppler < Formula desc "PDF rendering library (based on the xpdf-3.0 code base)" homepage "https://poppler.freedesktop.org/" url "https://poppler.freedesktop.org/poppler-23.01.0.tar.xz" sha256 "fae9b88d3d5033117d38477b79220cfd0d8e252c278ec870ab1832501741fd94" license "GPL-2.0-only" head "https://gitlab.freedesktop.org/poppler/poppler.git", branch: "master" livecheck do url :homepage regex(/href=.*?poppler[._-]v?(\d+(?:\.\d+)+)\.t/i) end bottle do sha256 arm64_ventura: "1546bb264c34a32e44c8d7e4ee378821330288b186cfc1338e68c0896eeb32b9" sha256 arm64_monterey: "ba8444c9d5d4d44e73f252ea6176be2b5950c8c7cb72e7e14505eece2a0a1ce7" sha256 arm64_big_sur: "db73fae6ec03c5000f2f1482d5a8fce8d6f23348129c3fcf409fd1093c8bb3dd" sha256 ventura: "8fcad244e90f92db5034c1d027721ec28eccf89fdd6ca0c9bb6a816047bd4bb6" sha256 monterey: "1cdfa3e941029fa9e6bff4f74d07acd9fd2a743c1f9cd1732e9ae5ed9a61d317" sha256 big_sur: "784ef9b14271fd90ddf618eba37ad3f51b6bcc8c6fbb77c6876ad50846d4a877" sha256 x86_64_linux: "527bdf84a5918aa4db339ec38c9fc593c0f2b0c6ae799a5562efa01981eee1a3" end depends_on "cmake" => :build depends_on "gobject-introspection" => :build depends_on "pkg-config" => :build depends_on "cairo" depends_on "fontconfig" depends_on "freetype" depends_on "gettext" depends_on "glib" depends_on "jpeg-turbo" depends_on "libpng" depends_on "libtiff" depends_on "little-cms2" depends_on "nspr" depends_on "nss" depends_on "openjpeg" uses_from_macos "gperf" => :build uses_from_macos "curl", since: :catalina # 7.55.0 required by poppler uses_from_macos "zlib" conflicts_with "pdftohtml", "pdf2image", "xpdf", because: "poppler, pdftohtml, pdf2image, and xpdf install conflicting executables" fails_with gcc: "5" resource "font-data" do url "https://poppler.freedesktop.org/poppler-data-0.4.11.tar.gz" sha256 "2cec05cd1bb03af98a8b06a1e22f6e6e1a65b1e2f3816cb3069bb0874825f08c" end def install ENV.cxx11 # removes /usr/include from CFLAGS (not clear why) ENV["PKG_CONFIG_SYSTEM_INCLUDE_PATH"] = "/usr/include" if MacOS.version < :mojave args = std_cmake_args + %W[ -DBUILD_GTK_TESTS=OFF -DENABLE_BOOST=OFF -DENABLE_CMS=lcms2 -DENABLE_GLIB=ON -DENABLE_QT5=OFF -DENABLE_QT6=OFF -DENABLE_UNSTABLE_API_ABI_HEADERS=ON -DWITH_GObjectIntrospection=ON -DCMAKE_INSTALL_RPATH=#{rpath} ] system "cmake", "-S", ".", "-B", "build_shared", *args system "cmake", "--build", "build_shared" system "cmake", "--install", "build_shared" system "cmake", "-S", ".", "-B", "build_static", *args, "-DBUILD_SHARED_LIBS=OFF" system "cmake", "--build", "build_static" lib.install "build_static/libpoppler.a" lib.install "build_static/cpp/libpoppler-cpp.a" lib.install "build_static/glib/libpoppler-glib.a" resource("font-data").stage do system "make", "install", "prefix=#{prefix}" end end test do system bin/"pdfinfo", test_fixtures("test.pdf") end end