Skip to content

Commit 4d346dd

Browse files
qcoro6 0.12.0
Add QCoro built against qt@6.
1 parent 0a3cfab commit 4d346dd

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

Formula/q/qcoro6.rb

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
class Qcoro6 < Formula
2+
desc "C++ Coroutines for Qt"
3+
homepage "https://qcoro.dev"
4+
url "https://github.com/qcoro/qcoro/archive/refs/tags/v0.12.0.tar.gz"
5+
sha256 "809afafab61593f994c005ca6e242300e1e3e7f4db8b5d41f8c642aab9450fbc"
6+
license "MIT"
7+
8+
depends_on "cmake" => [:build, :test]
9+
depends_on "qtbase"
10+
depends_on "qtdeclarative"
11+
depends_on "qtwebsockets"
12+
13+
def install
14+
system "cmake", "-S", ".", "-B", "build",
15+
"-DBUILD_SHARED_LIBS=ON",
16+
"-DCMAKE_INSTALL_RPATH=#{rpath}",
17+
"-DQCORO_BUILD_EXAMPLES=OFF",
18+
"-DQCORO_BUILD_TESTING=OFF",
19+
"-DUSE_QT_VERSION=6",
20+
*std_cmake_args
21+
system "cmake", "--build", "build"
22+
system "cmake", "--install", "build"
23+
end
24+
25+
test do
26+
(testpath/"CMakeLists.txt").write <<~CMAKE
27+
cmake_minimum_required(VERSION 3.16)
28+
project(QCoroTest LANGUAGES CXX)
29+
set(CMAKE_CXX_STANDARD 20)
30+
find_package(QCoro6 REQUIRED COMPONENTS Coro Core Network WebSockets Quick Qml Test)
31+
find_package(Qt6 REQUIRED COMPONENTS Core Network WebSockets Quick Qml Test)
32+
add_executable(testapp test.cpp)
33+
target_link_libraries(testapp PRIVATE
34+
QCoro6::Coro
35+
QCoro6::Core Qt6::Core
36+
QCoro6::Network Qt6::Network
37+
QCoro6::WebSockets Qt6::WebSockets
38+
QCoro6::Quick Qt6::Quick
39+
QCoro6::Qml Qt6::Qml
40+
QCoro6::Test Qt6::Test)
41+
qcoro_enable_coroutines()
42+
CMAKE
43+
44+
(testpath/"test.cpp").write <<~CPP
45+
#include <QCoroTask> // from QCoroCoro
46+
#include <QCoroSignal> // from QCoroCore
47+
#include <QCoroAbstractSocket> // from QCoroNetwork
48+
#include <QCoroWebSocket> // from QCoroWebSockets
49+
#include <QCoroImageProvider> // from QCoroQuick
50+
#include <QCoroQmlTask> // from QCoroQml
51+
#include <QCoroTest> // from QCoroTest
52+
int main(int argc, char **argv) {
53+
QCoro::Task<int> t = []() -> QCoro::Task<int> { co_return 42; }();
54+
return 0;
55+
}
56+
CPP
57+
58+
system "cmake", "-S", ".", "-B", "build"
59+
system "cmake", "--build", "build"
60+
system "./build/testapp"
61+
end
62+
end

0 commit comments

Comments
 (0)