/[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.14 Revision 1.15
1# Copyright 1999-2007 Gentoo Foundation 1# Copyright 1999-2007 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.14 2008/10/28 17:39:28 scarabeus Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/cmake-utils.eclass,v 1.15 2008/11/05 20:59:37 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# @BLURB: common ebuild functions for cmake-based packages 8# @BLURB: common ebuild functions for cmake-based packages
83# General function for configuring with cmake. Default behaviour is to start an 83# General function for configuring with cmake. Default behaviour is to start an
84# out-of-source build. 84# out-of-source build.
85cmake-utils_src_configure() { 85cmake-utils_src_configure() {
86 debug-print-function $FUNCNAME $* 86 debug-print-function $FUNCNAME $*
87 87
88 if ! has debug ${IUSE//+} || ! use debug ; then
89 append-cppflags -DNDEBUG
90 fi
91
92 if [[ -n "${CMAKE_IN_SOURCE_BUILD}" ]]; then 88 if [[ -n "${CMAKE_IN_SOURCE_BUILD}" ]]; then
93 cmake-utils_src_configurein 89 cmake-utils_src_configurein
94 else 90 else
95 cmake-utils_src_configureout 91 cmake-utils_src_configureout
96 fi 92 fi
117# Function for software that requires configure and building in the source 113# Function for software that requires configure and building in the source
118# directory. 114# directory.
119cmake-utils_src_configurein() { 115cmake-utils_src_configurein() {
120 debug-print-function $FUNCNAME $* 116 debug-print-function $FUNCNAME $*
121 117
118 _common_configure_code
122 local cmakeargs="$(_common_configure_code) ${mycmakeargs} ${EXTRA_ECONF}" 119 local cmakeargs="${mycmakeargs} ${EXTRA_ECONF}"
123 120
124 debug-print "$LINENO $ECLASS $FUNCNAME: mycmakeargs is $cmakeargs" 121 debug-print "$LINENO $ECLASS $FUNCNAME: mycmakeargs is $cmakeargs"
125 cmake ${cmakeargs} . || die "Cmake failed" 122 cmake -C "${TMPDIR}/gentoo_common_config.cmake" ${cmakeargs} . || die "Cmake failed"
126} 123}
127 124
128# @FUNCTION: cmake-utils_src_configureout 125# @FUNCTION: cmake-utils_src_configureout
129# @DESCRIPTION: 126# @DESCRIPTION:
130# Function for software that requires configure and building outside the source 127# Function for software that requires configure and building outside the source
131# tree - default. 128# tree - default.
132cmake-utils_src_configureout() { 129cmake-utils_src_configureout() {
133 debug-print-function $FUNCNAME $* 130 debug-print-function $FUNCNAME $*
134 131
132 _common_configure_code
135 local cmakeargs="$(_common_configure_code) ${mycmakeargs} ${EXTRA_ECONF}" 133 local cmakeargs="${mycmakeargs} ${EXTRA_ECONF}"
136 mkdir -p "${WORKDIR}"/${PN}_build 134 mkdir -p "${WORKDIR}"/${PN}_build
137 pushd "${WORKDIR}"/${PN}_build > /dev/null 135 pushd "${WORKDIR}"/${PN}_build > /dev/null
138 136
139 debug-print "$LINENO $ECLASS $FUNCNAME: mycmakeargs is $cmakeargs" 137 debug-print "$LINENO $ECLASS $FUNCNAME: mycmakeargs is $cmakeargs"
140 cmake ${cmakeargs} "${S}" || die "Cmake failed" 138 cmake -C "${TMPDIR}/gentoo_common_config.cmake" ${cmakeargs} "${S}" || die "Cmake failed"
141 139
142 popd > /dev/null 140 popd > /dev/null
143} 141}
144 142
145# Internal use only. Common configuration options for all types of builds. 143# Internal use only. Common configuration options for all types of builds.
146_common_configure_code() { 144_common_configure_code() {
147 local tmp_libdir=$(get_libdir) 145 local tmp_libdir=$(get_libdir)
148 # CMAKE_BUILD_TYPE only modifies compiler flags, so set to None 146 # here we set the compiler explicitly, set install directories prefixes, and
149 echo -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-None} 147 # make sure that the gentoo user compiler flags trump those set in the
150 echo -DCMAKE_C_COMPILER=$(type -P $(tc-getCC)) 148 # program
151 echo -DCMAKE_CXX_COMPILER=$(type -P $(tc-getCXX)) 149 local modules_dir=/usr/share/cmake/Modules
152 echo -DCMAKE_INSTALL_PREFIX=${PREFIX:-/usr} 150 local cxx_create_shared_library=$(sed -n -e 's/)/ CACHE STRING "")/' -e "s/<TARGET_SONAME>/<TARGET_SONAME> ${CXXFLAGS}/" -e '/SET(CMAKE_CXX_CREATE_SHARED_LIBRARY/,/)/p' "${modules_dir}/CMakeCXXInformation.cmake")
153 echo -DLIB_SUFFIX=${tmp_libdir/lib} 151 local c_create_shared_library=$(sed -n -e 's/)/ CACHE STRING "")/' -e "s/<TARGET_SONAME>/<TARGET_SONAME> ${CFLAGS}/" -e '/SET(CMAKE_C_CREATE_SHARED_LIBRARY/,/)/p' "${modules_dir}/CMakeCInformation.cmake")
154 echo -DLIB_INSTALL_DIR=${PREFIX:-/usr}/${tmp_libdir} 152 local c_compile_object=$(sed -n -e 's/)/ CACHE STRING "")/' -e "s/<FLAGS>/<FLAGS> ${CFLAGS}/" -e '/SET(CMAKE_C_COMPILE_OBJECT/,/)/p' "${modules_dir}/CMakeCInformation.cmake")
155 [[ -n ${CMAKE_NO_COLOR} ]] && echo -DCMAKE_COLOR_MAKEFILE=OFF 153 local cxx_compile_object=$(sed -n -e 's/)/ CACHE STRING "")/' -e "s/<FLAGS>/<FLAGS> ${CXXFLAGS}/" -e '/SET(CMAKE_CXX_COMPILE_OBJECT/,/)/p' "${modules_dir}/CMakeCXXInformation.cmake")
154 local c_link_executable=$(sed -n -e 's/)/ CACHE STRING "")/' -e "s/<FLAGS>/<FLAGS> ${CFLAGS}/" -e "s/<LINK_FLAGS>/<LINK_FLAGS> ${LDFLAGS}/" -e '/SET(CMAKE_C_LINK_EXECUTABLE/,/)/p' "${modules_dir}/CMakeCInformation.cmake")
155 local cxx_link_executable=$(sed -n -e 's/)/ CACHE STRING "")/' -e "s/<FLAGS>/<FLAGS> ${CXXFLAGS}/" -e "s/<LINK_FLAGS>/<LINK_FLAGS> ${LDFLAGS}/" -e '/SET(CMAKE_CXX_LINK_EXECUTABLE/,/)/p' "${modules_dir}/CMakeCXXInformation.cmake")
156 cat > "${TMPDIR}/gentoo_common_config.cmake" <<_EOF_
157SET(CMAKE_C_COMPILER $(type -P $(tc-getCC)) CACHE STRING "package building C compiler")
158SET(CMAKE_CXX_COMPILER $(type -P $(tc-getCXX)) CACHE STRING "package building C++ compiler")
159${c_create_shared_library}
160${cxx_create_shared_library}
161${c_compile_object}
162${cxx_compile_object}
163${c_link_executable}
164${cxx_link_executable}
165SET(CMAKE_INSTALL_PREFIX ${PREFIX:-/usr} CACHE FILEPATH "install path prefix")
166SET(LIB_SUFFIX ${tmp_libdir/lib} CACHE FILEPATH "library path suffix")
167SET(LIB_INSTALL_DIR ${PREFIX:-/usr}/${tmp_libdir} CACHE FILEPATH "library install directory")
168
169_EOF_
170
171 [[ -n ${CMAKE_NO_COLOR} ]] && echo 'SET(CMAKE_COLOR_MAKEFILE OFF CACHE BOOL "pretty colors during make")' >> "${TMPDIR}/gentoo_common_config.cmake"
172
173 if has debug ${IUSE//+} && use debug ; then
174 echo 'SET(CMAKE_BUILD_TYPE Debug CACHE STRING "determines build settings")' >> "${TMPDIR}/gentoo_common_config.cmake"
175 else
176 echo 'SET(CMAKE_BUILD_TYPE Release CACHE STRING "determines build settings")' >> "${TMPDIR}/gentoo_common_config.cmake"
177 fi
156} 178}
157 179
158# @FUNCTION: cmake-utils_src_make 180# @FUNCTION: cmake-utils_src_make
159# @DESCRIPTION: 181# @DESCRIPTION:
160# Function for building the package. Automatically detects the build type. 182# Function for building the package. Automatically detects the build type.

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.15

  ViewVC Help
Powered by ViewVC 1.1.20