/[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.25 Revision 1.29
1# Copyright 1999-2009 Gentoo Foundation 1# Copyright 1999-2009 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.25 2009/04/11 19:44:43 scarabeus Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/cmake-utils.eclass,v 1.29 2009/06/17 22:39:01 scarabeus 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#
22 22
23inherit toolchain-funcs multilib flag-o-matic base 23inherit toolchain-funcs multilib flag-o-matic base
24 24
25EXPF="src_compile src_test src_install" 25EXPF="src_compile src_test src_install"
26case ${EAPI:-0} in 26case ${EAPI:-0} in
27 2) EXPF="${EXPF} src_configure" 27 2) EXPF="${EXPF} src_configure" ;;
28 ;;
29 1|0) ;; 28 1|0) ;;
30 *) die "Unknown EAPI, Bug eclass maintainers." ;; 29 *) die "Unknown EAPI, Bug eclass maintainers." ;;
31esac 30esac
32EXPORT_FUNCTIONS ${EXPF} 31EXPORT_FUNCTIONS ${EXPF}
33 32
114 113
115# @FUNCTION: _check_build_dir 114# @FUNCTION: _check_build_dir
116# @DESCRIPTION: 115# @DESCRIPTION:
117# Determine using IN or OUT source build 116# Determine using IN or OUT source build
118_check_build_dir() { 117_check_build_dir() {
119 # in/out source build 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}}
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}"
120 if [[ -n "${CMAKE_IN_SOURCE_BUILD}" ]]; then 132 if [[ -n "${CMAKE_IN_SOURCE_BUILD}" ]]; then
133 # we build in source dir
121 CMAKE_BUILD_DIR="${S}" 134 CMAKE_BUILD_DIR="${CMAKE_USE_DIR}"
122 else 135 elif [[ ${CMAKE_USE_DIR} = ${WORKDIR} ]]; then
136 # out of tree build, but with $S=$WORKDIR, see bug #273949 for reason.
123 CMAKE_BUILD_DIR="${WORKDIR}/${PN}_build" 137 CMAKE_BUILD_DIR="${CMAKE_USE_DIR}/build"
138 else
139 # regular out of tree build
140 [[ ${1} = init || -d ${CMAKE_USE_DIR}_build ]] && SUF="_build" || SUF=""
141 CMAKE_BUILD_DIR="${CMAKE_USE_DIR}${SUF}"
142
124 fi 143 fi
125 echo ">>> Working in BUILD_DIR: \"$CMAKE_BUILD_DIR\"" 144 echo ">>> Working in BUILD_DIR: \"$CMAKE_BUILD_DIR\""
126} 145}
127# @FUNCTION: cmake-utils_use_with 146# @FUNCTION: cmake-utils_use_with
128# @USAGE: <USE flag> [flag name] 147# @USAGE: <USE flag> [flag name]
206_modify-cmakelists() { 225_modify-cmakelists() {
207 debug-print-function ${FUNCNAME} "$@" 226 debug-print-function ${FUNCNAME} "$@"
208 227
209 # Comment out all set (<some_should_be_user_defined_variable> value) 228 # Comment out all set (<some_should_be_user_defined_variable> value)
210 # TODO Add QA checker - inform when variable being checked for below is set in CMakeLists.txt 229 # TODO Add QA checker - inform when variable being checked for below is set in CMakeLists.txt
211 find "${S}" -name CMakeLists.txt \ 230 find "${CMAKE_USE_DIR}" -name CMakeLists.txt \
212 -exec sed -i -e '/^[[:space:]]*[sS][eE][tT][[:space:]]*([[:space:]]*CMAKE_BUILD_TYPE.*)/{s/^/#IGNORE /g}' {} + \ 231 -exec sed -i -e '/^[[:space:]]*[sS][eE][tT][[:space:]]*([[:space:]]*CMAKE_BUILD_TYPE.*)/{s/^/#IGNORE /g}' {} + \
213 -exec sed -i -e '/^[[:space:]]*[sS][eE][tT][[:space:]]*([[:space:]]*CMAKE_INSTALL_PREFIX.*)/{s/^/#IGNORE /g}' {} + \ 232 -exec sed -i -e '/^[[:space:]]*[sS][eE][tT][[:space:]]*([[:space:]]*CMAKE_INSTALL_PREFIX.*)/{s/^/#IGNORE /g}' {} + \
214 || die "${LINENO}: failed to disable hardcoded settings" 233 || die "${LINENO}: failed to disable hardcoded settings"
215 234
216 # NOTE Append some useful summary here 235 # NOTE Append some useful summary here
225# General function for configuring with cmake. Default behaviour is to start an 244# General function for configuring with cmake. Default behaviour is to start an
226# out-of-source build. 245# out-of-source build.
227cmake-utils_src_configure() { 246cmake-utils_src_configure() {
228 debug-print-function ${FUNCNAME} "$@" 247 debug-print-function ${FUNCNAME} "$@"
229 248
249 _check_build_dir init
250
230 # check if CMakeLists.txt exist and if no then die 251 # check if CMakeLists.txt exist and if no then die
231 if [[ ! -e "${S}"/CMakeLists.txt ]] ; then 252 if [[ ! -e "${CMAKE_USE_DIR}"/CMakeLists.txt ]] ; then
232 eerror "I was unable to locate CMakeLists.txt under:" 253 eerror "I was unable to locate CMakeLists.txt under:"
233 eerror "\"${S}/CMakeLists.txt\"" 254 eerror "\"${CMAKE_USE_DIR}/CMakeLists.txt\""
234 eerror "You should consider not inheriting the cmake eclass." 255 eerror "You should consider not inheriting the cmake eclass."
235 die "FATAL: Unable to find CMakeLists.txt" 256 die "FATAL: Unable to find CMakeLists.txt"
236 fi 257 fi
237 258
238 # Remove dangerous things. 259 # Remove dangerous things.
272SET (LIB_SUFFIX ${libdir/lib} CACHE STRING "library path suffix" FORCE) 293SET (LIB_SUFFIX ${libdir/lib} CACHE STRING "library path suffix" FORCE)
273_EOF_ 294_EOF_
274 [[ -n ${CMAKE_NO_COLOR} ]] && echo 'SET (CMAKE_COLOR_MAKEFILE OFF CACHE BOOL "pretty colors during make" FORCE)' >> ${common_config} 295 [[ -n ${CMAKE_NO_COLOR} ]] && echo 'SET (CMAKE_COLOR_MAKEFILE OFF CACHE BOOL "pretty colors during make" FORCE)' >> ${common_config}
275 cmakeargs="-C ${common_config} ${cmakeargs}" 296 cmakeargs="-C ${common_config} ${cmakeargs}"
276 297
277 _check_build_dir
278 mkdir -p "${CMAKE_BUILD_DIR}" 298 mkdir -p "${CMAKE_BUILD_DIR}"
279 pushd "${CMAKE_BUILD_DIR}" > /dev/null 299 pushd "${CMAKE_BUILD_DIR}" > /dev/null
280 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: mycmakeargs is $cmakeargs" 300 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: mycmakeargs is $cmakeargs"
281 cmake ${cmakeargs} "${S}" || die "cmake failed" 301 cmake ${cmakeargs} "${CMAKE_USE_DIR}" || die "cmake failed"
282 302
283 popd > /dev/null 303 popd > /dev/null
284} 304}
285 305
286# @FUNCTION: cmake-utils_src_compile 306# @FUNCTION: cmake-utils_src_compile
316# All arguments are passed to emake: 336# All arguments are passed to emake:
317cmake-utils_src_make() { 337cmake-utils_src_make() {
318 debug-print-function ${FUNCNAME} "$@" 338 debug-print-function ${FUNCNAME} "$@"
319 339
320 _check_build_dir 340 _check_build_dir
321 pushd "${CMAKE_BUILD_DIR}" > /dev/null 341 pushd "${CMAKE_BUILD_DIR}" &> /dev/null
322 # first check if Makefile exist otherwise die 342 # first check if Makefile exist otherwise die
323 [[ -e Makefile ]] || die "Makefile not found. Error during configure stage." 343 [[ -e Makefile ]] || die "Makefile not found. Error during configure stage."
324 if [[ -n ${CMAKE_VERBOSE} ]]; then 344 if [[ -n ${CMAKE_VERBOSE} ]]; then
325 emake VERBOSE=1 "$@" || die "Make failed!" 345 emake VERBOSE=1 "$@" || die "Make failed!"
326 else 346 else
327 emake "$@" || die "Make failed!" 347 emake "$@" || die "Make failed!"
328 fi 348 fi
329 popd > /dev/null 349 popd &> /dev/null
330} 350}
331 351
332# @FUNCTION: cmake-utils_src_install 352# @FUNCTION: cmake-utils_src_install
333# @DESCRIPTION: 353# @DESCRIPTION:
334# Function for installing the package. Automatically detects the build type. 354# Function for installing the package. Automatically detects the build type.
335cmake-utils_src_install() { 355cmake-utils_src_install() {
336 debug-print-function ${FUNCNAME} "$@" 356 debug-print-function ${FUNCNAME} "$@"
337 357
338 _check_build_dir 358 _check_build_dir
339 pushd "${CMAKE_BUILD_DIR}" > /dev/null 359 pushd "${CMAKE_BUILD_DIR}" &> /dev/null
340 emake install DESTDIR="${D}" || die "Make install failed" 360 emake install DESTDIR="${D}" || die "Make install failed"
341 popd > /dev/null 361 popd &> /dev/null
342 362
343 # Manual document installation 363 # Manual document installation
344 [[ -n "${DOCS}" ]] && { dodoc ${DOCS} || die "dodoc failed" ; } 364 [[ -n "${DOCS}" ]] && { dodoc ${DOCS} || die "dodoc failed" ; }
345 [[ -n "${HTML_DOCS}" ]] && { dohtml -r ${HTML_DOCS} || die "dohtml failed" ; } 365 [[ -n "${HTML_DOCS}" ]] && { dohtml -r ${HTML_DOCS} || die "dohtml failed" ; }
346} 366}
350# Function for testing the package. Automatically detects the build type. 370# Function for testing the package. Automatically detects the build type.
351cmake-utils_src_test() { 371cmake-utils_src_test() {
352 debug-print-function ${FUNCNAME} "$@" 372 debug-print-function ${FUNCNAME} "$@"
353 373
354 _check_build_dir 374 _check_build_dir
355 pushd "${CMAKE_BUILD_DIR}" > /dev/null 375 pushd "${CMAKE_BUILD_DIR}" &> /dev/null
356 # Standard implementation of src_test 376 # Standard implementation of src_test
357 if emake -j1 check -n &> /dev/null; then 377 if emake -j1 check -n &> /dev/null; then
358 einfo ">>> Test phase [check]: ${CATEGORY}/${PF}" 378 einfo ">>> Test phase [check]: ${CATEGORY}/${PF}"
359 if ! emake -j1 check; then 379 if ! emake -j1 check; then
360 die "Make check failed. See above for details." 380 die "Make check failed. See above for details."
365 die "Make test failed. See above for details." 385 die "Make test failed. See above for details."
366 fi 386 fi
367 else 387 else
368 einfo ">>> Test phase [none]: ${CATEGORY}/${PF}" 388 einfo ">>> Test phase [none]: ${CATEGORY}/${PF}"
369 fi 389 fi
370 popd > /dev/null 390 popd &> /dev/null
371} 391}

Legend:
Removed from v.1.25  
changed lines
  Added in v.1.29

  ViewVC Help
Powered by ViewVC 1.1.20