| 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.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 | |
| 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() { |
| 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 |
| … | |
… | |
| 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. |
| 227 | cmake-utils_src_configure() { |
239 | cmake-utils_src_configure() { |
| 228 | debug-print-function ${FUNCNAME} "$@" |
240 | debug-print-function ${FUNCNAME} "$@" |
| 229 | |
241 | |
|
|
242 | _check_build_dir |
|
|
243 | |
| 230 | # check if CMakeLists.txt exist and if no then die |
244 | # check if CMakeLists.txt exist and if no then die |
| 231 | if [[ ! -e "${S}"/CMakeLists.txt ]] ; then |
245 | if [[ ! -e "${CMAKE_USE_DIR}"/CMakeLists.txt ]] ; then |
| 232 | eerror "I was unable to locate CMakeLists.txt under:" |
246 | eerror "I was unable to locate CMakeLists.txt under:" |
| 233 | eerror "\"${S}/CMakeLists.txt\"" |
247 | eerror "\"${CMAKE_USE_DIR}/CMakeLists.txt\"" |
| 234 | eerror "You should consider not inheriting the cmake eclass." |
248 | eerror "You should consider not inheriting the cmake eclass." |
| 235 | die "FATAL: Unable to find CMakeLists.txt" |
249 | die "FATAL: Unable to find CMakeLists.txt" |
| 236 | fi |
250 | fi |
| 237 | |
251 | |
| 238 | # Remove dangerous things. |
252 | # Remove dangerous things. |
| … | |
… | |
| 272 | SET (LIB_SUFFIX ${libdir/lib} CACHE STRING "library path suffix" FORCE) |
286 | SET (LIB_SUFFIX ${libdir/lib} CACHE STRING "library path suffix" FORCE) |
| 273 | _EOF_ |
287 | _EOF_ |
| 274 | [[ -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} |
| 275 | cmakeargs="-C ${common_config} ${cmakeargs}" |
289 | cmakeargs="-C ${common_config} ${cmakeargs}" |
| 276 | |
290 | |
| 277 | _check_build_dir |
|
|
| 278 | mkdir -p "${CMAKE_BUILD_DIR}" |
291 | mkdir -p "${CMAKE_BUILD_DIR}" |
| 279 | pushd "${CMAKE_BUILD_DIR}" > /dev/null |
292 | pushd "${CMAKE_BUILD_DIR}" > /dev/null |
| 280 | debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: mycmakeargs is $cmakeargs" |
293 | debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: mycmakeargs is $cmakeargs" |
| 281 | cmake ${cmakeargs} "${S}" || die "cmake failed" |
294 | cmake ${cmakeargs} "${CMAKE_USE_DIR}" || die "cmake failed" |
| 282 | |
295 | |
| 283 | popd > /dev/null |
296 | popd > /dev/null |
| 284 | } |
297 | } |
| 285 | |
298 | |
| 286 | # @FUNCTION: cmake-utils_src_compile |
299 | # @FUNCTION: cmake-utils_src_compile |