Re: [gentoo-dev] RFC: cmake.eclass
On 12:51 Sun 04 Nov , Krzysiek Pawlik wrote: 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. Great! When's the scons one coming? =) # 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 # This would be a great opportunity to start using real eclass documentation (e.g. that found in eutils.eclass) so we can autogenerate a useful manpage on how to use it. # If you want to build in source tree set CMAKE_IN_SOURCE_BUILD to anything: [[ -n ${CMAKE_IN_SOURCE_BUILD} ]] CMAKE_BUILD_DIR=${S} Why would I want to do that? Some documentation would help. function ecmake() { Why are some functions declared with 'function' and others not? -DCMAKE_CXX_COMPILER=$(type -P $(tc-getCXX)) \ Why the 'type -P' bit? make DESTDIR=${D} install || die make install failed Does emake work? Thanks, Donnie -- [EMAIL PROTECTED] mailing list
Re: [gentoo-dev] RFC: cmake.eclass
Donnie Berkholz wrote: 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. Great! When's the scons one coming? =) I don't know scons ;) # # Original Author: nelchael # Purpose: Automate src_install and src_compile for packages using cmake # This would be a great opportunity to start using real eclass documentation (e.g. that found in eutils.eclass) so we can autogenerate a useful manpage on how to use it. Done. # If you want to build in source tree set CMAKE_IN_SOURCE_BUILD to anything: [[ -n ${CMAKE_IN_SOURCE_BUILD} ]] CMAKE_BUILD_DIR=${S} Why would I want to do that? Some documentation would help. Added: some packages refuse to build out of source, so it may be needed in some cases. function ecmake() { Why are some functions declared with 'function' and others not? Fixed: added '^function ' -DCMAKE_CXX_COMPILER=$(type -P $(tc-getCXX)) \ Why the 'type -P' bit? To get the full path to $CC and $CXX make DESTDIR=${D} install || die make install failed Does emake work? It should - fixed. Attached is new version and a diff to previous. -- Krzysiek Pawlik nelchael at gentoo.org key id: 0xBC51 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: $ # @ECLASS: cmake.eclass # @MAINTAINER: # [EMAIL PROTECTED] # @BLURB: wrap cmake # @DESCRIPTION: # The cmake eclass contains functions wrapping cmake to ease its usage in # ebuilds. It allows both out of source and in source builds. 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 # Some packages don't build out of source, so if you want to build in source # tree set CMAKE_IN_SOURCE_BUILD to anything before inheriting cmake.eclass: [[ -n ${CMAKE_IN_SOURCE_BUILD} ]] CMAKE_BUILD_DIR=${S} # @FUNCTION: prepare_build_dir # @USAGE: # @DESCRIPTION: # Create the build directory if it doesn't exist, this function should not be # used outside of this eclass. function prepare_build_dir() { if [[ ! -d ${CMAKE_BUILD_DIR} ]]; then mkdir -p ${CMAKE_BUILD_DIR} \ || die mkdir \${CMAKE_BUILD_DIR}\ failed fi } # @FUNCTION: ecmake # @USAGE: # @DESCRIPTION: # Run cmake to prepare makefiles, also prepares the build directory. 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 } # @FUNCTION: cmake_src_compile # @USAGE: make arguments # @DESCRIPTION: # Default src_compile for ebuilds using cmake, runs `ecmake' and then `emake'. function cmake_src_compile() { ecmake pushd ${CMAKE_BUILD_DIR} /dev/null emake [EMAIL PROTECTED] || die emake failed popd /dev/null } # @FUNCTION: cmake_src_install # @USAGE: # @DESCRIPTION: # Default src_install for ebuilds using cmake, runs `emake install' in build # directory. function cmake_src_install() { pushd ${CMAKE_BUILD_DIR} /dev/null emake DESTDIR=${D} install || die make install failed popd /dev/null } Index: cmake.eclass === --- cmake.eclass(revision 285) +++ cmake.eclass(working copy) @@ -2,10 +2,13 @@ # 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 -# +# @ECLASS: cmake.eclass +# @MAINTAINER: +# [EMAIL PROTECTED] +# @BLURB: wrap cmake +# @DESCRIPTION: +# The cmake eclass contains functions wrapping cmake to ease its usage in +# ebuilds. It allows both out of source and in source builds. inherit toolchain-funcs multilib @@ -16,13 +19,15 @@ CMAKE_BUILD_DIR=${WORKDIR}/cmake-build -# If you want to build in source tree set CMAKE_IN_SOURCE_BUILD to anything: +# Some packages don't build out of source, so if you want to build in source +#
Re: [gentoo-dev] RFC: cmake.eclass
Wulf C. Krueger wrote: KDE4 will make use of cmake-utils.eclass we wrote because Why call it cmake-utils? - we need use_enable- and use_with-like functions for cmake (makes ebuilds easier to read) Could be done. - in-source and out-of-source build support Got it too :) - we need LIB_SUFFIX support Could be added easily. - our KDE4 eclasses rely on it. Not in tree yet. You might want to take a look at it. It's in the tree. I don't really think we need two implementations. I think so too. I've got few suggestions: * in cmake-utils_src_make(): emake [EMAIL PROTECTED] - it would allow something like this: cmake-utils_src_make -j1 * if you `cd' into build directory - *please* return to ${S} - use pushd/popd. Last thing: please reply to gentoo-dev too :) -- Krzysiek Pawlik nelchael at gentoo.org key id: 0xBC51 desktop-misc, desktop-dock, x86, java, apache, ppc... signature.asc Description: OpenPGP digital signature
Re: [gentoo-dev] RFC: cmake.eclass
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Krzysiek Pawlik wrote: 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 a bit confused now. Both this eclass and the recently submitted cmake-utils.eclass seem to handle CMake-based packages. Can someone clarify? Marijn - -- Marijn Schouten (hkBst), Gentoo Lisp project http://www.gentoo.org/proj/en/lisp/, #gentoo-lisp on FreeNode -BEGIN PGP SIGNATURE- Version: GnuPG v2.0.7 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFHLdC/p/VmCx0OL2wRAqkvAKCamrr4efE6byCFxKV3+FktlTdEtwCgsXGZ k+2A7Ib+BnfNw7wAa+//INg= =BV6f -END PGP SIGNATURE- -- [EMAIL PROTECTED] mailing list
Re: [gentoo-dev] RFC: cmake.eclass
Marijn Schouten (hkBst) wrote: I'm a bit confused now. Both this eclass and the recently submitted cmake-utils.eclass seem to handle CMake-based packages. Can someone clarify? Yes: I've missed the discussion about cmake-utils.eclass - my version (cmake.eclass) is not needed. -- Krzysiek Pawlik nelchael at gentoo.org key id: 0xBC51 desktop-misc, desktop-dock, x86, java, apache, ppc... signature.asc Description: OpenPGP digital signature
Re: [gentoo-dev] RFC: cmake.eclass
Wulf: check this patch to cmake-utils.eclass - it used pushd/popd, adds CMAKE_IN_SOURCE_BUILD in cmake-utils_src_compile and defines LIB_INSTALL_DIR (cmake-utils will be used by other packages besides KDE too). -- Krzysiek Pawlik nelchael at gentoo.org key id: 0xBC51 desktop-misc, desktop-dock, x86, java, apache, ppc... Index: cmake-utils.eclass === RCS file: /var/cvsroot/gentoo-x86/eclass/cmake-utils.eclass,v retrieving revision 1.1 diff -u -r1.1 cmake-utils.eclass --- cmake-utils.eclass 4 Nov 2007 13:17:35 - 1.1 +++ cmake-utils.eclass 4 Nov 2007 14:08:01 - @@ -49,7 +49,11 @@ cmake-utils_src_compile() { debug-print-function $FUNCNAME $* - cmake-utils_src_configureout + if [[ -n ${CMAKE_IN_SOURCE_BUILD} ]]; then + cmake-utils_src_configurein + else + cmake-utils_src_configureout + fi cmake-utils_src_make } @@ -74,11 +78,13 @@ debug-print-function $FUNCNAME $* local cmakeargs=${mycmakeargs} $(_common_configure_code) - mkdir ${WORKDIR}/${PN}_build - cd ${WORKDIR}/${PN}_build + mkdir -p ${WORKDIR}/${PN}_build + pushd ${WORKDIR}/${PN}_build /dev/null debug-print $LINENO $ECLASS $FUNCNAME: mycmakeargs is $cmakeargs cmake ${cmakeargs} ${S} || die Cmake failed + + popd /dev/null } # Internal use only. Common configuration options for all types of builds. @@ -91,6 +97,7 @@ echo -DCMAKE_CXX_COMPILER=$(type -P $(tc-getCXX)) echo -DCMAKE_INSTALL_PREFIX=${PREFIX:-/usr} echo -DLIB_SUFFIX=${tmp_libdir/lib} + echo -DLIB_INSTALL_DIR=${tmp_libdir} [[ -n ${CMAKE_NO_COLOR} ]] echo -DCMAKE_COLOR_MAKEFILE=OFF } @@ -103,12 +110,15 @@ # At this point we can automatically check if it's an out-of-source or an # in-source build if [[ -d ${WORKDIR}/${PN}_build ]]; then - cd ${WORKDIR}/${PN}_build; + pushd ${WORKDIR}/${PN}_build /dev/null fi if ! [[ -z ${CMAKE_COMPILER_VERBOSE} ]]; then - emake VERBOSE=1 || die Make failed!; + emake VERBOSE=1 || die Make failed! else - emake || die Make failed!; + emake || die Make failed! + fi + if [[ -d ${WORKDIR}/${PN}_build ]]; then + popd /dev/null fi } @@ -121,9 +131,12 @@ # At this point we can automatically check if it's an out-of-source or an # in-source build if [[ -d ${WORKDIR}/${PN}_build ]]; then - cd ${WORKDIR}/${PN}_build; + pushd ${WORKDIR}/${PN}_build /dev/null fi emake install DESTDIR=${D} || die Make install failed + if [[ -d ${WORKDIR}/${PN}_build ]]; then + popd /dev/null + fi } # @FUNCTION: cmake-utils_src_test @@ -135,7 +148,7 @@ # At this point we can automatically check if it's an out-of-source or an # in-source build if [[ -d ${WORKDIR}/${PN}_build ]]; then - cd ${WORKDIR}/${PN}_build + pushd ${WORKDIR}/${PN}_build /dev/null fi # Standard implementation of src_test if emake -j1 check -n /dev/null; then @@ -151,4 +164,7 @@ else einfo Test phase [none]: ${CATEGORY}/${PF} fi + if [[ -d ${WORKDIR}/${PN}_build ]]; then + popd /dev/null + fi } signature.asc Description: OpenPGP digital signature
Re: [gentoo-dev] RFC: cmake.eclass
Hello Krzysiek! On Sunday, 04. November 2007 15:09:47 Krzysiek Pawlik wrote: Wulf: check this patch to cmake-utils.eclass - it used pushd/popd, adds CMAKE_IN_SOURCE_BUILD in cmake-utils_src_compile and defines LIB_INSTALL_DIR (cmake-utils will be used by other packages besides KDE too). Thanks, looks good. I'll do some testing and apply it. -- Best regards, Wulf signature.asc Description: This is a digitally signed message part.