# Copyright 1999-2007 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ # @ECLASS: cmake.eclass # @MAINTAINER: # nelchael@gentoo.org # @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: # @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 ${@} || 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 }