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-22.12.0.tar.xz" sha256 "d9aa9cacdfbd0f8e98fc2b3bb008e645597ed480685757c3e7bc74b4278d15c0" 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: "c4f2a399329c548d6a25a02377306de52e1cfb0ecdf9406167458a442238761f" sha256 arm64_monterey: "bb025511cc1b749bcccc7430a7c0dc43a1d6dd9518420e706040490d1ffaaa33" sha256 arm64_big_sur: "ee8389bcc3bed1ed712fa1fb5785f90fb48280c85a3bf8ea32ab31c2653d74d9" sha256 ventura: "de3c6978b3dedc8a598fab3454d65fa246de9bbfd3c9d895279c3e1340ea8912" sha256 monterey: "a2b52746a5ab84ce9ab439a2a2ec0351a2c714e53ed44d31151b4571ad36da64" sha256 big_sur: "82df8bd88a6d03ffbbd6179aa162da72eff9d3038737f34a162c5b7a85509565" sha256 x86_64_linux: "309a524025f6f1aac579232742613386e60198661bcbfbfab5d96cd7cf1eb61e" 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