homebrew-core/Formula/qt-mariadb.rb

99 lines
2.9 KiB
Ruby

class QtMariadb < Formula
desc "Qt SQL Database Driver"
homepage "https://www.qt.io/"
url "https://download.qt.io/official_releases/qt/6.3/6.3.2/submodules/qtbase-everywhere-src-6.3.2.tar.xz"
sha256 "7929ba4df870b6b30870bc0aed2525cfc606ed7091107b23cf7ed7e434caa9a6"
license all_of: ["LGPL-2.1-only", "LGPL-3.0-only"]
livecheck do
formula "qt"
end
bottle do
sha256 cellar: :any, arm64_monterey: "fb309cb56921c630d65a6fb3967a15942104dc5ac803b2d4f81c1a1c4c6e6295"
sha256 cellar: :any, arm64_big_sur: "807e5b1141a4b1939aa0c8466fb90147ac928c66202cf03d1fceb51ea5fbd80a"
sha256 cellar: :any, monterey: "a7c4949feef24e5a106090c74b0f27e281dc67a282113d363e81525880cdaa72"
sha256 cellar: :any, big_sur: "020e2a72cc0ba445bf381bfdd6593663b061369922a7270ff437de5be421ec5e"
sha256 cellar: :any, catalina: "2e5bef41a19958aa484a8bfedd86c8659fa0ec08615db2fae2581a4590a79508"
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"
fails_with gcc: "5"
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::addLibraryPath("#{share}/qt/plugins");
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