diff options
author | 2013-02-07 15:41:34 +0000 | |
---|---|---|
committer | 2013-02-07 15:41:34 +0000 | |
commit | 95f007acf4c1f19922909d7cc40a9f76c91b36bd (patch) | |
tree | 6327db755c6ff7bccb267a92730faf341b165027 /eclass/cmake-utils.eclass | |
parent | version bump, EAPI 5, use subslots (diff) | |
download | gentoo-2-95f007acf4c1f19922909d7cc40a9f76c91b36bd.tar.gz gentoo-2-95f007acf4c1f19922909d7cc40a9f76c91b36bd.tar.bz2 gentoo-2-95f007acf4c1f19922909d7cc40a9f76c91b36bd.zip |
Export src_prepare. Improve support for dev-util/ninja wrt bug #439608. Add support for CMAKE_DISABLE_FIND_PACKAGE wrt bug #453746.
Diffstat (limited to 'eclass/cmake-utils.eclass')
-rw-r--r-- | eclass/cmake-utils.eclass | 133 |
1 files changed, 99 insertions, 34 deletions
diff --git a/eclass/cmake-utils.eclass b/eclass/cmake-utils.eclass index cadabe92220e..0aa52a9e4f4f 100644 --- a/eclass/cmake-utils.eclass +++ b/eclass/cmake-utils.eclass @@ -1,6 +1,6 @@ -# Copyright 1999-2012 Gentoo Foundation +# Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/cmake-utils.eclass,v 1.91 2013/01/17 20:18:28 creffett Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/cmake-utils.eclass,v 1.92 2013/02/07 15:41:34 kensington Exp $ # @ECLASS: cmake-utils.eclass # @MAINTAINER: @@ -28,7 +28,7 @@ WANT_CMAKE="${WANT_CMAKE:-always}" # @ECLASS-VARIABLE: CMAKE_MIN_VERSION # @DESCRIPTION: -# Specify the minimum required CMake version. Default is 2.8.4 +# Specify the minimum required CMake version. CMAKE_MIN_VERSION="${CMAKE_MIN_VERSION:-2.8.8}" # @ECLASS-VARIABLE: CMAKE_REMOVE_MODULES_LIST @@ -44,9 +44,9 @@ CMAKE_REMOVE_MODULES="${CMAKE_REMOVE_MODULES:-yes}" # @ECLASS-VARIABLE: CMAKE_MAKEFILE_GENERATOR # @DESCRIPTION: -# Specify a makefile generator to be used by cmake. At this point only "make" -# and "ninja" is supported. -CMAKE_MAKEFILE_GENERATOR="${CMAKE_MAKEFILE_GENERATOR:-make}" +# Specify a makefile generator to be used by cmake. +# At this point only "emake" and "ninja" are supported. +CMAKE_MAKEFILE_GENERATOR="${CMAKE_MAKEFILE_GENERATOR:-emake}" CMAKEDEPEND="" case ${WANT_CMAKE} in @@ -61,12 +61,25 @@ inherit toolchain-funcs multilib flag-o-matic base CMAKE_EXPF="src_compile src_test src_install" case ${EAPI:-0} in - 2|3|4|5) CMAKE_EXPF+=" src_configure" ;; + 2|3|4|5) CMAKE_EXPF+=" src_prepare src_configure" ;; 1|0) ;; *) die "Unknown EAPI, Bug eclass maintainers." ;; esac EXPORT_FUNCTIONS ${CMAKE_EXPF} +case ${CMAKE_MAKEFILE_GENERATOR} in + emake) + CMAKEDEPEND+=" sys-devel/make" + ;; + ninja) + CMAKEDEPEND+=" dev-util/ninja" + ;; + *) + eerror "Unknown value for \${CMAKE_MAKEFILE_GENERATOR}" + die "Value ${CMAKE_MAKEFILE_GENERATOR} is not supported" + ;; +esac + if [[ ${PN} != cmake ]]; then CMAKEDEPEND+=" >=dev-util/cmake-${CMAKE_MIN_VERSION}" fi @@ -195,10 +208,22 @@ _check_build_dir() { # Determine which generator to use _generator_to_use() { - if [[ ${CMAKE_MAKEFILE_GENERATOR} = "ninja" ]]; then - has_version dev-util/ninja && echo "Ninja" && return - fi - echo "Unix Makefiles" + local generator_name + + case ${CMAKE_MAKEFILE_GENERATOR} in + ninja) + generator_name="Ninja" + ;; + emake) + generator_name="Unix Makefiles" + ;; + *) + eerror "Unknown value for \${CMAKE_MAKEFILE_GENERATOR}" + die "Value ${CMAKE_MAKEFILE_GENERATOR} is not supported" + ;; + esac + + echo ${generator_name} } # @FUNCTION: cmake-utils_use_with @@ -219,6 +244,16 @@ cmake-utils_use_with() { _use_me_now WITH_ "$@" ; } # and -DENABLE_FOO=OFF if it is disabled. cmake-utils_use_enable() { _use_me_now ENABLE_ "$@" ; } +# @FUNCTION: cmake-utils_use_find_package +# @USAGE: <USE flag> [flag name] +# @DESCRIPTION: +# Based on use_enable. See ebuild(5). +# +# `cmake-utils_use_find_package foo FOO` echoes -DCMAKE_DISABLE_FIND_PACKAGE=OFF +# if foo is enabled and -DCMAKE_DISABLE_FIND_PACKAGE=ON if it is disabled. +# This can be used to make find_package optional (since cmake-2.8.6). +cmake-utils_use_find_package() { _use_me_now_inverted CMAKE_DISABLE_FIND_PACKAGE_ "$@" ; } + # @FUNCTION: cmake-utils_use_disable # @USAGE: <USE flag> [flag name] # @DESCRIPTION: @@ -315,6 +350,12 @@ _modify-cmakelists() { _EOF_ } +enable_cmake-utils_src_prepare() { + debug-print-function ${FUNCNAME} "$@" + + base_src_prepare +} + enable_cmake-utils_src_configure() { debug-print-function ${FUNCNAME} "$@" @@ -433,33 +474,52 @@ enable_cmake-utils_src_compile() { cmake-utils_src_make "$@" } -# @FUNCTION: cmake-utils_src_make +# @FUNCTION: ninja_src_make +# @INTERNAL # @DESCRIPTION: -# Function for building the package. Automatically detects the build type. -# All arguments are passed to emake. -cmake-utils_src_make() { +# Build the package using ninja generator +ninja_src_make() { debug-print-function ${FUNCNAME} "$@" - _check_build_dir - pushd "${BUILD_DIR}" > /dev/null - if [[ $(_generator_to_use) = Ninja ]]; then - # first check if Makefile exist otherwise die [[ -e build.ninja ]] || die "Makefile not found. Error during configure stage." + if [[ "${CMAKE_VERBOSE}" != "OFF" ]]; then - #TODO get load average from portage (-l option) - ninja ${MAKEOPTS} -v "$@" - else - ninja "$@" - fi || die "ninja failed!" + # TODO: get load average from portage (-l option) + ninja ${MAKEOPTS} -v "$@" || die else - # first check if Makefile exist otherwise die + ninja "$@" || die + fi +} + +# @FUNCTION: make_src_make +# @INTERNAL +# @DESCRIPTION: +# Build the package using make generator +emake_src_make() { + debug-print-function ${FUNCNAME} "$@" + [[ -e Makefile ]] || die "Makefile not found. Error during configure stage." + if [[ "${CMAKE_VERBOSE}" != "OFF" ]]; then - emake VERBOSE=1 "$@" || die "Make failed!" + emake VERBOSE=1 "$@" || die else - emake "$@" || die "Make failed!" - fi + emake "$@" || die fi + +} + +# @FUNCTION: cmake-utils_src_make +# @DESCRIPTION: +# Function for building the package. Automatically detects the build type. +# All arguments are passed to emake. +cmake-utils_src_make() { + debug-print-function ${FUNCNAME} "$@" + + _check_build_dir + pushd "${BUILD_DIR}" > /dev/null + + ${CMAKE_MAKEFILE_GENERATOR}_src_make $@ + popd > /dev/null } @@ -468,12 +528,10 @@ enable_cmake-utils_src_install() { _check_build_dir pushd "${BUILD_DIR}" > /dev/null - if [[ $(_generator_to_use) = Ninja ]]; then - DESTDIR=${D} ninja install "$@" || die "died running ninja install" - base_src_install_docs - else - base_src_install "$@" - fi + + DESTDIR="${D}" ${CMAKE_MAKEFILE_GENERATOR} install "$@" || die "died running ${CMAKE_MAKEFILE_GENERATOR} install" + base_src_install_docs + popd > /dev/null # Backward compatibility, for non-array variables @@ -516,6 +574,13 @@ enable_cmake-utils_src_test() { fi } +# @FUNCTION: cmake-utils_src_prepare +# @DESCRIPTION: +# Wrapper function around base_src_prepare, just to expand the eclass API. +cmake-utils_src_prepare() { + _execute_optionaly "src_prepare" "$@" +} + # @FUNCTION: cmake-utils_src_configure # @DESCRIPTION: # General function for configuring with cmake. Default behaviour is to start an |