homebrew-core/Formula/qt-postgresql.rb

93 lines
2.7 KiB
Ruby

class QtPostgresql < Formula
desc "Qt SQL Database Driver"
homepage "https://www.qt.io/"
url "https://download.qt.io/official_releases/qt/6.2/6.2.2/submodules/qtbase-everywhere-src-6.2.2.tar.xz"
sha256 "85ab9180180c2eaf84cd11ae4c6d5a6a69f2f8fd7260aaccfd91a3e7e7232c1a"
license all_of: ["GFDL-1.3-only", "GPL-2.0-only", "GPL-3.0-only", "LGPL-2.1-only", "LGPL-3.0-only"]
livecheck do
formula "qt"
end
bottle do
sha256 cellar: :any, arm64_monterey: "d7a9c5e4c288bad61ca3944084e0fac08e82994fa5642a301365c5cbacbbbe5b"
sha256 cellar: :any, arm64_big_sur: "24cabb1507fffbc1d9ec453233ab5565980f0594d0c3dc6a45344817c12e0e73"
sha256 cellar: :any, monterey: "dc2f87420d0d10690b6c805ec1e8a2e37b45b7c66ca502cc4ee0017c1c2a1a68"
sha256 cellar: :any, big_sur: "bb004d3236c4f77ee14eaf0e8dc637bf03431e6a89d0a18c174a562c0c11b21d"
sha256 cellar: :any, catalina: "898e43767f57c63b84b6e8e9c04fa8323f97fa3a225f542673bc3f250d90e37e"
end
depends_on "cmake" => [:build, :test]
depends_on "postgresql"
depends_on "qt"
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 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