/[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.23 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.23 2009/04/04 12:28:10 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
224# @DESCRIPTION: 243# @DESCRIPTION:
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} "$@"
248
249 _check_build_dir init
250
251 # check if CMakeLists.txt exist and if no then die
252 if [[ ! -e "${CMAKE_USE_DIR}"/CMakeLists.txt ]] ; then
253 eerror "I was unable to locate CMakeLists.txt under:"
254 eerror "\"${CMAKE_USE_DIR}/CMakeLists.txt\""
255 eerror "You should consider not inheriting the cmake eclass."
256 die "FATAL: Unable to find CMakeLists.txt"
257 fi
229 258
230 # Remove dangerous things. 259 # Remove dangerous things.
231 _modify-cmakelists 260 _modify-cmakelists
232 261
233 # @SEE CMAKE_BUILD_TYPE 262 # @SEE CMAKE_BUILD_TYPE
264SET (LIB_SUFFIX ${libdir/lib} CACHE STRING "library path suffix" FORCE) 293SET (LIB_SUFFIX ${libdir/lib} CACHE STRING "library path suffix" FORCE)
265_EOF_ 294_EOF_
266 [[ -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}
267 cmakeargs="-C ${common_config} ${cmakeargs}" 296 cmakeargs="-C ${common_config} ${cmakeargs}"
268 297
269 _check_build_dir
270 mkdir -p "${CMAKE_BUILD_DIR}" 298 mkdir -p "${CMAKE_BUILD_DIR}"
271 pushd "${CMAKE_BUILD_DIR}" > /dev/null 299 pushd "${CMAKE_BUILD_DIR}" > /dev/null
272 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: mycmakeargs is $cmakeargs" 300 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: mycmakeargs is $cmakeargs"
273 cmake ${cmakeargs} "${S}" || die "cmake failed" 301 cmake ${cmakeargs} "${CMAKE_USE_DIR}" || die "cmake failed"
274 302
275 popd > /dev/null 303 popd > /dev/null
276} 304}
277 305
278# @FUNCTION: cmake-utils_src_compile 306# @FUNCTION: cmake-utils_src_compile
308# All arguments are passed to emake: 336# All arguments are passed to emake:
309cmake-utils_src_make() { 337cmake-utils_src_make() {
310 debug-print-function ${FUNCNAME} "$@" 338 debug-print-function ${FUNCNAME} "$@"
311 339
312 _check_build_dir 340 _check_build_dir
313 pushd "${CMAKE_BUILD_DIR}" > /dev/null 341 pushd "${CMAKE_BUILD_DIR}" &> /dev/null
342 # first check if Makefile exist otherwise die
343 [[ -e Makefile ]] || die "Makefile not found. Error during configure stage."
314 if [[ -n ${CMAKE_VERBOSE} ]]; then 344 if [[ -n ${CMAKE_VERBOSE} ]]; then
315 emake VERBOSE=1 "$@" || die "Make failed!" 345 emake VERBOSE=1 "$@" || die "Make failed!"
316 else 346 else
317 emake "$@" || die "Make failed!" 347 emake "$@" || die "Make failed!"
318 fi 348 fi
319 popd > /dev/null 349 popd &> /dev/null
320} 350}
321 351
322# @FUNCTION: cmake-utils_src_install 352# @FUNCTION: cmake-utils_src_install
323# @DESCRIPTION: 353# @DESCRIPTION:
324# Function for installing the package. Automatically detects the build type. 354# Function for installing the package. Automatically detects the build type.
325cmake-utils_src_install() { 355cmake-utils_src_install() {
326 debug-print-function ${FUNCNAME} "$@" 356 debug-print-function ${FUNCNAME} "$@"
327 357
328 _check_build_dir 358 _check_build_dir
329 pushd "${CMAKE_BUILD_DIR}" > /dev/null 359 pushd "${CMAKE_BUILD_DIR}" &> /dev/null
330 emake install DESTDIR="${D}" || die "Make install failed" 360 emake install DESTDIR="${D}" || die "Make install failed"
331 popd > /dev/null 361 popd &> /dev/null
332 362
333 # Manual document installation 363 # Manual document installation
334 [[ -n "${DOCS}" ]] && { dodoc ${DOCS} || die "dodoc failed" ; } 364 [[ -n "${DOCS}" ]] && { dodoc ${DOCS} || die "dodoc failed" ; }
335 [[ -n "${HTML_DOCS}" ]] && { dohtml -r ${HTML_DOCS} || die "dohtml failed" ; } 365 [[ -n "${HTML_DOCS}" ]] && { dohtml -r ${HTML_DOCS} || die "dohtml failed" ; }
336} 366}
340# Function for testing the package. Automatically detects the build type. 370# Function for testing the package. Automatically detects the build type.
341cmake-utils_src_test() { 371cmake-utils_src_test() {
342 debug-print-function ${FUNCNAME} "$@" 372 debug-print-function ${FUNCNAME} "$@"
343 373
344 _check_build_dir 374 _check_build_dir
345 pushd "${CMAKE_BUILD_DIR}" > /dev/null 375 pushd "${CMAKE_BUILD_DIR}" &> /dev/null
346 # Standard implementation of src_test 376 # Standard implementation of src_test
347 if emake -j1 check -n &> /dev/null; then 377 if emake -j1 check -n &> /dev/null; then
348 einfo ">>> Test phase [check]: ${CATEGORY}/${PF}" 378 einfo ">>> Test phase [check]: ${CATEGORY}/${PF}"
349 if ! emake -j1 check; then 379 if ! emake -j1 check; then
350 die "Make check failed. See above for details." 380 die "Make check failed. See above for details."
355 die "Make test failed. See above for details." 385 die "Make test failed. See above for details."
356 fi 386 fi
357 else 387 else
358 einfo ">>> Test phase [none]: ${CATEGORY}/${PF}" 388 einfo ">>> Test phase [none]: ${CATEGORY}/${PF}"
359 fi 389 fi
360 popd > /dev/null 390 popd &> /dev/null
361} 391}

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

  ViewVC Help
Powered by ViewVC 1.1.20