-# Copyright 1999-2018 Gentoo Foundation
+# Copyright 1999-2019 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: cmake-utils.eclass
# 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:
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
# 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.
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\""
_cmake_use_me_now_inverted CMAKE_DISABLE_FIND_PACKAGE_ "$@" ;
}
+# @FUNCTION: cmake_use_find_package
+# @USAGE: <USE flag> <package name>
+# @DESCRIPTION:
+# Alias for cmake-utils_use_find_package.
+cmake_use_find_package() {
+ if [[ "$#" != 2 ]] ; then
+ die "Usage: cmake_use_find_package <USE flag> <package name>"
+ fi
+
+ cmake-utils_use_find_package "$@" ;
+}
+
# @FUNCTION: cmake-utils_use_disable
# @USAGE: <USE flag> [flag name]
# @DESCRIPTION:
grep -qs "<<< Gentoo configuration >>>" "${CMAKE_USE_DIR}"/CMakeLists.txt && return 0
# Comment out all set (<some_should_be_user_defined_variable> value)
- # TODO Add QA checker - inform when variable being checked for below is set in CMakeLists.txt
- find "${CMAKE_USE_DIR}" -name CMakeLists.txt \
- -exec sed -i -e '/^[[:space:]]*[sS][eE][tT][[:space:]]*([[:space:]]*CMAKE_BUILD_TYPE.*)/{s/^/#IGNORE /g}' {} + \
- -exec sed -i -e '/^[[:space:]]*[sS][eE][tT][[:space:]]*([[:space:]]*CMAKE_COLOR_MAKEFILE.*)/{s/^/#IGNORE /g}' {} + \
- -exec sed -i -e '/^[[:space:]]*[sS][eE][tT][[:space:]]*([[:space:]]*CMAKE_INSTALL_PREFIX.*)/{s/^/#IGNORE /g}' {} + \
- -exec sed -i -e '/^[[:space:]]*[sS][eE][tT][[:space:]]*([[:space:]]*CMAKE_VERBOSE_MAKEFILE.*)/{s/^/#IGNORE /g}' {} + \
- || die "${LINENO}: failed to disable hardcoded settings"
+ find "${CMAKE_USE_DIR}" -name CMakeLists.txt -exec sed \
+ -e '/^[[:space:]]*set[[:space:]]*([[:space:]]*CMAKE_BUILD_TYPE\([[:space:]].*)\|)\)/I{s/^/#_cmake_modify_IGNORE /g}' \
+ -e '/^[[:space:]]*set[[:space:]]*([[:space:]]*CMAKE_COLOR_MAKEFILE[[:space:]].*)/I{s/^/#_cmake_modify_IGNORE /g}' \
+ -e '/^[[:space:]]*set[[:space:]]*([[:space:]]*CMAKE_INSTALL_PREFIX[[:space:]].*)/I{s/^/#_cmake_modify_IGNORE /g}' \
+ -e '/^[[:space:]]*set[[:space:]]*([[:space:]]*CMAKE_VERBOSE_MAKEFILE[[:space:]].*)/I{s/^/#_cmake_modify_IGNORE /g}' \
+ -i {} + || die "${LINENO}: failed to disable hardcoded settings"
+ local x
+ for x in $(find "${CMAKE_USE_DIR}" -name CMakeLists.txt -exec grep -l "^#_cmake_modify_IGNORE" {} +;); do
+ einfo "Hardcoded definition(s) removed in $(echo "${x}" | cut -c $((${#CMAKE_USE_DIR}+2))-):"
+ einfo "$(grep -se '^#_cmake_modify_IGNORE' ${x} | cut -c 22-99)"
+ done
# NOTE Append some useful summary here
cat >> "${CMAKE_USE_DIR}"/CMakeLists.txt <<- _EOF_ || die
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
fi
fi
- if [[ ${EPREFIX} ]]; then
+ if use prefix-guest; then
cat >> "${build_rules}" <<- _EOF_ || die
# in Prefix we need rpath and must ensure cmake gets our default linker path
# right ... except for Darwin hosts
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 BOOL "")
_EOF_
fi