################################################################################
#
# qt4-cmake.cygclass - functions for building CMake-based Qt4 packages
#
# Part of cygport - Cygwin packaging application
# Copyright (C) 2006-2020 Cygport authors
# Provided by the Cygwin project <https://cygwin.com/>
#
# cygport is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# cygport is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with cygport.  If not, see <https://www.gnu.org/licenses/>.
#
################################################################################

#****h* Cygclasses/qt4-cmake.cygclass
#  SYNOPSIS
#  inherit qt4-cmake
#  DESCRIPTION
#  This cygclass builds Qt4-based packages which use the CMake build system.
#  INHERITS
#  cmake.cygclass, qt4.cygclass
#****

inherit cmake qt4

#****C* qt4-cmake.cygclass/qt4_cmake_compile
#  SYNOPSIS
#  cd $B
#  qt4_cmake_compile [OPTIONS]
#  DESCRIPTION
#  Calls cygcmake with options to tell CMake where the Qt4 development tools
#  are found, followed by cmake to compile the package.  Options, in the form
#  of -DVARIABLE=VALUE, are passed on to cygcmake.
#****
qt4_cmake_compile() {
	cygcmake \
		-DAUTOMOC4_EXECUTABLE=/usr/bin/automoc4 \
		-DQT_MOC_EXECUTABLE=${QT4_MOC} \
		-DQT_QMAKE_EXECUTABLE=${QT4_QMAKE} \
		-DQT_RCC_EXECUTABLE=${QT4_RCC} \
		-DQT_UIC_EXECUTABLE=${QT4_UIC} \
		-DQT_UIC3_EXECUTABLE=${QT4_UIC3} \
		-DQT_DBUSCPP2XML_EXECUTABLE=${QT4_BINDIR}/qdbuscpp2xml \
		-DQT_DBUSXML2CPP_EXECUTABLE=${QT4_BINDIR}/qdbusxml2cpp \
		-DQT_LRELEASE_EXECUTABLE=${QT4_LRELEASE} \
		-DQT_LUPDATE_EXECUTABLE=${QT4_BINDIR}/lupdate \
		-DQT_INCLUDE_DIR=${QT4_INCLUDEDIR} \
		-DQT_LIBRARY_DIR=${QT4_LIBDIR} \
		-DQT_PLUGINS_DIR=${QT4_PLUGINSDIR} \
		"${@}"

	if [ -f build.ninja ]
	then
		cygninja
	else
		cygmake
	fi
}

#****o* qt4-cmake.cygclass/src_compile (qt4-cmake)
#  DEFINITION
src_compile() {
	cd ${B}
	: ${CYGCMAKE_GENERATOR=Ninja}
	qt4_cmake_compile
}
#****

readonly -f qt4_cmake_compile
