public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: Krzysiek Pawlik <nelchael@gentoo.org>
To: Gentoo Dev <gentoo-dev@lists.gentoo.org>
Subject: [gentoo-dev] RFC: cmake.eclass
Date: Sun, 04 Nov 2007 12:51:44 +0100	[thread overview]
Message-ID: <472DB250.2090406@gentoo.org> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 2488 bytes --]


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...

[-- Attachment #1.2: cmake.eclass --]
[-- Type: text/plain, Size: 2071 bytes --]

# 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 ${@} || 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 #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]

             reply	other threads:[~2007-11-04 11:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-04 11:51 Krzysiek Pawlik [this message]
2007-11-04 12:12 ` [gentoo-dev] RFC: cmake.eclass Donnie Berkholz
2007-11-04 12:34   ` Krzysiek Pawlik
     [not found] ` <200711041420.38049.philantrop@gentoo.org>
2007-11-04 13:30   ` Krzysiek Pawlik
2007-11-04 14:09     ` Krzysiek Pawlik
2007-11-04 14:35       ` Wulf C. Krueger
2007-11-04 14:01 ` Marijn Schouten (hkBst)
2007-11-04 14:07   ` Krzysiek Pawlik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=472DB250.2090406@gentoo.org \
    --to=nelchael@gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox