homebrew-core/Formula/qt-mariadb.rb

96 lines
2.8 KiB
Ruby

class QtMariadb < Formula
desc "Qt SQL Database Driver"
homepage "https://www.qt.io/"
url "https://download.qt.io/official_releases/qt/6.2/6.2.3/submodules/qtbase-everywhere-src-6.2.3.tar.xz"
sha256 "34d6d0072e197241463c417ad72610c3d44e2efd6062868e9a95283103d75df4"
license all_of: ["LGPL-2.1-only", "LGPL-3.0-only"]
livecheck do
formula "qt"
end
bottle do
sha256 cellar: :any, arm64_monterey: "6ee30746a2eef7c9d0f29e9343b6e5c395481485112df9c5adcf46f2795f016a"
sha256 cellar: :any, arm64_big_sur: "424504dd822c21cf4fe56f58ba2b76ffcce863876e976657128cc258ac65b8c8"
sha256 cellar: :any, monterey: "cf409955bcdb811c9e064be4090460e2183087a394edb312dc5d79da84e09f6f"
sha256 cellar: :any, big_sur: "04a2fca379b07afeafba02596234066ab7e604868d7e7b9ddf618752343e6555"
sha256 cellar: :any, catalina: "d92b742d9fbe8aa422b0429308a4b13461914f81f32669585422942d81344c2e"
end
depends_on "cmake" => [:build, :test]
depends_on "mariadb"
depends_on "qt"
conflicts_with "qt-mysql", "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 <QCoreApplication>
#include <QtSql>
#include <cassert>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QSqlDatabase db = QSqlDatabase::addDatabase("QMARIADB");
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