Hi, I needed to write a cmake eclass to build out of the sources. So, here is my cmake.eclass... I hope it will be usefull.
4 functions are defined : cmake_use_option <USEFLAG> [<OPTION> [<value if use> [<value else>]]] # eg: # USE=qt debug # cmake_use_option qt => -DWITH_qt=ON # cmake_use_option gtk => -DWITH_gtk=OFF # cmake_use_option qt ENABLE_QUI => -DENABLE_QUI=ON # cmake_use_option gtk ENABLE_GUI => -DENABLE_GUI=OFF # cmake_use_option gtk ENABLE_NOGUI OFF => -DENABLE_NOGUI=ON # cmake_use_option doc GENDOC full => # cmake_use_option html DOCFORMAT html text => -DGENDOC=text # cmake_use_option debug CMAKE_BUILD_TYPE debugfull => -DCMAKE_BUILD_TYPE=debugfull cmake_configure: create BUILDDIR, and run cmake with selected debug (and with prefix=/usr) cmake_compile emake in BUILDDIR cmake_install emake DESTDIR=$D install in BUILDDIR clean BUILDDIR Any comment appreciated... Beers, Panard -- HomePage: http://dev.inzenet.org/~panard/ Yzis : http://www.yzis.org Qomics : http://dev.inzenet.org/~panard/qomics Smileys : http://smileys.inzenet.org
# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
#
# Original Author: panard
# Purpose: cmake with a separate builddir
#
ECLASS="cmake"
INHERITED="$INHERITED $ECLASS"
DEPEND="dev-util/cmake"
RDEPEND=""
IUSE="debug"
BUILDDIR="${WORKDIR}/cmake-build"
# cmake option helper:
# cmake_use_option <USEFLAG> [<OPTION> [<value if use> [<value else>]]]
# eg:
# USE=qt debug
# cmake_use_option qt => -DWITH_qt=ON
# cmake_use_option gtk => -DWITH_gtk=OFF
# cmake_use_option qt ENABLE_QUI => -DENABLE_QUI=ON
# cmake_use_option gtk ENABLE_GUI => -DENABLE_GUI=OFF
# cmake_use_option gtk ENABLE_NOGUI OFF => -DENABLE_NOGUI=ON
# cmake_use_option doc GENDOC full =>
# cmake_use_option html DOCFORMAT html text => -DGENDOC=text
# cmake_use_option debug CMAKE_BUILD_TYPE debugfull =>
-DCMAKE_BUILD_TYPE=debugfull
#
cmake_use_option() {
local USEFLAG="$1"; shift
local OPTION="$1"; shift
if [ -z "${OPTION}" ]; then
OPTION="WITH_${USEFLAG}"
fi
local E_VALUE="ON" # value if use
local D_VALUE="OFF" # value if not used
if [ ! -z "$1" ]; then
case $1 in
on|On|oN|ON)
;;
off|ofF|oFf|oFF|Off|OfF|OFf|OFF)
# reverse values
E_VALUE="OFF"
D_VALUE="ON"
;;
*)
# non-boolean option
E_VALUE="$1"
D_VALUE="$2"
;;
esac
fi
local opt="-D${OPTION}="
if useq ${USEFLAG}; then
opt="${opt}${E_VALUE}"
elif [ ! -z "${D_VALUE}" ]; then
opt="${opt}${D_VALUE}"
else
opt=""
fi
echo ${opt}
}
cmake_configure() {
debug-print-function
debug-print "${FUNCNAME}: BUILDDIR is '${BUILDDIR}'"
mkdir -p ${BUILDDIR}
cd ${BUILDDIR}
vecho cmake ${S} -DCMAKE_INSTALL_PREFIX=/usr $(cmake_use_option debug
CMAKE_BUILD_TYPE debugfull) $*
cmake ${S} -DCMAKE_INSTALL_PREFIX=/usr $(cmake_use_option debug
CMAKE_BUILD_TYPE debugfull) $*
ret=$?
cd ${OLDPWD}
return $ret
}
cmake_compile() {
cd ${BUILDDIR}
emake $*
ret=$?
cd ${OLDPWD}
return $ret
}
cmake_install() {
cd ${BUILDDIR}
emake DESTDIR="${D}" $* install
ret=$?
rm -rf ${BUILDDIR}
cd ${OLDPWD}
return $ret
}
pgpdVWAqqefC9.pgp
Description: PGP signature
