homebrew-core/Formula/qt-mariadb.rb

104 lines
3.1 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.0/submodules/qtbase-everywhere-src-6.3.0.tar.xz"
sha256 "b865aae43357f792b3b0a162899d9bf6a1393a55c4e5e4ede5316b157b1a0f99"
license all_of: ["LGPL-2.1-only", "LGPL-3.0-only"]
livecheck do
formula "qt"
end
bottle do
sha256 cellar: :any, arm64_monterey: "1cacdb48e2abaf6113b124e20e5bcb27aaa1563131773bbdc2b4b4b9fdb975fc"
sha256 cellar: :any, arm64_big_sur: "991b5dc7b2c45e72ef4954d75eca4e9f5ad04490a3587c3f5c1679afaea5a762"
sha256 cellar: :any, monterey: "af7d00c613b7e3d5f2a3fede78b95ef84bbcb1946407ef81576cd84aa13753bc"
sha256 cellar: :any, big_sur: "8c941b7941ff85541f32d6803e6f59ebca9bfccdddbeb00743b7e82a764bef26"
sha256 cellar: :any, catalina: "8810ea19b26d89585e3ac18b377694820625059d561a024117a2f94f61aa3cd0"
sha256 cellar: :any_skip_relocation, x86_64_linux: "47ed48b5567a90e1ed2f8210652eac95267527ef0529fe82dfe511f09fc60c87"
end
depends_on "cmake" => [:build, :test]
depends_on "mariadb"
depends_on "qt"
on_linux do
depends_on "gcc"
end
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