# Description: A music player and library organizer.
# URL: https://www.clementine-player.org/
# Maintainer: Danny Rawlins, crux at romster dot me
# Depends on: boost crypto++ glew glu gst-plugins-bad gst-plugins-good gst-plugins-ugly protobuf qt5

name=clementine
version=1.4.0rc2
release=1
source=(https://github.com/clementine-player/Clementine/archive/$version/$name-$version.tar.gz)

build() {
	# make sure we do not have ccache masquerade directory in PATH
	# as cmake calls ccache directly, this avoids recursvely
	# calling ccache and CCACHE_PREFIX
	PATH=$(echo ${PATH} | awk -v RS=: -v ORS=: '/ccache/ {next} {print}' | sed 's/:*$//')

	# -Wl,--as-needed breaks linking
	#LDFLAGS=$(echo ${LDFLAGS} | awk -v RS=' ' -v ORS=' ' '/-Wl,--as-needed/ {next} {print}')

	sed -e 's|CRYPTOPP cryptopp|CRYPTOPP libcryptopp|' -i Clementine-$version/CMakeLists.txt

	cmake -S Clementine-$version -B build -G Ninja \
		-D CMAKE_INSTALL_PREFIX=/usr \
		-D CMAKE_BUILD_TYPE=Release \
		-D CMAKE_C_FLAGS_RELEASE="$CFLAGS" \
		-D CMAKE_CXX_FLAGS="$CXXFLAGS -Wno-catch-value" \
		-Wno-dev

	cmake --build build
	DESTDIR=$PKG cmake --install build
}
