class QtMysql < Formula desc "Qt SQL Database Driver" homepage "https://www.qt.io/" url "https://download.qt.io/official_releases/qt/6.2/6.2.0/submodules/qtbase-everywhere-src-6.2.0.tar.xz" sha256 "fdfff0716d093bcb6bcd53746ce1d3c9701a6bf3326d47813866d43949b47769" license all_of: ["LGPL-2.1-only", "LGPL-3.0-only"] livecheck do formula "qt" end bottle do sha256 cellar: :any, arm64_big_sur: "ac2a2bd54a8101aaea80351a272ca0ce9d7f6473adc3852b29ec7d3d87ca27cc" sha256 cellar: :any, big_sur: "4471d064b9128b1b86ba6816b38b33e1eedd03eae4e25b5921d6f1705209d34d" sha256 cellar: :any, catalina: "78582f28387fe6d8b91891205817d78e27b5b86f9d4011c2e35946226cc5dcfe" sha256 cellar: :any, mojave: "9474ed480b7f475b1a63d440656dddf7bc51d8da2c98bcd12fea52dc9eeb172b" end depends_on "cmake" => [:build, :test] depends_on "mysql" depends_on "qt" conflicts_with "qt-mariadb", "qt-percona-server", because: "qt-mysql, qt-mariadb, and qt-percona-server install the same binaries" def install args = std_cmake_args + %W[ -DCMAKE_STAGING_PREFIX=#{prefix} -DFEATURE_sql_ibase=OFF -DFEATURE_sql_mysql=ON -DFEATURE_sql_oci=OFF -DFEATURE_sql_odbc=OFF -DFEATURE_sql_psql=OFF -DFEATURE_sql_sqlite=OFF ] cd "src/plugins/sqldrivers" do system "cmake", ".", *args system "cmake", "--build", "." system "cmake", "--install", "." end end test do (testpath/"CMakeLists.txt").write <<~EOS cmake_minimum_required(VERSION #{Formula["cmake"].version}) project(test VERSION 1.0.0 LANGUAGES CXX) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_AUTOUIC ON) find_package(Qt6 COMPONENTS Core Sql REQUIRED) add_executable(test main.cpp ) target_link_libraries(test PRIVATE Qt6::Core Qt6::Sql) EOS (testpath/"test.pro").write <<~EOS QT += core sql QT -= gui TARGET = test CONFIG += console debug CONFIG -= app_bundle TEMPLATE = app SOURCES += main.cpp EOS (testpath/"main.cpp").write <<~EOS #include #include #include int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); assert(db.isValid()); return 0; } EOS system "cmake", "-S", ".", "-B", "build", "-DCMAKE_BUILD_TYPE=Debug" system "cmake", "--build", "build" system "./build/test" ENV.delete "CPATH" system "qmake" system "make" system "./test" end end