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-0.80.0.tar.xz" sha256 "4d3ca6b79bc13b8e24092e34f83ef5f387f3bb0bbd7359a6c078e09c696d104f" head "https://anongit.freedesktop.org/git/poppler/poppler.git" bottle do sha256 "dd48b34109a79cf0e69ecfc337f8c2be7f51bd45aa4c60b37d8a10df5de2a91b" => :catalina sha256 "7bbe9bb66ad004191666a91d40604cb53afc72ac2164f516c91d94cde51ee822" => :mojave sha256 "f1d895dfd2f065bde6f022a5a032857a9f309e0b9105844a33f26ad1680c3155" => :high_sierra sha256 "d4e41ad3122828932ba39ef6eb86ea65bca73ca546e28e013adc0b87fe0927e3" => :sierra 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" depends_on "libpng" depends_on "libtiff" depends_on "little-cms2" depends_on "nss" depends_on "openjpeg" depends_on "qt" conflicts_with "pdftohtml", "pdf2image", "xpdf", :because => "poppler, pdftohtml, pdf2image, and xpdf install conflicting executables" resource "font-data" do url "https://poppler.freedesktop.org/poppler-data-0.4.9.tar.gz" sha256 "1f9c7e7de9ecd0db6ab287349e31bf815ca108a5a175cf906a90163bdbe32012" end def install ENV.cxx11 args = std_cmake_args + %w[ -DBUILD_GTK_TESTS=OFF -DENABLE_CMS=lcms2 -DENABLE_GLIB=ON -DENABLE_QT5=ON -DENABLE_UNSTABLE_API_ABI_HEADERS=ON -DWITH_GObjectIntrospection=ON ] system "cmake", ".", *args system "make", "install" system "make", "clean" system "cmake", ".", "-DBUILD_SHARED_LIBS=OFF", *args system "make" lib.install "libpoppler.a" lib.install "cpp/libpoppler-cpp.a" lib.install "glib/libpoppler-glib.a" resource("font-data").stage do system "make", "install", "prefix=#{prefix}" end libpoppler = (lib/"libpoppler.dylib").readlink [ "#{lib}/libpoppler-cpp.dylib", "#{lib}/libpoppler-glib.dylib", "#{lib}/libpoppler-qt5.dylib", *Dir["#{bin}/*"], ].each do |f| macho = MachO.open(f) macho.change_dylib("@rpath/#{libpoppler}", "#{lib}/#{libpoppler}") macho.write! end end test do system "#{bin}/pdfinfo", test_fixtures("test.pdf") end end