summaryrefslogtreecommitdiff
path: root/eclass/cmake-utils.eclass
diff options
context:
space:
mode:
Diffstat (limited to 'eclass/cmake-utils.eclass')
-rw-r--r--eclass/cmake-utils.eclass53
1 files changed, 41 insertions, 12 deletions
diff --git a/eclass/cmake-utils.eclass b/eclass/cmake-utils.eclass
index 98f5fa41b55a..776de76b31d4 100644
--- a/eclass/cmake-utils.eclass
+++ b/eclass/cmake-utils.eclass
@@ -9,7 +9,7 @@
# Maciej Mrozowski <reavertm@gentoo.org>
# (undisclosed contributors)
# Original author: Zephyrus (zephyrus@mirach.it)
-# @SUPPORTED_EAPIS: 5 6
+# @SUPPORTED_EAPIS: 5 6 7
# @BLURB: common ebuild functions for cmake-based packages
# @DESCRIPTION:
# The cmake-utils eclass makes creating ebuilds for cmake-based packages much easier.
@@ -50,10 +50,12 @@ _CMAKE_UTILS_ECLASS=1
# Set to enable in-source build.
# @ECLASS-VARIABLE: CMAKE_MAKEFILE_GENERATOR
+# @DEFAULT_UNSET
# @DESCRIPTION:
# Specify a makefile generator to be used by cmake.
# At this point only "emake" and "ninja" are supported.
-: ${CMAKE_MAKEFILE_GENERATOR:=emake}
+# In EAPI 7 and above, the default is set to "ninja",
+# whereas in EAPIs below 7, it is set to "emake".
# @ECLASS-VARIABLE: CMAKE_MIN_VERSION
# @DESCRIPTION:
@@ -105,27 +107,39 @@ _CMAKE_UTILS_ECLASS=1
case ${EAPI} in
5) : ${CMAKE_WARN_UNUSED_CLI:=no} ;;
- 6) : ${CMAKE_WARN_UNUSED_CLI:=yes} ;;
+ 6|7) : ${CMAKE_WARN_UNUSED_CLI:=yes} ;;
*) die "EAPI=${EAPI:-0} is not supported" ;;
esac
inherit toolchain-funcs ninja-utils flag-o-matic multiprocessing xdg-utils
case ${EAPI} in
- 5|6) inherit eutils multilib ;;
+ [56])
+ : ${CMAKE_MAKEFILE_GENERATOR:=emake}
+ inherit eutils multilib
+ ;;
+ *)
+ : ${CMAKE_MAKEFILE_GENERATOR:=ninja}
+ ;;
esac
EXPORT_FUNCTIONS src_prepare src_configure src_compile src_test src_install
-[[ ${WANT_CMAKE} ]] && eqawarn "\${WANT_CMAKE} has been removed and is a no-op now"
+if [[ ${WANT_CMAKE} ]]; then
+ if [[ ${EAPI} != [56] ]]; then
+ die "\${WANT_CMAKE} has been removed and is a no-op now"
+ else
+ eqawarn "\${WANT_CMAKE} has been removed and is a no-op now"
+ fi
+fi
[[ ${PREFIX} ]] && die "\${PREFIX} has been removed and is a no-op now"
case ${CMAKE_MAKEFILE_GENERATOR} in
emake)
- DEPEND="sys-devel/make"
+ BDEPEND="sys-devel/make"
;;
ninja)
- DEPEND="dev-util/ninja"
+ BDEPEND="dev-util/ninja"
;;
*)
eerror "Unknown value for \${CMAKE_MAKEFILE_GENERATOR}"
@@ -134,9 +148,14 @@ case ${CMAKE_MAKEFILE_GENERATOR} in
esac
if [[ ${PN} != cmake ]]; then
- DEPEND+=" >=dev-util/cmake-${CMAKE_MIN_VERSION}"
+ BDEPEND+=" >=dev-util/cmake-${CMAKE_MIN_VERSION}"
fi
+case ${EAPI} in
+ 7) ;;
+ *) DEPEND=" ${BDEPEND}" ;;
+esac
+
# Internal functions used by cmake-utils_use_*
_cmake_use_me_now() {
debug-print-function ${FUNCNAME} "$@"
@@ -195,8 +214,13 @@ _cmake_check_build_dir() {
# Respect both the old variable and the new one, depending
# on which one was set by the ebuild.
if [[ ! ${BUILD_DIR} && ${CMAKE_BUILD_DIR} ]]; then
- eqawarn "The CMAKE_BUILD_DIR variable has been renamed to BUILD_DIR."
- eqawarn "Please migrate the ebuild to use the new one."
+ if [[ ${EAPI} != [56] ]]; then
+ eerror "The CMAKE_BUILD_DIR variable has been renamed to BUILD_DIR."
+ die "The ebuild must be migrated to BUILD_DIR."
+ else
+ eqawarn "The CMAKE_BUILD_DIR variable has been renamed to BUILD_DIR."
+ eqawarn "Please migrate the ebuild to use the new one."
+ fi
# In the next call, both variables will be set already
# and we'd have to know which one takes precedence.
@@ -211,7 +235,7 @@ _cmake_check_build_dir() {
fi
# Backwards compatibility for getting the value.
- CMAKE_BUILD_DIR=${BUILD_DIR}
+ [[ ${EAPI} == [56] ]] && CMAKE_BUILD_DIR=${BUILD_DIR}
mkdir -p "${BUILD_DIR}" || die
echo ">>> Working in BUILD_DIR: \"$BUILD_DIR\""
@@ -495,7 +519,11 @@ cmake-utils_src_configure() {
debug-print-function ${FUNCNAME} "$@"
if [[ ! ${_CMAKE_UTILS_SRC_PREPARE_HAS_RUN} ]]; then
- eqawarn "cmake-utils_src_prepare has not been run, please open a bug on https://bugs.gentoo.org/"
+ if [[ ${EAPI} != [56] ]]; then
+ die "FATAL: cmake-utils_src_prepare has not been run"
+ else
+ eqawarn "cmake-utils_src_prepare has not been run, please open a bug on https://bugs.gentoo.org/"
+ fi
fi
[[ ${EAPI} == 5 ]] && _cmake_cleanup_cmake
@@ -617,6 +645,7 @@ cmake-utils_src_configure() {
if [[ ${EAPI} != [56] ]]; then
cat >> "${common_config}" <<- _EOF_ || die
SET (CMAKE_INSTALL_DOCDIR "${EPREFIX}/usr/share/doc/${PF}" CACHE PATH "")
+ SET (BUILD_SHARED_LIBS ON CACHE BOOLEAN "")
_EOF_
fi