/[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.27
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.27 2009/05/27 14:34:33 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
121 CMAKE_BUILD_DIR="${S}" 133 CMAKE_BUILD_DIR="${CMAKE_USE_DIR}"
122 else 134 else
123 CMAKE_BUILD_DIR="${WORKDIR}/${PN}_build" 135 CMAKE_BUILD_DIR="${CMAKE_USE_DIR}_build"
124 fi 136 fi
125 echo ">>> Working in BUILD_DIR: \"$CMAKE_BUILD_DIR\"" 137 echo ">>> Working in BUILD_DIR: \"$CMAKE_BUILD_DIR\""
126} 138}
127# @FUNCTION: cmake-utils_use_with 139# @FUNCTION: cmake-utils_use_with
128# @USAGE: <USE flag> [flag name] 140# @USAGE: <USE flag> [flag name]
206_modify-cmakelists() { 218_modify-cmakelists() {
207 debug-print-function ${FUNCNAME} "$@" 219 debug-print-function ${FUNCNAME} "$@"
208 220
209 # Comment out all set (<some_should_be_user_defined_variable> value) 221 # 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 222 # TODO Add QA checker - inform when variable being checked for below is set in CMakeLists.txt
211 find "${S}" -name CMakeLists.txt \ 223 find "${CMAKE_USE_DIR}" -name CMakeLists.txt \
212 -exec sed -i -e '/^[[:space:]]*[sS][eE][tT][[:space:]]*([[:space:]]*CMAKE_BUILD_TYPE.*)/{s/^/#IGNORE /g}' {} + \ 224 -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}' {} + \ 225 -exec sed -i -e '/^[[:space:]]*[sS][eE][tT][[:space:]]*([[:space:]]*CMAKE_INSTALL_PREFIX.*)/{s/^/#IGNORE /g}' {} + \
214 || die "${LINENO}: failed to disable hardcoded settings" 226 || die "${LINENO}: failed to disable hardcoded settings"
215 227
216 # NOTE Append some useful summary here 228 # NOTE Append some useful summary here
224# @DESCRIPTION: 236# @DESCRIPTION:
225# General function for configuring with cmake. Default behaviour is to start an 237# General function for configuring with cmake. Default behaviour is to start an
226# out-of-source build. 238# out-of-source build.
227cmake-utils_src_configure() { 239cmake-utils_src_configure() {
228 debug-print-function ${FUNCNAME} "$@" 240 debug-print-function ${FUNCNAME} "$@"
241
242 _check_build_dir
243
244 # check if CMakeLists.txt exist and if no then die
245 if [[ ! -e "${CMAKE_USE_DIR}"/CMakeLists.txt ]] ; then
246 eerror "I was unable to locate CMakeLists.txt under:"
247 eerror "\"${CMAKE_USE_DIR}/CMakeLists.txt\""
248 eerror "You should consider not inheriting the cmake eclass."
249 die "FATAL: Unable to find CMakeLists.txt"
250 fi
229 251
230 # Remove dangerous things. 252 # Remove dangerous things.
231 _modify-cmakelists 253 _modify-cmakelists
232 254
233 # @SEE CMAKE_BUILD_TYPE 255 # @SEE CMAKE_BUILD_TYPE
264SET (LIB_SUFFIX ${libdir/lib} CACHE STRING "library path suffix" FORCE) 286SET (LIB_SUFFIX ${libdir/lib} CACHE STRING "library path suffix" FORCE)
265_EOF_ 287_EOF_
266 [[ -n ${CMAKE_NO_COLOR} ]] && echo 'SET (CMAKE_COLOR_MAKEFILE OFF CACHE BOOL "pretty colors during make" FORCE)' >> ${common_config} 288 [[ -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}" 289 cmakeargs="-C ${common_config} ${cmakeargs}"
268 290
269 _check_build_dir
270 mkdir -p "${CMAKE_BUILD_DIR}" 291 mkdir -p "${CMAKE_BUILD_DIR}"
271 pushd "${CMAKE_BUILD_DIR}" > /dev/null 292 pushd "${CMAKE_BUILD_DIR}" > /dev/null
272 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: mycmakeargs is $cmakeargs" 293 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: mycmakeargs is $cmakeargs"
273 cmake ${cmakeargs} "${S}" || die "cmake failed" 294 cmake ${cmakeargs} "${CMAKE_USE_DIR}" || die "cmake failed"
274 295
275 popd > /dev/null 296 popd > /dev/null
276} 297}
277 298
278# @FUNCTION: cmake-utils_src_compile 299# @FUNCTION: cmake-utils_src_compile
309cmake-utils_src_make() { 330cmake-utils_src_make() {
310 debug-print-function ${FUNCNAME} "$@" 331 debug-print-function ${FUNCNAME} "$@"
311 332
312 _check_build_dir 333 _check_build_dir
313 pushd "${CMAKE_BUILD_DIR}" > /dev/null 334 pushd "${CMAKE_BUILD_DIR}" > /dev/null
335 # first check if Makefile exist otherwise die
336 [[ -e Makefile ]] || die "Makefile not found. Error during configure stage."
314 if [[ -n ${CMAKE_VERBOSE} ]]; then 337 if [[ -n ${CMAKE_VERBOSE} ]]; then
315 emake VERBOSE=1 "$@" || die "Make failed!" 338 emake VERBOSE=1 "$@" || die "Make failed!"
316 else 339 else
317 emake "$@" || die "Make failed!" 340 emake "$@" || die "Make failed!"
318 fi 341 fi

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

  ViewVC Help
Powered by ViewVC 1.1.20