Hello,

Le Jeudi 18 Mai 2006 12:54, Simon Stelling a écrit :
> I have no clue what cmake is or what you are trying to, so I just
> comment on a few other things I catched:

Thanks for your comments,

Cmake is a autotools/autoconf replacement (http://www.cmake.org), it is the 
new build system for kde.
Some projects using cmake need to have a separate builddir (kde does, and some 
others).

In this eclass, there is an helper function to use cmake options according to 
useflags (like use_enable), and the support for building out of the sources 
(in $WORKDIR/cmake-build)

> [...]
>
> > cmake_compile() {
> > cmake_install() {
>
> aren't these meant to be cmake-src_compile/cmake-src_install?
Well, it is for cmake_install indead, but cmake_compile need that 
cmake_configure has been done before... so I consider cmake_configure and 
cmake_compile more like econf and emake commands.
So I've added a separate  cmake_src_compile.

I've updated the eclass, according to your comments, and renamed cmake_install 
to cmake_src_install.
I've also made the installation prefix customable with INSTALL_PREFIX envvar.

Here is an ebuild example for using this cmake eclass:
http://dev.inzenet.org/~panard/patches/gentoo-overlay/app-editors/yzis/yzis-0.1_pre20060518.ebuild

Thanks,

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"

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"
        local OPTION="$2"
        shift 2
        OPTION=${OPTION:-"WITH_${USEFLAG}"}
        local E_VALUE="ON" # value if use
        local D_VALUE="OFF" # value if not used
        if [ ! -z "$1" ]; then
                case $1 in
                        [oO][nN])
                                ;;
                        [oO][fF][fF])
                                # 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}'"

        INSTALL_PREFIX="${INSTALL_PREFIX:-/usr}"

        mkdir -p ${BUILDDIR}
        cd ${BUILDDIR}
        echo cmake ${S} -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
                        $(cmake_use_option debug CMAKE_BUILD_TYPE debugfull) $*
        cmake ${S} -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
                        $(cmake_use_option debug CMAKE_BUILD_TYPE debugfull) $*
        ret=$?
        cd ${OLDPWD}
        return $ret
}

cmake_compile() {
        cd ${BUILDDIR} || die "no BUILDDIR configured"
        emake $*
        ret=$?
        cd ${OLDPWD}
        return $ret
}

cmake_src_compile() {
        cmake_configure $* || die "Configuration failed"
        cmake_compile || die "Compilation failed"
}

cmake_src_install() {
        cd ${BUILDDIR}
        emake DESTDIR="${D}" $* install || die "Installation failed"
        ret=$?
        rm -rf ${BUILDDIR}
        cd ${OLDPWD}
        return $ret
}

EXPORT_FUNCTIONS src_compile src_install

Attachment: pgpA49AijCUAk.pgp
Description: PGP signature

Reply via email to