A little introduction: cmake is an alternative for autotools, more and more
packages are using it (and some new big ones are on the way, KDE4 for example).

I've wrote an eclass that makes writing ebuilds for such packages a little
easier - it provides an ecmake function that takes care of few needed variables,
prefix and such.

I'm open for discussion about it, the eclass currently is only in my overlay at
o.g.o. For example I've changed sys-power/ncpufreqd to use the cmake.eclass,
complete ebuild can be viewed at
http://overlays.gentoo.org/dev/nelchael/browser/sys-power/ncpufreqd/ncpufreqd-2.4.ebuild
(compare it to the in-tree version:
http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-power/ncpufreqd/ncpufreqd-2.4.ebuild?rev=1.1&view=markup
)

Following ebuilds (52 to be exact) have dev-util/cmake in {R,}DEPEND (so could
use the new eclass):

app-cdr/cdrkit-1.1.2
app-cdr/cdrkit-1.1.4
app-cdr/cdrkit-1.1.5.1
app-cdr/cdrkit-1.1.6
app-mobilephone/gammu-1.12.0
app-mobilephone/gammu-1.13.0
dev-cpp/eigen-1.0.5
dev-cpp/gccxml-0.6.0-r1
dev-cpp/gccxml-0.7.0_pre20060311
dev-db/mysql-community-5.1.14_beta-r1
dev-db/mysql-community-5.1.15_beta
dev-db/mysql-community-5.1.21_beta
dev-games/physfs-1.1.1
dev-php5/php-qt-0.1
dev-ruby/qt4-qtruby-1.4.8
dev-ruby/qt4-qtruby-1.4.9
dev-ruby/qt4-qtruby-1.4.9-r1
dev-util/dwarves-1.0_p1
dev-util/kdesvn-0.11.2
dev-util/kdesvn-0.12.1
dev-util/kdesvn-0.13.0
dev-util/kdesvn-0.14.0
games-fps/doomsday-1.9.0_beta5
games-puzzle/ksudoku-0.4
games-strategy/boson-0.13
games-strategy/hedgewars-0.9.0
games-strategy/hedgewars-0.9.0-r1
kde-misc/kbfx-0.4.9.3.1-r1
kde-misc/kgtk-0.9.1-r1
media-libs/libprojectm-1.01
media-libs/libprojectm-1.01-r1
media-plugins/libvisual-projectm-1.0
media-sound/mppenc-1.16
media-sound/musescore-0.6.1
media-sound/musescore-0.7.0.1
media-sound/rosegarden-1.5.1
net-p2p/museek+-0.1.13-r1
sci-astronomy/stellarium-0.9.0
sci-chemistry/avogadro-0.1.0
sci-chemistry/avogadro-0.2.0
sci-geosciences/marble-0.3
sci-geosciences/marble-0.4
sci-libs/vtk-5.0.3
sci-visualization/paraview-2.6.2
sys-apps/initng-0.6.10.1
sys-apps/initng-9999
sys-apps/initng-ifiles-0.1.4
sys-power/ncpufreqd-2.4
x11-themes/gtk-engines-qt-0.7_p20070327-r2
x11-themes/gtk-engines-qt-0.8
x11-themes/gtk-engines-qtcurve-0.55.0
x11-themes/qtcurve-0.55.0

-- 
Krzysiek Pawlik   <nelchael at gentoo.org>   key id: 0xBC555551
desktop-misc, desktop-dock, x86, java, apache, ppc...
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

#
# Original Author: nelchael
# Purpose: Automate src_install and src_compile for packages using cmake
#

inherit toolchain-funcs multilib

EXPORT_FUNCTIONS src_compile src_install

DEPEND="${DEPEND}
        >=dev-util/cmake-2.4.6-r1"

CMAKE_BUILD_DIR="${WORKDIR}/cmake-build"

# If you want to build in source tree set CMAKE_IN_SOURCE_BUILD to anything:
[[ -n "${CMAKE_IN_SOURCE_BUILD}" ]] && CMAKE_BUILD_DIR="${S}"

#
# Prepare CMAKE_BUILD_DIR:
#       - create the directory if it's missing
#
function prepare_build_dir() {

        if [[ ! -d "${CMAKE_BUILD_DIR}" ]]; then
                mkdir -p "${CMAKE_BUILD_DIR}" \
                        || die "mkdir \"${CMAKE_BUILD_DIR}\" failed"
        fi

}

#
# Run cmake with some needed defines.
# If you want to add something use CMAKE_FLAGS.
# If you want verbose makefile set CMAKE_VERBOSE to anything.
#
function ecmake() {

        prepare_build_dir

        pushd "${CMAKE_BUILD_DIR}" > /dev/null

        [[ -n "${CMAKE_VERBOSE}" ]] && \
                CMAKE_FLAGS="-DCMAKE_VERBOSE_MAKEFILE=1 ${CMAKE_FLAGS}"

        echo "cmake -DCMAKE_CXX_COMPILER=\"$(type -P $(tc-getCXX))\" 
-DCMAKE_CXX_FLAGS=\"${CXXFLAGS}\" -DCMAKE_C_COMPILER=\"$(type -P $(tc-getCC))\" 
-DCMAKE_C_FLAGS=\"${CFLAGS}\" -DCMAKE_INSTALL_PREFIX=\"/usr\" 
-DLIB_INSTALL_DIR=\"/usr/$(get_libdir)\" \"${S}\" ${CMAKE_FLAGS}"

        /usr/bin/cmake \
                -DCMAKE_CXX_COMPILER="$(type -P $(tc-getCXX))" \
                -DCMAKE_CXX_FLAGS="${CXXFLAGS}" \
                -DCMAKE_C_COMPILER="$(type -P $(tc-getCC))" \
                -DCMAKE_C_FLAGS="${CFLAGS}" \
                -DCMAKE_INSTALL_PREFIX="/usr" \
                -DLIB_INSTALL_DIR="/usr/$(get_libdir)" \
                ${CMAKE_FLAGS} \
                "${S}" || die "cmake failed"

        popd > /dev/null

}

#
# Run `ecmake' and default make target.
#
cmake_src_compile() {

        ecmake

        pushd "${CMAKE_BUILD_DIR}" > /dev/null
        emake [EMAIL PROTECTED] || die "emake failed"
        popd > /dev/null

}

#
# Change to build directory and run `make install'.
#
cmake_src_install() {

        pushd "${CMAKE_BUILD_DIR}" > /dev/null
        make DESTDIR="${D}" install || die "make install failed"
        popd > /dev/null

}

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to