homebrew-core/Formula/qt-postgresql.rb

98 lines
3.1 KiB
Ruby

class QtPostgresql < Formula
desc "Qt SQL Database Driver"
homepage "https://www.qt.io/"
url "https://download.qt.io/official_releases/qt/6.4/6.4.2/submodules/qtbase-everywhere-src-6.4.2.tar.xz"
sha256 "a88bc6cedbb34878a49a622baa79cace78cfbad4f95fdbd3656ddb21c705525d"
license any_of: ["GPL-2.0-only", "GPL-3.0-only", "LGPL-3.0-only"]
livecheck do
formula "qt"
end
bottle do
sha256 cellar: :any, arm64_ventura: "4f7adfadbbd008639b7f165be4d224a0ab12fdcb52877c268577b9e40c87bd47"
sha256 cellar: :any, arm64_monterey: "342fa58e05477919d5a85bd7261f4e05059f97049867decc17cc31a878117809"
sha256 cellar: :any, arm64_big_sur: "31d5a603cab4a589ad824b292baf0c186a18f2ffbce4db7f5a8916a5d64e4aef"
sha256 cellar: :any, ventura: "5a0272e2af095507a0cf3e18bfb58a50f8123a3a75cc9580379bc8652ccf6f18"
sha256 cellar: :any, monterey: "c0c9da0bf33fac4b26130e7e2f60d4ba7c919460f38d96bf6828420a5871a3f7"
sha256 cellar: :any, big_sur: "1d73a634cb50c079e607caa855c474e6b49dc10c529cb743468307a1ca4700b1"
sha256 cellar: :any_skip_relocation, x86_64_linux: "3312296993e06625c77b36b6f22f70eb8ae65252406558e3f1b2500039fd82d6"
end
depends_on "cmake" => [:build, :test]
depends_on "libpq"
depends_on "qt"
fails_with gcc: "5"
def install
args = std_cmake_args + %W[
-DCMAKE_STAGING_PREFIX=#{prefix}
-DFEATURE_sql_ibase=OFF
-DFEATURE_sql_mysql=OFF
-DFEATURE_sql_oci=OFF
-DFEATURE_sql_odbc=OFF
-DFEATURE_sql_psql=ON
-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("QPSQL");
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