| 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.26 2009/05/08 10:54:02 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 | |
| 23 | inherit toolchain-funcs multilib flag-o-matic base |
23 | inherit toolchain-funcs multilib flag-o-matic base |
| 24 | |
24 | |
| 25 | EXPF="src_compile src_test src_install" |
25 | EXPF="src_compile src_test src_install" |
| 26 | case ${EAPI:-0} in |
26 | case ${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." ;; |
| 31 | esac |
30 | esac |
| 32 | EXPORT_FUNCTIONS ${EXPF} |
31 | EXPORT_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() { |
|
|
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 | |
| 119 | # in/out source build |
126 | # in/out source build |
| 120 | if [[ -n "${CMAKE_IN_SOURCE_BUILD}" ]]; then |
127 | if [[ -n "${CMAKE_IN_SOURCE_BUILD}" ]]; then |
| 121 | CMAKE_BUILD_DIR="${S}" |
128 | CMAKE_BUILD_DIR="${CMAKE_USE_DIR}" |
| 122 | else |
129 | else |
| 123 | CMAKE_BUILD_DIR="${WORKDIR}/${PN}_build" |
130 | CMAKE_BUILD_DIR="${CMAKE_USE_DIR}_build" |
| 124 | fi |
131 | fi |
| 125 | echo ">>> Working in BUILD_DIR: \"$CMAKE_BUILD_DIR\"" |
132 | echo ">>> Working in BUILD_DIR: \"$CMAKE_BUILD_DIR\"" |
| 126 | } |
133 | } |
| 127 | # @FUNCTION: cmake-utils_use_with |
134 | # @FUNCTION: cmake-utils_use_with |
| 128 | # @USAGE: <USE flag> [flag name] |
135 | # @USAGE: <USE flag> [flag name] |
| … | |
… | |
| 206 | _modify-cmakelists() { |
213 | _modify-cmakelists() { |
| 207 | debug-print-function ${FUNCNAME} "$@" |
214 | debug-print-function ${FUNCNAME} "$@" |
| 208 | |
215 | |
| 209 | # Comment out all set (<some_should_be_user_defined_variable> value) |
216 | # 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 |
217 | # TODO Add QA checker - inform when variable being checked for below is set in CMakeLists.txt |
| 211 | find "${S}" -name CMakeLists.txt \ |
218 | find "${CMAKE_USE_DIR}" -name CMakeLists.txt \ |
| 212 | -exec sed -i -e '/^[[:space:]]*[sS][eE][tT][[:space:]]*([[:space:]]*CMAKE_BUILD_TYPE.*)/{s/^/#IGNORE /g}' {} + \ |
219 | -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}' {} + \ |
220 | -exec sed -i -e '/^[[:space:]]*[sS][eE][tT][[:space:]]*([[:space:]]*CMAKE_INSTALL_PREFIX.*)/{s/^/#IGNORE /g}' {} + \ |
| 214 | || die "${LINENO}: failed to disable hardcoded settings" |
221 | || die "${LINENO}: failed to disable hardcoded settings" |
| 215 | |
222 | |
| 216 | # NOTE Append some useful summary here |
223 | # NOTE Append some useful summary here |
| … | |
… | |
| 225 | # General function for configuring with cmake. Default behaviour is to start an |
232 | # General function for configuring with cmake. Default behaviour is to start an |
| 226 | # out-of-source build. |
233 | # out-of-source build. |
| 227 | cmake-utils_src_configure() { |
234 | cmake-utils_src_configure() { |
| 228 | debug-print-function ${FUNCNAME} "$@" |
235 | debug-print-function ${FUNCNAME} "$@" |
| 229 | |
236 | |
|
|
237 | _check_build_dir |
|
|
238 | |
| 230 | # check if CMakeLists.txt exist and if no then die |
239 | # check if CMakeLists.txt exist and if no then die |
| 231 | if [[ ! -e "${S}"/CMakeLists.txt ]] ; then |
240 | if [[ ! -e "${CMAKE_USE_DIR}"/CMakeLists.txt ]] ; then |
| 232 | eerror "I was unable to locate CMakeLists.txt under:" |
241 | eerror "I was unable to locate CMakeLists.txt under:" |
| 233 | eerror "\"${S}/CMakeLists.txt\"" |
242 | eerror "\"${CMAKE_USE_DIR}/CMakeLists.txt\"" |
| 234 | eerror "You should consider not inheriting the cmake eclass." |
243 | eerror "You should consider not inheriting the cmake eclass." |
| 235 | die "FATAL: Unable to find CMakeLists.txt" |
244 | die "FATAL: Unable to find CMakeLists.txt" |
| 236 | fi |
245 | fi |
| 237 | |
246 | |
| 238 | # Remove dangerous things. |
247 | # Remove dangerous things. |
| … | |
… | |
| 272 | SET (LIB_SUFFIX ${libdir/lib} CACHE STRING "library path suffix" FORCE) |
281 | SET (LIB_SUFFIX ${libdir/lib} CACHE STRING "library path suffix" FORCE) |
| 273 | _EOF_ |
282 | _EOF_ |
| 274 | [[ -n ${CMAKE_NO_COLOR} ]] && echo 'SET (CMAKE_COLOR_MAKEFILE OFF CACHE BOOL "pretty colors during make" FORCE)' >> ${common_config} |
283 | [[ -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}" |
284 | cmakeargs="-C ${common_config} ${cmakeargs}" |
| 276 | |
285 | |
| 277 | _check_build_dir |
|
|
| 278 | mkdir -p "${CMAKE_BUILD_DIR}" |
286 | mkdir -p "${CMAKE_BUILD_DIR}" |
| 279 | pushd "${CMAKE_BUILD_DIR}" > /dev/null |
287 | pushd "${CMAKE_BUILD_DIR}" > /dev/null |
| 280 | debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: mycmakeargs is $cmakeargs" |
288 | debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: mycmakeargs is $cmakeargs" |
| 281 | cmake ${cmakeargs} "${S}" || die "cmake failed" |
289 | cmake ${cmakeargs} "${CMAKE_USE_DIR}" || die "cmake failed" |
| 282 | |
290 | |
| 283 | popd > /dev/null |
291 | popd > /dev/null |
| 284 | } |
292 | } |
| 285 | |
293 | |
| 286 | # @FUNCTION: cmake-utils_src_compile |
294 | # @FUNCTION: cmake-utils_src_compile |