# Copyright 2025 Arniiiii lg3dx6fd@gmail.com
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit cmake

DESCRIPTION="Lightweight structured concurrency for C++20"
HOMEPAGE="https://github.com/hudson-trading/corral"

CORRAL_COMMIT="3505402a3a8ae4ad02e9661889178cbec523210d"

SRC_URI="https://github.com/hudson-trading/corral/archive/${CORRAL_COMMIT}.tar.gz -> ${P}.tar.gz"

S="${WORKDIR}/corral-${CORRAL_COMMIT}"

LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64"

IUSE="test examples	doc"

RESTRICT="!test? ( test )"

DEPEND="
	test? (
		dev-libs/boost
		<dev-cpp/catch-3.0.0:0
		dev-libs/openssl
	)
	examples? (
		dev-libs/boost
		dev-qt/qtbase
)
"

RDEPEND="${DEPEND}"

src_configure() {
	local mycmakeargs=(
		-DCMAKE_SKIP_INSTALL_RULES=OFF
		-DBUILD_TESTING=$(usex test ON OFF)
		-DSKIP_TESTS=$(usex test OFF ON)
		-DCORRAL_CATCH2=""
		-DCORRAL_BOOST="a" # here can be anything not same as ".*://.*"
		-DCORRAL_EXAMPLES=$(usex examples ON OFF)
		-DSKIP_EXAMPLES=$(usex examples OFF ON)

		# my default:
		-DFETCHCONTENT_QUIET=OFF
		--log-level=DEBUG
	)

	cmake_src_configure

}

src_install() {
	if use doc; then
		einstalldocs
	fi

	cmake_src_install
}