qt.rb 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. # Patches for Qt must be at the very least submitted to Qt's Gerrit codereview
  2. # rather than their bug-report Jira. The latter is rarely reviewed by Qt.
  3. class Qt < Formula
  4. desc "Cross-platform application and UI framework"
  5. homepage "https://www.qt.io/"
  6. url "https://download.qt.io/archive/qt/5.10/5.10.1/single/qt-everywhere-src-5.10.1.tar.xz"
  7. mirror "https://mirrorservice.org/sites/download.qt-project.org/official_releases/qt/5.10/5.10.1/single/qt-everywhere-src-5.10.1.tar.xz"
  8. sha256 "05ffba7b811b854ed558abf2be2ddbd3bb6ddd0b60ea4b5da75d277ac15e740a"
  9. head "https://code.qt.io/qt/qt5.git", :branch => "5.10.1", :shallow => false
  10. bottle do
  11. sha256 "8b4bad005596a5f8790150fe455db998ac2406f4e0f04140d6656205d844d266" => :high_sierra
  12. sha256 "9c488554935fb573554a4e36d36d3c81e47245b7fefc4b61edef894e67ba1740" => :sierra
  13. sha256 "c0407afba5951df6cc4c6f6c1c315972bd41c99cecb4e029919c4c15ab6f7bdc" => :el_capitan
  14. end
  15. keg_only "Qt 5 has CMake issues when linked"
  16. option "with-docs", "Build documentation"
  17. option "with-examples", "Build examples"
  18. deprecated_option "with-mysql" => "with-mysql-client"
  19. # OS X 10.7 Lion is still supported in Qt 5.5, but is no longer a reference
  20. # configuration and thus untested in practice. Builds on OS X 10.7 have been
  21. # reported to fail: <https://github.com/Homebrew/homebrew/issues/45284>.
  22. depends_on :macos => :mountain_lion
  23. depends_on "pkg-config" => :build
  24. depends_on :xcode => :build
  25. depends_on "mysql-client" => :optional
  26. depends_on "postgresql" => :optional
  27. # Restore `.pc` files for framework-based build of Qt 5 on OS X. This
  28. # partially reverts <https://codereview.qt-project.org/#/c/140954/> merged
  29. # between the 5.5.1 and 5.6.0 releases. (Remove this as soon as feasible!)
  30. #
  31. # Core formulae known to fail without this patch (as of 2016-10-15):
  32. # * gnuplot (with `--with-qt` option)
  33. # * mkvtoolnix (with `--with-qt` option, silent build failure)
  34. # * poppler (with `--with-qt` option)
  35. patch do
  36. url "https://raw.githubusercontent.com/Homebrew/formula-patches/e8fe6567/qt5/restore-pc-files.patch"
  37. sha256 "48ff18be2f4050de7288bddbae7f47e949512ac4bcd126c2f504be2ac701158b"
  38. end
  39. # Fix compile error on macOS 10.13 around QFixed:
  40. # https://github.com/Homebrew/homebrew-core/issues/27095
  41. # https://bugreports.qt.io/browse/QTBUG-67545
  42. patch do
  43. url "https://raw.githubusercontent.com/z00m1n/formula-patches/0de0e229/qt/QTBUG-67545.patch"
  44. sha256 "4a115097c7582c7dce4207f5500d13feb8c990eb8a05a43f41953985976ebe6c"
  45. end
  46. # Fix compile error on macOS 10.13 caused by qtlocation dependency
  47. # mapbox-gl-native using Boost 1.62.0 does not build with C++ 17:
  48. # https://github.com/Homebrew/homebrew-core/issues/27095
  49. # https://bugreports.qt.io/browse/QTBUG-67810
  50. patch do
  51. url "https://raw.githubusercontent.com/z00m1n/formula-patches/a1a1f0dd/qt/QTBUG-67810.patch"
  52. sha256 "8ee0bf71df1043f08ebae3aa35036be29c4d9ebff8a27e3b0411a6bd635e9382"
  53. end
  54. def install
  55. args = %W[
  56. -verbose
  57. -prefix #{prefix}
  58. -release
  59. -opensource -confirm-license
  60. -system-zlib
  61. -qt-libpng
  62. -qt-libjpeg
  63. -qt-freetype
  64. -qt-pcre
  65. -nomake tests
  66. -no-rpath
  67. -pkg-config
  68. -dbus-runtime
  69. -no-assimp
  70. ]
  71. args << "-nomake" << "examples" if build.without? "examples"
  72. if build.with? "mysql-client"
  73. args << "-plugin-sql-mysql"
  74. (buildpath/"brew_shim/mysql_config").write <<~EOS
  75. #!/bin/sh
  76. if [ x"$1" = x"--libs" ]; then
  77. mysql_config --libs | sed "s/-lssl -lcrypto//"
  78. else
  79. exec mysql_config "$@"
  80. fi
  81. EOS
  82. chmod 0755, "brew_shim/mysql_config"
  83. args << "-mysql_config" << buildpath/"brew_shim/mysql_config"
  84. end
  85. args << "-plugin-sql-psql" if build.with? "postgresql"
  86. system "./configure", *args
  87. system "make"
  88. ENV.deparallelize
  89. system "make", "install"
  90. if build.with? "docs"
  91. system "make", "docs"
  92. system "make", "install_docs"
  93. end
  94. # Some config scripts will only find Qt in a "Frameworks" folder
  95. frameworks.install_symlink Dir["#{lib}/*.framework"]
  96. # The pkg-config files installed suggest that headers can be found in the
  97. # `include` directory. Make this so by creating symlinks from `include` to
  98. # the Frameworks' Headers folders.
  99. Pathname.glob("#{lib}/*.framework/Headers") do |path|
  100. include.install_symlink path => path.parent.basename(".framework")
  101. end
  102. # Move `*.app` bundles into `libexec` to expose them to `brew linkapps` and
  103. # because we don't like having them in `bin`.
  104. # (Note: This move breaks invocation of Assistant via the Help menu
  105. # of both Designer and Linguist as that relies on Assistant being in `bin`.)
  106. libexec.mkpath
  107. Pathname.glob("#{bin}/*.app") { |app| mv app, libexec }
  108. end
  109. def caveats; <<~EOS
  110. We agreed to the Qt opensource license for you.
  111. If this is unacceptable you should uninstall.
  112. EOS
  113. end
  114. test do
  115. (testpath/"hello.pro").write <<~EOS
  116. QT += core
  117. QT -= gui
  118. TARGET = hello
  119. CONFIG += console
  120. CONFIG -= app_bundle
  121. TEMPLATE = app
  122. SOURCES += main.cpp
  123. EOS
  124. (testpath/"main.cpp").write <<~EOS
  125. #include <QCoreApplication>
  126. #include <QDebug>
  127. int main(int argc, char *argv[])
  128. {
  129. QCoreApplication a(argc, argv);
  130. qDebug() << "Hello World!";
  131. return 0;
  132. }
  133. EOS
  134. system bin/"qmake", testpath/"hello.pro"
  135. system "make"
  136. assert_predicate testpath/"hello", :exist?
  137. assert_predicate testpath/"main.o", :exist?
  138. system "./hello"
  139. end
  140. end