From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1QiUkW-0004oY-JC for garchives@archives.gentoo.org; Sun, 17 Jul 2011 17:03:25 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 75A2F21C20D; Sun, 17 Jul 2011 17:03:15 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 2851821C294 for ; Sun, 17 Jul 2011 17:03:15 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 2737D1B4009 for ; Sun, 17 Jul 2011 17:03:14 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 540958003D for ; Sun, 17 Jul 2011 17:03:13 +0000 (UTC) From: "Andreas Hüttel" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Andreas Hüttel" Message-ID: Subject: [gentoo-commits] proj/sci:master commit in: eclass/ X-VCS-Repository: proj/sci X-VCS-Files: eclass/cmake-utils.eclass X-VCS-Directories: eclass/ X-VCS-Committer: dilfridge X-VCS-Committer-Name: Andreas Hüttel X-VCS-Revision: c71472052ce0ba88995ec5dcde5fce9d498da19c Date: Sun, 17 Jul 2011 17:03:13 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 7c1d98a8c53189aea095a9383d5899a9 commit: c71472052ce0ba88995ec5dcde5fce9d498da19c Author: Andreas K. Huettel (dilfridge) gentoo o= rg> AuthorDate: Sun Jul 17 16:08:28 2011 +0000 Commit: Andreas H=C3=BCttel gentoo org> CommitDate: Sun Jul 17 16:08:28 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/sci.git;a=3Dc= ommit;h=3Dc7147205 Copied eclass from main tree --- eclass/cmake-utils.eclass | 467 +++++++++++++++++++++++++++++++++++++++= ++++++ 1 files changed, 467 insertions(+), 0 deletions(-) diff --git a/eclass/cmake-utils.eclass b/eclass/cmake-utils.eclass new file mode 100644 index 0000000..6a58226 --- /dev/null +++ b/eclass/cmake-utils.eclass @@ -0,0 +1,467 @@ +# Copyright 1999-2010 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/eclass/cmake-utils.eclass,v 1.69 2011= /06/27 21:11:57 abcd Exp $ + +# @ECLASS: cmake-utils.eclass +# @MAINTAINER: +# kde@gentoo.org +# +# @CODE +# Tom=C3=A1=C5=A1 Chv=C3=A1tal +# Maciej Mrozowski +# (undisclosed contributors) +# Original author: Zephyrus (zephyrus@mirach.it) +# @CODE +# @BLURB: common ebuild functions for cmake-based packages +# @DESCRIPTION: +# The cmake-utils eclass is base.eclass(5) wrapper that makes creating e= builds for +# cmake-based packages much easier. +# It provides all inherited features (DOCS, HTML_DOCS, PATCHES) along wi= th out-of-source +# builds (default), in-source builds and an implementation of the well-k= nown use_enable +# and use_with functions for CMake. + +# @ECLASS-VARIABLE: WANT_CMAKE +# @DESCRIPTION: +# Specify if cmake-utils eclass should depend on cmake optionaly or not. +# This is usefull when only part of aplication is using cmake build syst= em. +# Valid values are: always [default], optional (where the value is the u= seflag +# used for optionality) +WANT_CMAKE=3D"${WANT_CMAKE:-always}" + +# @ECLASS-VARIABLE: CMAKE_MIN_VERSION +# @DESCRIPTION: +# Specify the minimum required CMake version. Default is 2.8.1 +CMAKE_MIN_VERSION=3D"${CMAKE_MIN_VERSION:-2.8.1}" + +CMAKEDEPEND=3D"" +case ${WANT_CMAKE} in + always) + ;; + *) + IUSE+=3D" ${WANT_CMAKE}" + CMAKEDEPEND+=3D"${WANT_CMAKE}? ( " + ;; +esac +inherit toolchain-funcs multilib flag-o-matic base + +CMAKE_EXPF=3D"src_compile src_test src_install" +case ${EAPI:-0} in + 4|3|2) CMAKE_EXPF+=3D" src_configure" ;; + 1|0) ;; + *) die "Unknown EAPI, Bug eclass maintainers." ;; +esac +EXPORT_FUNCTIONS ${CMAKE_EXPF} + +: ${DESCRIPTION:=3D"Based on the ${ECLASS} eclass"} + +if [[ ${PN} !=3D cmake ]]; then + CMAKEDEPEND+=3D">=3Ddev-util/cmake-${CMAKE_MIN_VERSION}" +fi + +CMAKEDEPEND+=3D" userland_GNU? ( >=3Dsys-apps/findutils-4.4.0 )" + +[[ ${WANT_CMAKE} =3D always ]] || CMAKEDEPEND+=3D" )" + +DEPEND=3D"${CMAKEDEPEND}" +unset CMAKEDEPEND + +# Internal functions used by cmake-utils_use_* +_use_me_now() { + debug-print-function ${FUNCNAME} "$@" + + local uper capitalised x + [[ -z $2 ]] && die "cmake-utils_use-$1 []" + if [[ ! -z $3 ]]; then + # user specified the use name so use it + echo "-D$1$3=3D$(use $2 && echo ON || echo OFF)" + else + # use all various most used combinations + uper=3D$(echo ${2} | tr '[:lower:]' '[:upper:]') + capitalised=3D$(echo ${2} | sed 's/\<\(.\)\([^ ]*\)/\u\1\L\2/g') + for x in $2 $uper $capitalised; do + echo "-D$1$x=3D$(use $2 && echo ON || echo OFF) " + done + fi +} +_use_me_now_inverted() { + debug-print-function ${FUNCNAME} "$@" + + local uper capitalised x + [[ -z $2 ]] && die "cmake-utils_use-$1 []" + if [[ ! -z $3 ]]; then + # user specified the use name so use it + echo "-D$1$3=3D$(use $2 && echo OFF || echo ON)" + else + # use all various most used combinations + uper=3D$(echo ${2} | tr '[:lower:]' '[:upper:]') + capitalised=3D$(echo ${2} | sed 's/\<\(.\)\([^ ]*\)/\u\1\L\2/g') + for x in $2 $uper $capitalised; do + echo "-D$1$x=3D$(use $2 && echo OFF || echo ON) " + done + fi +} + +# @ECLASS-VARIABLE: CMAKE_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. + +# @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_c= onfigure. +# 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:=3DGentoo} + +# @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 enable verbose messages during compilation. + +# @ECLASS-VARIABLE: PREFIX +# @DESCRIPTION: +# Eclass respects PREFIX variable, though it's not recommended way to se= t +# install/lib/bin prefixes. +# Use -DCMAKE_INSTALL_PREFIX=3D... CMake variable instead. + +# @ECLASS-VARIABLE: CMAKE_BINARY +# @DESCRIPTION: +# Eclass can use different cmake binary than the one provided in by syst= em. +: ${CMAKE_BINARY:=3Dcmake} + +# Determine using IN or OUT source build +_check_build_dir() { + : ${CMAKE_USE_DIR:=3D${S}} + if [[ -n ${CMAKE_IN_SOURCE_BUILD} ]]; then + # we build in source dir + CMAKE_BUILD_DIR=3D"${CMAKE_USE_DIR}" + else + : ${CMAKE_BUILD_DIR:=3D${WORKDIR}/${P}_build} + fi + echo ">>> Working in BUILD_DIR: \"$CMAKE_BUILD_DIR\"" +} +# @FUNCTION: cmake-utils_use_with +# @USAGE: [flag name] +# @DESCRIPTION: +# Based on use_with. See ebuild(5). +# +# `cmake-utils_use_with foo FOO` echoes -DWITH_FOO=3DON if foo is enable= d +# and -DWITH_FOO=3DOFF if it is disabled. +cmake-utils_use_with() { _use_me_now WITH_ "$@" ; } + +# @FUNCTION: cmake-utils_use_enable +# @USAGE: [flag name] +# @DESCRIPTION: +# Based on use_enable. See ebuild(5). +# +# `cmake-utils_use_enable foo FOO` echoes -DENABLE_FOO=3DON if foo is en= abled +# and -DENABLE_FOO=3DOFF if it is disabled. +cmake-utils_use_enable() { _use_me_now ENABLE_ "$@" ; } + +# @FUNCTION: cmake-utils_use_disable +# @USAGE: [flag name] +# @DESCRIPTION: +# Based on inversion of use_enable. See ebuild(5). +# +# `cmake-utils_use_enable foo FOO` echoes -DDISABLE_FOO=3DOFF if foo is = enabled +# and -DDISABLE_FOO=3DON if it is disabled. +cmake-utils_use_disable() { _use_me_now_inverted DISABLE_ "$@" ; } + +# @FUNCTION: cmake-utils_use_no +# @USAGE: [flag name] +# @DESCRIPTION: +# Based on use_disable. See ebuild(5). +# +# `cmake-utils_use_no foo FOO` echoes -DNO_FOO=3DOFF if foo is enabled +# and -DNO_FOO=3DON if it is disabled. +cmake-utils_use_no() { _use_me_now_inverted NO_ "$@" ; } + +# @FUNCTION: cmake-utils_use_want +# @USAGE: [flag name] +# @DESCRIPTION: +# Based on use_enable. See ebuild(5). +# +# `cmake-utils_use_want foo FOO` echoes -DWANT_FOO=3DON if foo is enable= d +# and -DWANT_FOO=3DOFF if it is disabled. +cmake-utils_use_want() { _use_me_now WANT_ "$@" ; } + +# @FUNCTION: cmake-utils_use_build +# @USAGE: [flag name] +# @DESCRIPTION: +# Based on use_enable. See ebuild(5). +# +# `cmake-utils_use_build foo FOO` echoes -DBUILD_FOO=3DON if foo is enab= led +# and -DBUILD_FOO=3DOFF if it is disabled. +cmake-utils_use_build() { _use_me_now BUILD_ "$@" ; } + +# @FUNCTION: cmake-utils_use_has +# @USAGE: [flag name] +# @DESCRIPTION: +# Based on use_enable. See ebuild(5). +# +# `cmake-utils_use_has foo FOO` echoes -DHAVE_FOO=3DON if foo is enabled +# and -DHAVE_FOO=3DOFF if it is disabled. +cmake-utils_use_has() { _use_me_now HAVE_ "$@" ; } + +# @FUNCTION: cmake-utils_use_use +# @USAGE: [flag name] +# @DESCRIPTION: +# Based on use_enable. See ebuild(5). +# +# `cmake-utils_use_use foo FOO` echoes -DUSE_FOO=3DON if foo is enabled +# and -DUSE_FOO=3DOFF if it is disabled. +cmake-utils_use_use() { _use_me_now USE_ "$@" ; } + +# @FUNCTION: cmake-utils_use +# @USAGE: [flag name] +# @DESCRIPTION: +# Based on use_enable. See ebuild(5). +# +# `cmake-utils_use foo FOO` echoes -DFOO=3DON if foo is enabled +# and -DFOO=3DOFF if it is disabled. +cmake-utils_use() { _use_me_now "" "$@" ; } + +# Internal function for modifying hardcoded definitions. +# Removes dangerous definitions that override Gentoo settings. +_modify-cmakelists() { + debug-print-function ${FUNCNAME} "$@" + + # Only edit the files once + grep -qs "<<< Gentoo configuration >>>" CMakeLists.txt && return 0 + + # Comment out all set ( value) + # TODO Add QA checker - inform when variable being checked for below is= set in CMakeLists.txt + find "${CMAKE_USE_DIR}" -name CMakeLists.txt \ + -exec sed -i -e '/^[[:space:]]*[sS][eE][tT][[:space:]]*([[:space:]]*CM= AKE_BUILD_TYPE.*)/{s/^/#IGNORE /g}' {} + \ + -exec sed -i -e '/^[[:space:]]*[sS][eE][tT][[:space:]]*([[:space:]]*CM= AKE_COLOR_MAKEFILE.*)/{s/^/#IGNORE /g}' {} + \ + -exec sed -i -e '/^[[:space:]]*[sS][eE][tT][[:space:]]*([[:space:]]*CM= AKE_INSTALL_PREFIX.*)/{s/^/#IGNORE /g}' {} + \ + -exec sed -i -e '/^[[:space:]]*[sS][eE][tT][[:space:]]*([[:space:]]*CM= AKE_VERBOSE_MAKEFILE.*)/{s/^/#IGNORE /g}' {} + \ + || die "${LINENO}: failed to disable hardcoded settings" + + # NOTE Append some useful summary here + cat >> "${CMAKE_USE_DIR}"/CMakeLists.txt <<- _EOF_ + + MESSAGE(STATUS "<<< Gentoo configuration >>> + Build type \${CMAKE_BUILD_TYPE} + Install path \${CMAKE_INSTALL_PREFIX} + Compiler flags: + C \${CMAKE_C_FLAGS} + C++ \${CMAKE_CXX_FLAGS} + Linker flags: + Executable \${CMAKE_EXE_LINKER_FLAGS} + Module \${CMAKE_MODULE_LINKER_FLAGS} + Shared \${CMAKE_SHARED_LINKER_FLAGS}\n") + _EOF_ +} + +enable_cmake-utils_src_configure() { + debug-print-function ${FUNCNAME} "$@" + + _check_build_dir + + # check if CMakeLists.txt exist and if no then die + if [[ ! -e ${CMAKE_USE_DIR}/CMakeLists.txt ]] ; then + eerror "Unable to locate CMakeLists.txt under:" + eerror "\"${CMAKE_USE_DIR}/CMakeLists.txt\"" + eerror "Consider not inheriting the cmake eclass." + die "FATAL: Unable to find CMakeLists.txt" + fi + + # Remove dangerous things. + _modify-cmakelists + + # Fix xdg collision with sandbox + export XDG_CONFIG_HOME=3D"${T}" + + # @SEE CMAKE_BUILD_TYPE + if [[ ${CMAKE_BUILD_TYPE} =3D Gentoo ]]; then + # Handle release builds + if ! has debug ${IUSE//+} || ! use debug; then + append-cppflags -DNDEBUG + fi + fi + + # Prepare Gentoo override rules (set valid compiler, append CPPFLAGS) + local build_rules=3D${T}/gentoo_rules.cmake + cat > "${build_rules}" <<- _EOF_ + SET (CMAKE_C_COMPILER $(type -P $(tc-getCC)) CACHE FILEPATH "C compile= r" FORCE) + SET (CMAKE_C_COMPILE_OBJECT " ${CPPFLAGS} = -o -c " CACHE STRING "C compile command" FORCE) + SET (CMAKE_CXX_COMPILER $(type -P $(tc-getCXX)) CACHE FILEPATH "C++ co= mpiler" FORCE) + SET (CMAKE_CXX_COMPILE_OBJECT " ${CPPFLA= GS} -o -c " CACHE STRING "C++ compile command" F= ORCE) + _EOF_ + + if use prefix; then + cat >> "${build_rules}" <<- _EOF_ + # in Prefix we need rpath and must ensure cmake gets our default link= er path + # right ... except for Darwin hosts + IF (NOT APPLE) + SET (CMAKE_SKIP_RPATH OFF CACHE BOOL "" FORCE) + SET (CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH "${EPREFIX}/usr/${CHOST}/li= b/gcc;${EPREFIX}/usr/${CHOST}/lib;${EPREFIX}/usr/$(get_libdir);${EPREFIX}= /$(get_libdir)" + CACHE STRING "" FORCE) + + ELSE () + + SET(CMAKE_PREFIX_PATH "${EPREFIX}${PREFIX:-/usr}" CACHE STRING ""FORC= E) + SET(CMAKE_SKIP_BUILD_RPATH OFF CACHE BOOL "" FORCE) + SET(CMAKE_SKIP_RPATH OFF CACHE BOOL "" FORCE) + SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE CACHE BOOL "" FORCE)=20 + SET(CMAKE_INSTALL_RPATH "${EPREFIX}${PREFIX:-/usr}/lib;${EPREFIX}/usr= /${CHOST}/lib/gcc;${EPREFIX}/usr/${CHOST}/lib;${EPREFIX}/usr/$(get_libdir= );${EPREFIX}/$(get_libdir)" CACHE STRING "" FORCE) + SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE CACHE BOOL "" FORCE) + SET(CMAKE_INSTALL_NAME_DIR "${EPREFIX}${PREFIX:-/usr}/lib" CACHE STRI= NG "" FORCE) + + ENDIF (NOT APPLE) + _EOF_ + fi + + # Common configure parameters (invariants) + local common_config=3D${T}/gentoo_common_config.cmake + local libdir=3D$(get_libdir) + cat > "${common_config}" <<- _EOF_ + SET (LIB_SUFFIX ${libdir/lib} CACHE STRING "library path suffix" FORCE= ) + SET (CMAKE_INSTALL_LIBDIR ${libdir} CACHE PATH "Output directory for l= ibraries") + _EOF_ + [[ "${NOCOLOR}" =3D true || "${NOCOLOR}" =3D yes ]] && echo 'SET (CMAKE= _COLOR_MAKEFILE OFF CACHE BOOL "pretty colors during make" FORCE)' >> "${= common_config}" + + # Convert mycmakeargs to an array, for backwards compatibility + # Make the array a local variable since <=3Dportage-2.1.6.x does not + # support global arrays (see bug #297255). + if [[ $(declare -p mycmakeargs 2>&-) !=3D "declare -a mycmakeargs=3D"* = ]]; then + local mycmakeargs_local=3D(${mycmakeargs}) + else + local mycmakeargs_local=3D("${mycmakeargs[@]}") + fi + + has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=3D + + # Common configure parameters (overridable) + # NOTE CMAKE_BUILD_TYPE can be only overriden via CMAKE_BUILD_TYPE ecla= ss variable + # No -DCMAKE_BUILD_TYPE=3Dxxx definitions will be in effect. + local cmakeargs=3D( + --no-warn-unused-cli + -C "${common_config}" + -DCMAKE_INSTALL_PREFIX=3D"${EPREFIX}${PREFIX:-/usr}" + "${mycmakeargs_local[@]}" + -DCMAKE_BUILD_TYPE=3D"${CMAKE_BUILD_TYPE}" + -DCMAKE_INSTALL_DO_STRIP=3DOFF + -DCMAKE_USER_MAKE_RULES_OVERRIDE=3D"${build_rules}" + "${MYCMAKEARGS}" + ) + + mkdir -p "${CMAKE_BUILD_DIR}" + pushd "${CMAKE_BUILD_DIR}" > /dev/null + debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: mycmakeargs is ${mycmakea= rgs_local[*]}" + echo "${CMAKE_BINARY}" "${cmakeargs[@]}" "${CMAKE_USE_DIR}" + "${CMAKE_BINARY}" "${cmakeargs[@]}" "${CMAKE_USE_DIR}" || die "cmake fa= iled" + 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 "$@" +} + +# @FUNCTION: cmake-utils_src_make +# @DESCRIPTION: +# Function for building the package. Automatically detects the build typ= e. +# All arguments are passed to emake. +cmake-utils_src_make() { + debug-print-function ${FUNCNAME} "$@" + + _check_build_dir + pushd "${CMAKE_BUILD_DIR}" > /dev/null + # first check if Makefile exist otherwise die + [[ -e Makefile ]] || die "Makefile not found. Error during configure st= age." + if [[ -n ${CMAKE_VERBOSE} ]]; then + emake VERBOSE=3D1 "$@" || die "Make failed!" + else + emake "$@" || die "Make failed!" + fi + popd > /dev/null +} + +enable_cmake-utils_src_install() { + debug-print-function ${FUNCNAME} "$@" + + _check_build_dir + pushd "${CMAKE_BUILD_DIR}" > /dev/null + base_src_install "$@" + popd > /dev/null + + # Backward compatibility, for non-array variables + if [[ -n "${DOCS}" ]] && [[ "$(declare -p DOCS 2>/dev/null 2>&1)" !=3D = "declare -a"* ]]; then + dodoc ${DOCS} || die "dodoc failed" + fi + if [[ -n "${HTML_DOCS}" ]] && [[ "$(declare -p HTML_DOCS 2>/dev/null 2>= &1)" !=3D "declare -a"* ]]; then + dohtml -r ${HTML_DOCS} || die "dohtml failed" + fi +} + +enable_cmake-utils_src_test() { + debug-print-function ${FUNCNAME} "$@" + local ctestargs + + _check_build_dir + pushd "${CMAKE_BUILD_DIR}" > /dev/null + [[ -e CTestTestfile.cmake ]] || { echo "No tests found. Skipping."; ret= urn 0 ; } + + [[ -n ${TEST_VERBOSE} ]] && ctestargs=3D"--extra-verbose --output-on-fa= ilure" + ctest ${ctestargs} "$@" || die "Tests failed." + popd > /dev/null +} + +# @FUNCTION: cmake-utils_src_configure +# @DESCRIPTION: +# General function for configuring with cmake. Default behaviour is to s= tart an +# out-of-source build. +cmake-utils_src_configure() { + _execute_optionaly "src_configure" "$@" +} + +# @FUNCTION: cmake-utils_src_compile +# @DESCRIPTION: +# General function for compiling with cmake. Default behaviour is to che= ck for +# EAPI and respectively to configure as well or just compile. +# Automatically detects the build type. All arguments are passed to emak= e. +cmake-utils_src_compile() { + _execute_optionaly "src_compile" "$@" +} + +# @FUNCTION: cmake-utils_src_install +# @DESCRIPTION: +# Function for installing the package. Automatically detects the build t= ype. +cmake-utils_src_install() { + _execute_optionaly "src_install" "$@" +} + +# @FUNCTION: cmake-utils_src_test +# @DESCRIPTION: +# Function for testing the package. Automatically detects the build type= . +cmake-utils_src_test() { + _execute_optionaly "src_test" "$@" +} + +# Optionally executes phases based on WANT_CMAKE variable/USE flag. +_execute_optionaly() { + local phase=3D"$1" ; shift + if [[ ${WANT_CMAKE} =3D always ]]; then + enable_cmake-utils_${phase} "$@" + else + use ${WANT_CMAKE} && enable_cmake-utils_${phase} "$@" + fi +}