/[gentoo-x86]/eclass/cmake-utils.eclass
Gentoo

Diff of /eclass/cmake-utils.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.28 Revision 1.59
1# Copyright 1999-2009 Gentoo Foundation 1# Copyright 1999-2010 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/cmake-utils.eclass,v 1.28 2009/05/29 08:06:46 scarabeus Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/cmake-utils.eclass,v 1.59 2010/09/16 16:04:11 reavertm Exp $
4 4
5# @ECLASS: cmake-utils.eclass 5# @ECLASS: cmake-utils.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# kde@gentoo.org 7# kde@gentoo.org
8# 8#
9# @CODE 9# @CODE
10# Tomáš Chvátal <scarabeus@gentoo.org> 10# Tomáš Chvátal <scarabeus@gentoo.org>
11# Maciej Mrozowski <reavertm@poczta.fm> 11# Maciej Mrozowski <reavertm@gentoo.org>
12# (undisclosed contributors) 12# (undisclosed contributors)
13# Original author: Zephyrus (zephyrus@mirach.it) 13# Original author: Zephyrus (zephyrus@mirach.it)
14# @CODE 14# @CODE
15# @BLURB: common ebuild functions for cmake-based packages 15# @BLURB: common ebuild functions for cmake-based packages
16# @DESCRIPTION: 16# @DESCRIPTION:
17# The cmake-utils eclass contains functions that make creating ebuilds for 17# The cmake-utils eclass is base.eclass(5) wrapper that makes creating ebuilds for
18# cmake-based packages much easier. 18# cmake-based packages much easier.
19# Its main features are support of out-of-source builds as well as in-source 19# It provides all inherited features (DOCS, HTML_DOCS, PATCHES) along with out-of-source
20# builds and an implementation of the well-known use_enable and use_with 20# builds (default), in-source builds and an implementation of the well-known use_enable
21# functions for CMake. 21# and use_with functions for CMake.
22 22
23# @ECLASS-VARIABLE: WANT_CMAKE
24# @DESCRIPTION:
25# Specify if cmake-utils eclass should depend on cmake optionaly or not.
26# This is usefull when only part of aplication is using cmake build system.
27# Valid values are: always [default], optional (where the value is the useflag
28# used for optionality)
29WANT_CMAKE="${WANT_CMAKE:-always}"
30
31# @ECLASS-VARIABLE: CMAKE_MIN_VERSION
32# @DESCRIPTION:
33# Specify the minimum required CMake version. Default is 2.6.2-r1
34CMAKE_MIN_VERSION="${CMAKE_MIN_VERSION:-2.6.2-r1}"
35
36CMAKEDEPEND=""
37case ${WANT_CMAKE} in
38 always)
39 ;;
40 *)
41 IUSE+=" ${WANT_CMAKE}"
42 CMAKEDEPEND+="${WANT_CMAKE}? ( "
43 ;;
44esac
23inherit toolchain-funcs multilib flag-o-matic base 45inherit toolchain-funcs multilib flag-o-matic base
24 46
25EXPF="src_compile src_test src_install" 47CMAKE_EXPF="src_compile src_test src_install"
26case ${EAPI:-0} in 48case ${EAPI:-0} in
27 2) EXPF="${EXPF} src_configure" ;; 49 3|2) CMAKE_EXPF+=" src_configure" ;;
28 1|0) ;; 50 1|0) ;;
29 *) die "Unknown EAPI, Bug eclass maintainers." ;; 51 *) die "Unknown EAPI, Bug eclass maintainers." ;;
30esac 52esac
31EXPORT_FUNCTIONS ${EXPF} 53EXPORT_FUNCTIONS ${CMAKE_EXPF}
32 54
33: ${DESCRIPTION:="Based on the ${ECLASS} eclass"} 55: ${DESCRIPTION:="Based on the ${ECLASS} eclass"}
34 56
35if [[ ${PN} != cmake ]]; then 57if [[ ${PN} != cmake ]]; then
36 CMAKEDEPEND=">=dev-util/cmake-2.6.2-r1" 58 CMAKEDEPEND+=">=dev-util/cmake-${CMAKE_MIN_VERSION}"
37fi 59fi
38 60
61CMAKEDEPEND+=" userland_GNU? ( >=sys-apps/findutils-4.4.0 )"
62
63[[ ${WANT_CMAKE} = always ]] || CMAKEDEPEND+=" )"
64
39DEPEND="${CMAKEDEPEND} 65DEPEND="${CMAKEDEPEND}"
40 userland_GNU? ( >=sys-apps/findutils-4.4.0 ) 66unset CMAKEDEPEND
41"
42 67
43# Internal functions used by cmake-utils_use_* 68# Internal functions used by cmake-utils_use_*
44_use_me_now() { 69_use_me_now() {
45 debug-print-function ${FUNCNAME} "$@" 70 debug-print-function ${FUNCNAME} "$@"
46 71
74 echo "-D$1$x=$(use $2 && echo OFF || echo ON) " 99 echo "-D$1$x=$(use $2 && echo OFF || echo ON) "
75 done 100 done
76 fi 101 fi
77} 102}
78 103
79# @ECLASS-VARIABLE: DOCS
80# @DESCRIPTION:
81# Documents passed to dodoc command.
82
83# @ECLASS-VARIABLE: HTML_DOCS
84# @DESCRIPTION:
85# Documents passed to dohtml command.
86
87# @ECLASS-VARIABLE: PREFIX
88# @DESCRIPTION:
89# Eclass respects PREFIX variable, though it's not recommended way to set
90# install/lib/bin prefixes.
91# Use -DCMAKE_INSTALL_PREFIX=... CMake variable instead.
92
93# @ECLASS-VARIABLE: CMAKE_IN_SOURCE_BUILD 104# @ECLASS-VARIABLE: CMAKE_BUILD_DIR
94# @DESCRIPTION: 105# @DESCRIPTION:
95# Set to enable in-source build. 106# Build directory where all cmake processed files should be generated.
96 107# For in-source build it's fixed to ${CMAKE_USE_DIR}.
97# @ECLASS-VARIABLE: CMAKE_NO_COLOR 108# For out-of-source build it can be overriden, by default it uses
98# @DESCRIPTION: 109# ${WORKDIR}/${P}_build.
99# Set to disable cmake output coloring.
100
101# @ECLASS-VARIABLE: CMAKE_VERBOSE
102# @DESCRIPTION:
103# Set to enable verbose messages during compilation.
104 110
105# @ECLASS-VARIABLE: CMAKE_BUILD_TYPE 111# @ECLASS-VARIABLE: CMAKE_BUILD_TYPE
106# @DESCRIPTION: 112# @DESCRIPTION:
107# Set to override default CMAKE_BUILD_TYPE. Only useful for packages 113# Set to override default CMAKE_BUILD_TYPE. Only useful for packages
108# known to make use of "if (CMAKE_BUILD_TYPE MATCHES xxx)". 114# known to make use of "if (CMAKE_BUILD_TYPE MATCHES xxx)".
109# If about to be set - needs to be set before invoking cmake-utils_src_configure. 115# If about to be set - needs to be set before invoking cmake-utils_src_configure.
110# You usualy do *NOT* want nor need to set it as it pulls CMake default build-type 116# You usualy do *NOT* want nor need to set it as it pulls CMake default build-type
111# specific compiler flags overriding make.conf. 117# specific compiler flags overriding make.conf.
112: ${CMAKE_BUILD_TYPE:=Gentoo} 118: ${CMAKE_BUILD_TYPE:=Gentoo}
113 119
114# @FUNCTION: _check_build_dir 120# @ECLASS-VARIABLE: CMAKE_IN_SOURCE_BUILD
115# @DESCRIPTION: 121# @DESCRIPTION:
122# Set to enable in-source build.
123
124# @ECLASS-VARIABLE: CMAKE_USE_DIR
125# @DESCRIPTION:
126# Sets the directory where we are working with cmake.
127# For example when application uses autotools and only one
128# plugin needs to be done by cmake.
129# By default it uses ${S}.
130
131# @ECLASS-VARIABLE: CMAKE_VERBOSE
132# @DESCRIPTION:
133# Set to enable verbose messages during compilation.
134
135# @ECLASS-VARIABLE: PREFIX
136# @DESCRIPTION:
137# Eclass respects PREFIX variable, though it's not recommended way to set
138# install/lib/bin prefixes.
139# Use -DCMAKE_INSTALL_PREFIX=... CMake variable instead.
140
116# Determine using IN or OUT source build 141# Determine using IN or OUT source build
117_check_build_dir() { 142_check_build_dir() {
118 # @ECLASS-VARIABLE: CMAKE_USE_DIR
119 # @DESCRIPTION:
120 # Sets the directory where we are working with cmake.
121 # For example when application uses autotools and only one
122 # plugin needs to be done by cmake.
123 # By default it uses ${S}.
124 : ${CMAKE_USE_DIR:=${S}} 143 : ${CMAKE_USE_DIR:=${S}}
125
126 # @ECLASS-VARIABLE: CMAKE_BUILD_DIR
127 # @DESCRIPTION:
128 # Specify the build directory where all cmake processed
129 # files should be located.
130 #
131 # For installing binary doins "${CMAKE_BUILD_DIR}/${PN}"
132 if [[ -n "${CMAKE_IN_SOURCE_BUILD}" ]]; then 144 if [[ -n ${CMAKE_IN_SOURCE_BUILD} ]]; then
145 # we build in source dir
133 CMAKE_BUILD_DIR="${CMAKE_USE_DIR}" 146 CMAKE_BUILD_DIR="${CMAKE_USE_DIR}"
134 else 147 else
135 [[ ${1} = init || -d ${CMAKE_USE_DIR}_build ]] && SUF="_build" || SUF="" 148 : ${CMAKE_BUILD_DIR:=${WORKDIR}/${P}_build}
136 CMAKE_BUILD_DIR="${CMAKE_USE_DIR}${SUF}"
137
138 fi 149 fi
139 echo ">>> Working in BUILD_DIR: \"$CMAKE_BUILD_DIR\"" 150 echo ">>> Working in BUILD_DIR: \"$CMAKE_BUILD_DIR\""
140} 151}
141# @FUNCTION: cmake-utils_use_with 152# @FUNCTION: cmake-utils_use_with
142# @USAGE: <USE flag> [flag name] 153# @USAGE: <USE flag> [flag name]
199# 210#
200# `cmake-utils_use_has foo FOO` echoes -DHAVE_FOO=ON if foo is enabled 211# `cmake-utils_use_has foo FOO` echoes -DHAVE_FOO=ON if foo is enabled
201# and -DHAVE_FOO=OFF if it is disabled. 212# and -DHAVE_FOO=OFF if it is disabled.
202cmake-utils_use_has() { _use_me_now HAVE_ "$@" ; } 213cmake-utils_use_has() { _use_me_now HAVE_ "$@" ; }
203 214
204# @FUNCTION: cmake-utils_has 215# @FUNCTION: cmake-utils_use_use
216# @USAGE: <USE flag> [flag name]
205# @DESCRIPTION: 217# @DESCRIPTION:
206# Deprecated, use cmake-utils_use_has, kept now for backcompat. 218# Based on use_enable. See ebuild(5).
207cmake-utils_has() { ewarn "QA notice: using deprecated ${FUNCNAME} call, use cmake-utils_use_has instead." ; _use_me_now HAVE_ "$@" ; } 219#
220# `cmake-utils_use_use foo FOO` echoes -DUSE_FOO=ON if foo is enabled
221# and -DUSE_FOO=OFF if it is disabled.
222cmake-utils_use_use() { _use_me_now USE_ "$@" ; }
208 223
209# @FUNCTION: cmake-utils_use 224# @FUNCTION: cmake-utils_use
210# @USAGE: <USE flag> [flag name] 225# @USAGE: <USE flag> [flag name]
211# @DESCRIPTION: 226# @DESCRIPTION:
212# Based on use_enable. See ebuild(5). 227# Based on use_enable. See ebuild(5).
214# `cmake-utils_use foo FOO` echoes -DFOO=ON if foo is enabled 229# `cmake-utils_use foo FOO` echoes -DFOO=ON if foo is enabled
215# and -DFOO=OFF if it is disabled. 230# and -DFOO=OFF if it is disabled.
216cmake-utils_use() { _use_me_now "" "$@" ; } 231cmake-utils_use() { _use_me_now "" "$@" ; }
217 232
218# Internal function for modifying hardcoded definitions. 233# Internal function for modifying hardcoded definitions.
219# Removes dangerous definitionts that override Gentoo settings. 234# Removes dangerous definitions that override Gentoo settings.
220_modify-cmakelists() { 235_modify-cmakelists() {
221 debug-print-function ${FUNCNAME} "$@" 236 debug-print-function ${FUNCNAME} "$@"
222 237
223 # Comment out all set (<some_should_be_user_defined_variable> value) 238 # Comment out all set (<some_should_be_user_defined_variable> value)
224 # TODO Add QA checker - inform when variable being checked for below is set in CMakeLists.txt 239 # TODO Add QA checker - inform when variable being checked for below is set in CMakeLists.txt
225 find "${CMAKE_USE_DIR}" -name CMakeLists.txt \ 240 find "${CMAKE_USE_DIR}" -name CMakeLists.txt \
226 -exec sed -i -e '/^[[:space:]]*[sS][eE][tT][[:space:]]*([[:space:]]*CMAKE_BUILD_TYPE.*)/{s/^/#IGNORE /g}' {} + \ 241 -exec sed -i -e '/^[[:space:]]*[sS][eE][tT][[:space:]]*([[:space:]]*CMAKE_BUILD_TYPE.*)/{s/^/#IGNORE /g}' {} + \
242 -exec sed -i -e '/^[[:space:]]*[sS][eE][tT][[:space:]]*([[:space:]]*CMAKE_COLOR_MAKEFILE.*)/{s/^/#IGNORE /g}' {} + \
227 -exec sed -i -e '/^[[:space:]]*[sS][eE][tT][[:space:]]*([[:space:]]*CMAKE_INSTALL_PREFIX.*)/{s/^/#IGNORE /g}' {} + \ 243 -exec sed -i -e '/^[[:space:]]*[sS][eE][tT][[:space:]]*([[:space:]]*CMAKE_INSTALL_PREFIX.*)/{s/^/#IGNORE /g}' {} + \
244 -exec sed -i -e '/^[[:space:]]*[sS][eE][tT][[:space:]]*([[:space:]]*CMAKE_VERBOSE_MAKEFILE.*)/{s/^/#IGNORE /g}' {} + \
228 || die "${LINENO}: failed to disable hardcoded settings" 245 || die "${LINENO}: failed to disable hardcoded settings"
229 246
230 # NOTE Append some useful summary here 247 # NOTE Append some useful summary here
231 echo ' 248 cat >> CMakeLists.txt <<- _EOF_
249
232MESSAGE(STATUS "<<< Gentoo configuration >>> 250 MESSAGE(STATUS "<<< Gentoo configuration >>>
233Build type: ${CMAKE_BUILD_TYPE} 251 Build type \${CMAKE_BUILD_TYPE}
234Install path: ${CMAKE_INSTALL_PREFIX}\n")' >> CMakeLists.txt 252 Install path \${CMAKE_INSTALL_PREFIX}
253 Compiler flags:
254 C \${CMAKE_C_FLAGS}
255 C++ \${CMAKE_CXX_FLAGS}
256 Linker flags:
257 Executable \${CMAKE_EXE_LINKER_FLAGS}
258 Module \${CMAKE_MODULE_LINKER_FLAGS}
259 Shared \${CMAKE_SHARED_LINKER_FLAGS}\n")
260 _EOF_
235} 261}
236 262
237# @FUNCTION: cmake-utils_src_configure
238# @DESCRIPTION:
239# General function for configuring with cmake. Default behaviour is to start an
240# out-of-source build.
241cmake-utils_src_configure() { 263enable_cmake-utils_src_configure() {
242 debug-print-function ${FUNCNAME} "$@" 264 debug-print-function ${FUNCNAME} "$@"
243 265
244 _check_build_dir init 266 _check_build_dir init
245 267
246 # check if CMakeLists.txt exist and if no then die 268 # check if CMakeLists.txt exist and if no then die
247 if [[ ! -e "${CMAKE_USE_DIR}"/CMakeLists.txt ]] ; then 269 if [[ ! -e ${CMAKE_USE_DIR}/CMakeLists.txt ]] ; then
248 eerror "I was unable to locate CMakeLists.txt under:" 270 eerror "Unable to locate CMakeLists.txt under:"
249 eerror "\"${CMAKE_USE_DIR}/CMakeLists.txt\"" 271 eerror "\"${CMAKE_USE_DIR}/CMakeLists.txt\""
250 eerror "You should consider not inheriting the cmake eclass." 272 eerror "Consider not inheriting the cmake eclass."
251 die "FATAL: Unable to find CMakeLists.txt" 273 die "FATAL: Unable to find CMakeLists.txt"
252 fi 274 fi
253 275
254 # Remove dangerous things. 276 # Remove dangerous things.
255 _modify-cmakelists 277 _modify-cmakelists
278
279 # Fix xdg collision with sandbox
280 export XDG_CONFIG_HOME="${T}"
256 281
257 # @SEE CMAKE_BUILD_TYPE 282 # @SEE CMAKE_BUILD_TYPE
258 if [[ ${CMAKE_BUILD_TYPE} = Gentoo ]]; then 283 if [[ ${CMAKE_BUILD_TYPE} = Gentoo ]]; then
259 # Handle release builds 284 # Handle release builds
260 if ! has debug ${IUSE//+} || ! use debug; then 285 if ! has debug ${IUSE//+} || ! use debug; then
261 append-cppflags -DNDEBUG 286 append-cppflags -DNDEBUG
262 fi 287 fi
263 fi 288 fi
264 289
265 # Prepare Gentoo override rules (set valid compiler, append CPPFLAGS) 290 # Prepare Gentoo override rules (set valid compiler, append CPPFLAGS)
266 local build_rules="${TMPDIR}"/gentoo_rules.cmake 291 local build_rules=${T}/gentoo_rules.cmake
267cat > ${build_rules} << _EOF_ 292 cat > "${build_rules}" <<- _EOF_
268SET (CMAKE_C_COMPILER $(type -P $(tc-getCC)) CACHE FILEPATH "C compiler" FORCE) 293 SET (CMAKE_C_COMPILER $(type -P $(tc-getCC)) CACHE FILEPATH "C compiler" FORCE)
269SET (CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> <DEFINES> ${CPPFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "C compile command" FORCE) 294 SET (CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> <DEFINES> ${CPPFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "C compile command" FORCE)
270SET (CMAKE_CXX_COMPILER $(type -P $(tc-getCXX)) CACHE FILEPATH "C++ compiler" FORCE) 295 SET (CMAKE_CXX_COMPILER $(type -P $(tc-getCXX)) CACHE FILEPATH "C++ compiler" FORCE)
271SET (CMAKE_CXX_COMPILE_OBJECT "<CMAKE_CXX_COMPILER> <DEFINES> ${CPPFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "C++ compile command" FORCE) 296 SET (CMAKE_CXX_COMPILE_OBJECT "<CMAKE_CXX_COMPILER> <DEFINES> ${CPPFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "C++ compile command" FORCE)
272_EOF_ 297 _EOF_
298
299 if use prefix; then
300 cat >> "${build_rules}" <<- _EOF_
301 # in Prefix we need rpath and must ensure cmake gets our default linker path
302 # right ... except for Darwin hosts
303 IF (NOT APPLE)
304 SET (CMAKE_SKIP_RPATH OFF CACHE BOOL "" FORCE)
305 SET (CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH "${EPREFIX}/usr/${CHOST}/lib/gcc;${EPREFIX}/usr/${CHOST}/lib;${EPREFIX}/usr/$(get_libdir);${EPREFIX}/$(get_libdir)"
306 CACHE STRING "" FORCE)
307 ENDIF (NOT APPLE)
308 _EOF_
309 fi
310
311 # Common configure parameters (invariants)
312 local common_config=${T}/gentoo_common_config.cmake
313 local libdir=$(get_libdir)
314 cat > "${common_config}" <<- _EOF_
315 SET (LIB_SUFFIX ${libdir/lib} CACHE STRING "library path suffix" FORCE)
316 SET (CMAKE_INSTALL_LIBDIR ${libdir} CACHE PATH "Output directory for libraries")
317 _EOF_
318 [[ "${NOCOLOR}" = true || "${NOCOLOR}" = yes ]] && echo 'SET (CMAKE_COLOR_MAKEFILE OFF CACHE BOOL "pretty colors during make" FORCE)' >> "${common_config}"
319
320 # Convert mycmakeargs to an array, for backwards compatibility
321 # Make the array a local variable since <=portage-2.1.6.x does not
322 # support global arrays (see bug #297255).
323 if [[ $(declare -p mycmakeargs 2>&-) != "declare -a mycmakeargs="* ]]; then
324 local mycmakeargs_local=(${mycmakeargs})
325 else
326 local mycmakeargs_local=("${mycmakeargs[@]}")
327 fi
328
329 has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
273 330
274 # Common configure parameters (overridable) 331 # Common configure parameters (overridable)
275 # NOTE CMAKE_BUILD_TYPE can be only overriden via CMAKE_BUILD_TYPE eclass variable 332 # NOTE CMAKE_BUILD_TYPE can be only overriden via CMAKE_BUILD_TYPE eclass variable
276 # No -DCMAKE_BUILD_TYPE=xxx definitions will be in effect. 333 # No -DCMAKE_BUILD_TYPE=xxx definitions will be in effect.
277 local cmakeargs=" 334 local cmakeargs=(
335 -C "${common_config}"
278 -DCMAKE_INSTALL_PREFIX=${PREFIX:-/usr} 336 -DCMAKE_INSTALL_PREFIX="${EPREFIX}${PREFIX:-/usr}"
279 ${mycmakeargs} 337 "${mycmakeargs_local[@]}"
280 -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} 338 -DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}"
281 -DCMAKE_INSTALL_DO_STRIP=OFF 339 -DCMAKE_INSTALL_DO_STRIP=OFF
282 -DCMAKE_USER_MAKE_RULES_OVERRIDE=${build_rules}" 340 -DCMAKE_USER_MAKE_RULES_OVERRIDE="${build_rules}"
283 341 "${MYCMAKEARGS}"
284 # Common configure parameters (invariants) 342 )
285 local common_config="${TMPDIR}"/gentoo_common_config.cmake
286 local libdir=$(get_libdir)
287cat > ${common_config} << _EOF_
288SET (LIB_SUFFIX ${libdir/lib} CACHE STRING "library path suffix" FORCE)
289_EOF_
290 [[ -n ${CMAKE_NO_COLOR} ]] && echo 'SET (CMAKE_COLOR_MAKEFILE OFF CACHE BOOL "pretty colors during make" FORCE)' >> ${common_config}
291 cmakeargs="-C ${common_config} ${cmakeargs}"
292 343
293 mkdir -p "${CMAKE_BUILD_DIR}" 344 mkdir -p "${CMAKE_BUILD_DIR}"
294 pushd "${CMAKE_BUILD_DIR}" > /dev/null 345 pushd "${CMAKE_BUILD_DIR}" > /dev/null
295 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: mycmakeargs is $cmakeargs" 346 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: mycmakeargs is ${mycmakeargs_local[*]}"
347 echo cmake "${cmakeargs[@]}" "${CMAKE_USE_DIR}"
296 cmake ${cmakeargs} "${CMAKE_USE_DIR}" || die "cmake failed" 348 cmake "${cmakeargs[@]}" "${CMAKE_USE_DIR}" || die "cmake failed"
297
298 popd > /dev/null 349 popd > /dev/null
299} 350}
300 351
301# @FUNCTION: cmake-utils_src_compile
302# @DESCRIPTION:
303# General function for compiling with cmake. Default behaviour is to check for
304# EAPI and respectively to configure as well or just compile.
305cmake-utils_src_compile() { 352enable_cmake-utils_src_compile() {
306 debug-print-function ${FUNCNAME} "$@" 353 debug-print-function ${FUNCNAME} "$@"
307 354
308 has src_configure ${EXPF} || cmake-utils_src_configure 355 has src_configure ${CMAKE_EXPF} || cmake-utils_src_configure
309 cmake-utils_src_make "$@" 356 cmake-utils_src_make "$@"
310} 357}
311 358
312# @FUNCTION: cmake-utils_src_configurein
313# @DESCRIPTION:
314# Deprecated
315cmake-utils_src_configurein() {
316 ewarn "QA notice: using deprecated ${FUNCNAME} call, set CMAKE_IN_SOURCE_BUILD=1 instead."
317 cmake-utils_src_configure
318}
319
320# @FUNCTION: cmake-utils_src_configureout
321# @DESCRIPTION:
322# Deprecated
323cmake-utils_src_configureout() {
324 ewarn "QA notice: using deprecated ${FUNCNAME} call, out of source build is enabled by default."
325 cmake-utils_src_configure
326}
327
328# @FUNCTION: cmake-utils_src_make 359# @FUNCTION: cmake-utils_src_make
329# @DESCRIPTION: 360# @DESCRIPTION:
330# Function for building the package. Automatically detects the build type. 361# Function for building the package. Automatically detects the build type.
331# All arguments are passed to emake: 362# All arguments are passed to emake.
332cmake-utils_src_make() { 363cmake-utils_src_make() {
333 debug-print-function ${FUNCNAME} "$@" 364 debug-print-function ${FUNCNAME} "$@"
334 365
335 _check_build_dir 366 _check_build_dir
336 pushd "${CMAKE_BUILD_DIR}" &> /dev/null 367 pushd "${CMAKE_BUILD_DIR}" > /dev/null
337 # first check if Makefile exist otherwise die 368 # first check if Makefile exist otherwise die
338 [[ -e Makefile ]] || die "Makefile not found. Error during configure stage." 369 [[ -e Makefile ]] || die "Makefile not found. Error during configure stage."
339 if [[ -n ${CMAKE_VERBOSE} ]]; then 370 if [[ -n ${CMAKE_VERBOSE} ]]; then
340 emake VERBOSE=1 "$@" || die "Make failed!" 371 emake VERBOSE=1 "$@" || die "Make failed!"
341 else 372 else
342 emake "$@" || die "Make failed!" 373 emake "$@" || die "Make failed!"
343 fi 374 fi
344 popd &> /dev/null 375 popd > /dev/null
376}
377
378enable_cmake-utils_src_install() {
379 debug-print-function ${FUNCNAME} "$@"
380
381 _check_build_dir
382 pushd "${CMAKE_BUILD_DIR}" > /dev/null
383 base_src_install
384 popd > /dev/null
385
386 # Backward compatibility, for non-array variables
387 if [[ -n "${DOCS}" ]] && [[ "$(declare -p DOCS 2>/dev/null 2>&1)" != "declare -a"* ]]; then
388 dodoc ${DOCS} || die "dodoc failed"
389 fi
390 if [[ -n "${HTML_DOCS}" ]] && [[ "$(declare -p HTML_DOCS 2>/dev/null 2>&1)" != "declare -a"* ]]; then
391 dohtml -r ${HTML_DOCS} || die "dohtml failed"
392 fi
393}
394
395enable_cmake-utils_src_test() {
396 debug-print-function ${FUNCNAME} "$@"
397
398 _check_build_dir
399 pushd "${CMAKE_BUILD_DIR}" > /dev/null
400 local ctestargs
401 [[ -n ${TEST_VERBOSE} ]] && ctestargs="--extra-verbose --output-on-failure"
402 ctest ${ctestargs} || die "Tests failed."
403 popd > /dev/null
404}
405
406# @FUNCTION: cmake-utils_src_configure
407# @DESCRIPTION:
408# General function for configuring with cmake. Default behaviour is to start an
409# out-of-source build.
410cmake-utils_src_configure() {
411 _execute_optionaly "src_configure" "$@"
412}
413
414# @FUNCTION: cmake-utils_src_compile
415# @DESCRIPTION:
416# General function for compiling with cmake. Default behaviour is to check for
417# EAPI and respectively to configure as well or just compile.
418# Automatically detects the build type. All arguments are passed to emake.
419cmake-utils_src_compile() {
420 _execute_optionaly "src_compile" "$@"
345} 421}
346 422
347# @FUNCTION: cmake-utils_src_install 423# @FUNCTION: cmake-utils_src_install
348# @DESCRIPTION: 424# @DESCRIPTION:
349# Function for installing the package. Automatically detects the build type. 425# Function for installing the package. Automatically detects the build type.
350cmake-utils_src_install() { 426cmake-utils_src_install() {
351 debug-print-function ${FUNCNAME} "$@" 427 _execute_optionaly "src_install" "$@"
352
353 _check_build_dir
354 pushd "${CMAKE_BUILD_DIR}" &> /dev/null
355 emake install DESTDIR="${D}" || die "Make install failed"
356 popd &> /dev/null
357
358 # Manual document installation
359 [[ -n "${DOCS}" ]] && { dodoc ${DOCS} || die "dodoc failed" ; }
360 [[ -n "${HTML_DOCS}" ]] && { dohtml -r ${HTML_DOCS} || die "dohtml failed" ; }
361} 428}
362 429
363# @FUNCTION: cmake-utils_src_test 430# @FUNCTION: cmake-utils_src_test
364# @DESCRIPTION: 431# @DESCRIPTION:
365# Function for testing the package. Automatically detects the build type. 432# Function for testing the package. Automatically detects the build type.
366cmake-utils_src_test() { 433cmake-utils_src_test() {
367 debug-print-function ${FUNCNAME} "$@" 434 _execute_optionaly "src_test" "$@"
435}
368 436
369 _check_build_dir 437# Optionally executes phases based on WANT_CMAKE variable/USE flag.
370 pushd "${CMAKE_BUILD_DIR}" &> /dev/null 438_execute_optionaly() {
371 # Standard implementation of src_test 439 local phase="$1" ; shift
372 if emake -j1 check -n &> /dev/null; then 440 if [[ ${WANT_CMAKE} = always ]]; then
373 einfo ">>> Test phase [check]: ${CATEGORY}/${PF}" 441 enable_cmake-utils_${phase} "$@"
374 if ! emake -j1 check; then 442 else
375 die "Make check failed. See above for details." 443 use ${WANT_CMAKE} && enable_cmake-utils_${phase} "$@"
376 fi 444 fi
377 elif emake -j1 test -n &> /dev/null; then
378 einfo ">>> Test phase [test]: ${CATEGORY}/${PF}"
379 if ! emake -j1 test; then
380 die "Make test failed. See above for details."
381 fi
382 else
383 einfo ">>> Test phase [none]: ${CATEGORY}/${PF}"
384 fi
385 popd &> /dev/null
386} 445}

Legend:
Removed from v.1.28  
changed lines
  Added in v.1.59

  ViewVC Help
Powered by ViewVC 1.1.20