diff options
author | Michael Palimaka <kensington@gentoo.org> | 2014-08-12 14:58:40 +0000 |
---|---|---|
committer | Michael Palimaka <kensington@gentoo.org> | 2014-08-12 14:58:40 +0000 |
commit | 595a87093d59743aa3dfa800ce6d1776c3312595 (patch) | |
tree | bd896c55ebd57cd23ea531712dd950cc7ca2ceed /eclass/cmake-utils.eclass | |
parent | add patches to fix testsuite (diff) | |
download | gentoo-2-595a87093d59743aa3dfa800ce6d1776c3312595.tar.gz gentoo-2-595a87093d59743aa3dfa800ce6d1776c3312595.tar.bz2 gentoo-2-595a87093d59743aa3dfa800ce6d1776c3312595.zip |
Sync with KDE overlay, including a large number of cosmetic changes and simplification and removal of old code.
Diffstat (limited to 'eclass/cmake-utils.eclass')
-rw-r--r-- | eclass/cmake-utils.eclass | 234 |
1 files changed, 106 insertions, 128 deletions
diff --git a/eclass/cmake-utils.eclass b/eclass/cmake-utils.eclass index d394ad1c26c7..ec40d3b12466 100644 --- a/eclass/cmake-utils.eclass +++ b/eclass/cmake-utils.eclass @@ -1,6 +1,6 @@ # Copyright 1999-2014 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/cmake-utils.eclass,v 1.109 2014/08/05 22:59:44 johu Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/cmake-utils.eclass,v 1.110 2014/08/12 14:58:40 kensington Exp $ # @ECLASS: cmake-utils.eclass # @MAINTAINER: @@ -20,42 +20,92 @@ if [[ -z ${_CMAKE_UTILS_ECLASS} ]]; then _CMAKE_UTILS_ECLASS=1 -# @ECLASS-VARIABLE: WANT_CMAKE + +# @ECLASS-VARIABLE: BUILD_DIR # @DESCRIPTION: -# Specify if cmake-utils eclass should depend on cmake optionally or not. -# This is usefull when only part of aplication is using cmake build system. -# Valid values are: always [default], optional (where the value is the useflag -# used for optionality) -WANT_CMAKE="${WANT_CMAKE:-always}" +# Build directory where all cmake processed files should be generated. +# For in-source build it's fixed to ${CMAKE_USE_DIR}. +# For out-of-source build it can be overridden, by default it uses +# ${WORKDIR}/${P}_build. +# +# This variable has been called CMAKE_BUILD_DIR formerly. +# It is set under that name for compatibility. + +# @ECLASS-VARIABLE: CMAKE_BINARY +# @DESCRIPTION: +# Eclass can use different cmake binary than the one provided in by system. +: ${CMAKE_BINARY:=cmake} + +# @ECLASS-VARIABLE: CMAKE_BUILD_TYPE +# @DESCRIPTION: +# Set to override default CMAKE_BUILD_TYPE. Only useful for packages +# known to make use of "if (CMAKE_BUILD_TYPE MATCHES xxx)". +# If about to be set - needs to be set before invoking cmake-utils_src_configure. +# You usualy do *NOT* want nor need to set it as it pulls CMake default build-type +# specific compiler flags overriding make.conf. +: ${CMAKE_BUILD_TYPE:=Gentoo} + +# @ECLASS-VARIABLE: CMAKE_IN_SOURCE_BUILD +# @DESCRIPTION: +# Set to enable in-source build. + +# @ECLASS-VARIABLE: CMAKE_MAKEFILE_GENERATOR +# @DESCRIPTION: +# Specify a makefile generator to be used by cmake. +# At this point only "emake" and "ninja" are supported. +: ${CMAKE_MAKEFILE_GENERATOR:=emake} # @ECLASS-VARIABLE: CMAKE_MIN_VERSION # @DESCRIPTION: # Specify the minimum required CMake version. -CMAKE_MIN_VERSION="${CMAKE_MIN_VERSION:-2.8.12}" +: ${CMAKE_MIN_VERSION:=2.8.12} + +# @ECLASS-VARIABLE: CMAKE_REMOVE_MODULES +# @DESCRIPTION: +# Do we want to remove anything? yes or whatever else for no +: ${CMAKE_REMOVE_MODULES:=yes} +CMAKE_REMOVE_MODULES="${CMAKE_REMOVE_MODULES:-yes}" # @ECLASS-VARIABLE: CMAKE_REMOVE_MODULES_LIST # @DESCRIPTION: # Space-separated list of CMake modules that will be removed in $S during src_prepare, # in order to force packages to use the system version. -CMAKE_REMOVE_MODULES_LIST="${CMAKE_REMOVE_MODULES_LIST:-FindBLAS FindLAPACK}" +: ${CMAKE_REMOVE_MODULES_LIST:=FindBLAS FindLAPACK} -# @ECLASS-VARIABLE: CMAKE_REMOVE_MODULES +# @ECLASS-VARIABLE: CMAKE_USE_DIR # @DESCRIPTION: -# Do we want to remove anything? yes or whatever else for no -CMAKE_REMOVE_MODULES="${CMAKE_REMOVE_MODULES:-yes}" +# Sets the directory where we are working with cmake. +# For example when application uses autotools and only one +# plugin needs to be done by cmake. +# By default it uses ${S}. -# @ECLASS-VARIABLE: CMAKE_MAKEFILE_GENERATOR +# @ECLASS-VARIABLE: CMAKE_VERBOSE # @DESCRIPTION: -# 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}" +# Set to OFF to disable verbose messages during compilation +: ${CMAKE_VERBOSE:=ON} # @ECLASS-VARIABLE: CMAKE_WARN_UNUSED_CLI # @DESCRIPTION: # Warn about variables that are declared on the command line # but not used. Might give false-positives. # "no" to disable (default) or anything else to enable. -CMAKE_WARN_UNUSED_CLI="${CMAKE_WARN_UNUSED_CLI:-no}" +: ${CMAKE_WARN_UNUSED_CLI:=no} + +# @ECLASS-VARIABLE: PREFIX +# @DESCRIPTION: +# Eclass respects PREFIX variable, though it's not recommended way to set +# install/lib/bin prefixes. +# Use -DCMAKE_INSTALL_PREFIX=... CMake variable instead. +: ${PREFIX:=/usr} + +# @ECLASS-VARIABLE: WANT_CMAKE +# @DESCRIPTION: +# Specify if cmake-utils eclass should depend on cmake optionally or not. +# This is useful when only part of application is using cmake build system. +# Valid values are: always [default], optional (where the value is the useflag +# used for optionality) +: ${WANT_CMAKE:=always} + CMAKEDEPEND="" case ${WANT_CMAKE} in @@ -68,13 +118,12 @@ case ${WANT_CMAKE} in esac inherit toolchain-funcs multilib flag-o-matic eutils -CMAKE_EXPF="src_compile src_test src_install" case ${EAPI:-0} in - 2|3|4|5) CMAKE_EXPF+=" src_prepare src_configure" ;; - 1|0) eerror "cmake-utils no longer supports EAPI 0-1." && die - ;; - *) die "Unknown EAPI, bug eclass maintainers." ;; + 2|3|4|5) : ;; + *) die "EAPI=${EAPI} is not supported" ;; esac + +CMAKE_EXPF="src_prepare src_configure src_compile src_test src_install" EXPORT_FUNCTIONS ${CMAKE_EXPF} case ${CMAKE_MAKEFILE_GENERATOR} in @@ -137,53 +186,6 @@ _use_me_now_inverted() { fi } -# @ECLASS-VARIABLE: BUILD_DIR -# @DESCRIPTION: -# Build directory where all cmake processed files should be generated. -# For in-source build it's fixed to ${CMAKE_USE_DIR}. -# For out-of-source build it can be overriden, by default it uses -# ${WORKDIR}/${P}_build. -# -# This variable has been called CMAKE_BUILD_DIR formerly. -# It is set under that name for compatibility. - -# @ECLASS-VARIABLE: CMAKE_BUILD_TYPE -# @DESCRIPTION: -# Set to override default CMAKE_BUILD_TYPE. Only useful for packages -# known to make use of "if (CMAKE_BUILD_TYPE MATCHES xxx)". -# If about to be set - needs to be set before invoking cmake-utils_src_configure. -# You usualy do *NOT* want nor need to set it as it pulls CMake default build-type -# specific compiler flags overriding make.conf. -: ${CMAKE_BUILD_TYPE:=Gentoo} - -# @ECLASS-VARIABLE: CMAKE_IN_SOURCE_BUILD -# @DESCRIPTION: -# Set to enable in-source build. - -# @ECLASS-VARIABLE: CMAKE_USE_DIR -# @DESCRIPTION: -# Sets the directory where we are working with cmake. -# For example when application uses autotools and only one -# plugin needs to be done by cmake. -# By default it uses ${S}. - -# @ECLASS-VARIABLE: CMAKE_VERBOSE -# @DESCRIPTION: -# Set to OFF to disable verbose messages during compilation -: ${CMAKE_VERBOSE:=ON} - -# @ECLASS-VARIABLE: PREFIX -# @DESCRIPTION: -# Eclass respects PREFIX variable, though it's not recommended way to set -# install/lib/bin prefixes. -# Use -DCMAKE_INSTALL_PREFIX=... CMake variable instead. -: ${PREFIX:=/usr} - -# @ECLASS-VARIABLE: CMAKE_BINARY -# @DESCRIPTION: -# Eclass can use different cmake binary than the one provided in by system. -: ${CMAKE_BINARY:=cmake} - # Determine using IN or OUT source build _check_build_dir() { : ${CMAKE_USE_DIR:=${S}} @@ -261,7 +263,7 @@ cmake-utils_use_enable() { _use_me_now ENABLE_ "$@" ; } # # `cmake-utils_use_find_package foo LibFoo` echoes -DCMAKE_DISABLE_FIND_PACKAGE_LibFoo=OFF # if foo is enabled and -DCMAKE_DISABLE_FIND_PACKAGE_LibFoo=ON if it is disabled. -# This can be used to make find_package optional (since cmake-2.8.6). +# This can be used to make find_package optional. cmake-utils_use_find_package() { _use_me_now_inverted CMAKE_DISABLE_FIND_PACKAGE_ "$@" ; } # @FUNCTION: cmake-utils_use_disable @@ -372,15 +374,15 @@ _modify-cmakelists() { enable_cmake-utils_src_prepare() { debug-print-function ${FUNCNAME} "$@" - debug-print "$FUNCNAME: PATCHES=$PATCHES" + pushd "${S}" > /dev/null - pushd "${S}" >/dev/null + debug-print "$FUNCNAME: PATCHES=$PATCHES" [[ ${PATCHES[@]} ]] && epatch "${PATCHES[@]}" - + debug-print "$FUNCNAME: applying user patches" epatch_user - popd >/dev/null + popd > /dev/null } # @VARIABLE: mycmakeargs @@ -393,9 +395,10 @@ enable_cmake-utils_src_prepare() { # local mycmakeargs=( # $(cmake-utils_use_with openconnect) # ) +# # cmake-utils_src_configure # } - +# @CODE enable_cmake-utils_src_configure() { debug-print-function ${FUNCNAME} "$@" @@ -508,17 +511,16 @@ enable_cmake-utils_src_configure() { "${MYCMAKEARGS}" ) - pushd "${BUILD_DIR}" >/dev/null + pushd "${BUILD_DIR}" > /dev/null debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: mycmakeargs is ${mycmakeargs_local[*]}" echo "${CMAKE_BINARY}" "${cmakeargs[@]}" "${CMAKE_USE_DIR}" "${CMAKE_BINARY}" "${cmakeargs[@]}" "${CMAKE_USE_DIR}" || die "cmake failed" - popd >/dev/null + popd > /dev/null } enable_cmake-utils_src_compile() { debug-print-function ${FUNCNAME} "$@" - has src_configure ${CMAKE_EXPF} || cmake-utils_src_configure cmake-utils_src_make "$@" } @@ -590,61 +592,25 @@ cmake-utils_src_make() { debug-print-function ${FUNCNAME} "$@" _check_build_dir - pushd "${BUILD_DIR}" >/dev/null + pushd "${BUILD_DIR}" > /dev/null ${CMAKE_MAKEFILE_GENERATOR}_src_make "$@" - popd >/dev/null -} - -enable_cmake-utils_src_install() { - debug-print-function ${FUNCNAME} "$@" - - _check_build_dir - pushd "${BUILD_DIR}" >/dev/null - DESTDIR="${D}" ${CMAKE_MAKEFILE_GENERATOR} install "$@" || die "died running ${CMAKE_MAKEFILE_GENERATOR} install" - popd >/dev/null - - pushd "${S}" >/dev/null - # Install docs, copied from base_src_install_docs - local x - - if [[ "$(declare -p DOCS 2>/dev/null 2>&1)" == "declare -a"* ]]; then - for x in "${DOCS[@]}"; do - debug-print "$FUNCNAME: docs: creating document from ${x}" - dodoc "${x}" || die "dodoc failed" - done - fi - if [[ "$(declare -p HTML_DOCS 2>/dev/null 2>&1)" == "declare -a"* ]]; then - for x in "${HTML_DOCS[@]}"; do - debug-print "$FUNCNAME: docs: creating html document from ${x}" - dohtml -r "${x}" || die "dohtml failed" - done - fi - - # Backward compatibility, for non-array variables - if [[ -n "${DOCS}" ]] && [[ "$(declare -p DOCS 2>/dev/null 2>&1)" != "declare -a"* ]]; then - dodoc ${DOCS} || die "dodoc failed" - fi - if [[ -n "${HTML_DOCS}" ]] && [[ "$(declare -p HTML_DOCS 2>/dev/null 2>&1)" != "declare -a"* ]]; then - dohtml -r ${HTML_DOCS} || die "dohtml failed" - fi - - popd >/dev/null + popd > /dev/null } enable_cmake-utils_src_test() { debug-print-function ${FUNCNAME} "$@" _check_build_dir - pushd "${BUILD_DIR}" >/dev/null + pushd "${BUILD_DIR}" > /dev/null [[ -e CTestTestfile.cmake ]] || { echo "No tests found. Skipping."; return 0 ; } [[ -n ${TEST_VERBOSE} ]] && myctestargs+=( --extra-verbose --output-on-failure ) if ctest "${myctestargs[@]}" "$@" ; then einfo "Tests succeeded." - popd >/dev/null + popd > /dev/null return 0 else if [[ -n "${CMAKE_YES_I_WANT_TO_SEE_THE_TEST_LOG}" ]] ; then @@ -659,11 +625,24 @@ enable_cmake-utils_src_test() { fi # die might not die due to nonfatal - popd >/dev/null + popd > /dev/null return 1 fi } +enable_cmake-utils_src_install() { + debug-print-function ${FUNCNAME} "$@" + + _check_build_dir + pushd "${BUILD_DIR}" > /dev/null + DESTDIR="${D}" ${CMAKE_MAKEFILE_GENERATOR} install "$@" || die "died running ${CMAKE_MAKEFILE_GENERATOR} install" + popd > /dev/null + + pushd "${S}" > /dev/null + einstalldocs + popd > /dev/null +} + # @FUNCTION: cmake-utils_src_prepare # @DESCRIPTION: # Apply ebuild and user patches. @@ -681,20 +660,12 @@ cmake-utils_src_configure() { # @FUNCTION: cmake-utils_src_compile # @DESCRIPTION: -# General function for compiling with cmake. Default behaviour is to check for -# EAPI and respectively to configure as well or just compile. +# General function for compiling with cmake. # Automatically detects the build type. All arguments are passed to emake. cmake-utils_src_compile() { _execute_optionally "src_compile" "$@" } -# @FUNCTION: cmake-utils_src_install -# @DESCRIPTION: -# Function for installing the package. Automatically detects the build type. -cmake-utils_src_install() { - _execute_optionally "src_install" "$@" -} - # @FUNCTION: cmake-utils_src_test # @DESCRIPTION: # Function for testing the package. Automatically detects the build type. @@ -702,6 +673,13 @@ cmake-utils_src_test() { _execute_optionally "src_test" "$@" } +# @FUNCTION: cmake-utils_src_install +# @DESCRIPTION: +# Function for installing the package. Automatically detects the build type. +cmake-utils_src_install() { + _execute_optionally "src_install" "$@" +} + # Optionally executes phases based on WANT_CMAKE variable/USE flag. _execute_optionally() { local phase="$1" ; shift |