public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] cmake.eclass
@ 2006-05-18 10:13 Panard
  2006-05-18 10:54 ` Simon Stelling
  0 siblings, 1 reply; 19+ messages in thread
From: Panard @ 2006-05-18 10:13 UTC (permalink / raw
  To: gentoo-dev


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

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

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

# 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
}


[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2006-08-24  4:04 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-18 10:13 [gentoo-dev] cmake.eclass Panard
2006-05-18 10:54 ` Simon Stelling
2006-05-18 11:44   ` Panard
2006-05-24  0:52     ` Mike Frysinger
2006-05-24 10:46       ` Panard
2006-05-24 12:11         ` Thomas Kear
2006-05-24 13:24           ` Panard
2006-05-25 11:31             ` Carsten Lohrke
2006-05-25 14:39               ` Danny van Dyk
2006-05-25 14:37                 ` Diego 'Flameeyes' Pettenò
2006-05-25 14:54                   ` Carsten Lohrke
2006-05-25 22:50               ` Panard
2006-05-25 23:10                 ` Danny van Dyk
2006-05-25 23:09                   ` Diego 'Flameeyes' Pettenò
2006-05-25 23:20                   ` Danny van Dyk
2006-05-25 21:15             ` Mike Frysinger
2006-05-25 22:52               ` Panard
2006-08-24  3:23               ` lnxg33k
2006-08-24  4:02                 ` Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox