mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-16 01:16:59 +02:00
eclass/cmake: Sync with Gentoo
It's from Gentoo commit 759cec852497f888d93cccfedbc83f16eb765fb4.
This commit is contained in:
parent
7b4897eebf
commit
6b973e990a
@ -1,4 +1,4 @@
|
||||
# Copyright 1999-2021 Gentoo Authors
|
||||
# Copyright 1999-2022 Gentoo Authors
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
|
||||
# @ECLASS: cmake.eclass
|
||||
@ -28,7 +28,7 @@ _CMAKE_ECLASS=1
|
||||
|
||||
inherit flag-o-matic multiprocessing ninja-utils toolchain-funcs xdg-utils
|
||||
|
||||
# @ECLASS-VARIABLE: BUILD_DIR
|
||||
# @ECLASS_VARIABLE: BUILD_DIR
|
||||
# @DEFAULT_UNSET
|
||||
# @DESCRIPTION:
|
||||
# Build directory where all cmake processed files should be generated.
|
||||
@ -38,13 +38,13 @@ inherit flag-o-matic multiprocessing ninja-utils toolchain-funcs xdg-utils
|
||||
[[ ${EAPI} == 7 ]] && : ${BUILD_DIR:=${WORKDIR}/${P}_build}
|
||||
# EAPI-8: set inside _cmake_check_build_dir
|
||||
|
||||
# @ECLASS-VARIABLE: CMAKE_BINARY
|
||||
# @ECLASS_VARIABLE: CMAKE_BINARY
|
||||
# @DESCRIPTION:
|
||||
# Eclass can use different cmake binary than the one provided in by system.
|
||||
: ${CMAKE_BINARY:=cmake}
|
||||
|
||||
[[ ${EAPI} == 7 ]] && : ${CMAKE_BUILD_TYPE:=Gentoo}
|
||||
# @ECLASS-VARIABLE: CMAKE_BUILD_TYPE
|
||||
# @ECLASS_VARIABLE: CMAKE_BUILD_TYPE
|
||||
# @DESCRIPTION:
|
||||
# Set to override default CMAKE_BUILD_TYPE. Only useful for packages
|
||||
# known to make use of "if (CMAKE_BUILD_TYPE MATCHES xxx)".
|
||||
@ -57,12 +57,12 @@ inherit flag-o-matic multiprocessing ninja-utils toolchain-funcs xdg-utils
|
||||
# In EAPI 7, the default was non-standard build type of Gentoo.
|
||||
: ${CMAKE_BUILD_TYPE:=RelWithDebInfo}
|
||||
|
||||
# @ECLASS-VARIABLE: CMAKE_IN_SOURCE_BUILD
|
||||
# @ECLASS_VARIABLE: CMAKE_IN_SOURCE_BUILD
|
||||
# @DEFAULT_UNSET
|
||||
# @DESCRIPTION:
|
||||
# Set to enable in-source build.
|
||||
|
||||
# @ECLASS-VARIABLE: CMAKE_MAKEFILE_GENERATOR
|
||||
# @ECLASS_VARIABLE: CMAKE_MAKEFILE_GENERATOR
|
||||
# @PRE_INHERIT
|
||||
# @DEFAULT_UNSET
|
||||
# @DESCRIPTION:
|
||||
@ -71,7 +71,7 @@ inherit flag-o-matic multiprocessing ninja-utils toolchain-funcs xdg-utils
|
||||
# The default is set to "ninja".
|
||||
: ${CMAKE_MAKEFILE_GENERATOR:=ninja}
|
||||
|
||||
# @ECLASS-VARIABLE: CMAKE_REMOVE_MODULES_LIST
|
||||
# @ECLASS_VARIABLE: CMAKE_REMOVE_MODULES_LIST
|
||||
# @PRE_INHERIT
|
||||
# @DEFAULT_UNSET
|
||||
# @DESCRIPTION:
|
||||
@ -90,25 +90,25 @@ else
|
||||
fi
|
||||
fi
|
||||
|
||||
# @ECLASS-VARIABLE: CMAKE_USE_DIR
|
||||
# @ECLASS_VARIABLE: CMAKE_USE_DIR
|
||||
# @DESCRIPTION:
|
||||
# Sets the directory where we are working with cmake, for example when
|
||||
# application uses autotools and only one plugin needs to be done by cmake.
|
||||
# By default it uses current working directory (in EAPI-7: ${S}).
|
||||
|
||||
# @ECLASS-VARIABLE: CMAKE_VERBOSE
|
||||
# @ECLASS_VARIABLE: CMAKE_VERBOSE
|
||||
# @DESCRIPTION:
|
||||
# Set to OFF to disable verbose messages during compilation
|
||||
: ${CMAKE_VERBOSE:=ON}
|
||||
|
||||
# @ECLASS-VARIABLE: CMAKE_WARN_UNUSED_CLI
|
||||
# @ECLASS_VARIABLE: CMAKE_WARN_UNUSED_CLI
|
||||
# @DESCRIPTION:
|
||||
# Warn about variables that are declared on the command line
|
||||
# but not used. Might give false-positives.
|
||||
# "no" to disable (default) or anything else to enable.
|
||||
: ${CMAKE_WARN_UNUSED_CLI:=yes}
|
||||
|
||||
# @ECLASS-VARIABLE: CMAKE_EXTRA_CACHE_FILE
|
||||
# @ECLASS_VARIABLE: CMAKE_EXTRA_CACHE_FILE
|
||||
# @USER_VARIABLE
|
||||
# @DEFAULT_UNSET
|
||||
# @DESCRIPTION:
|
||||
@ -116,7 +116,7 @@ fi
|
||||
# for econf and is needed to pass TRY_RUN results when cross-compiling.
|
||||
# Should be set by user in a per-package basis in /etc/portage/package.env.
|
||||
|
||||
# @ECLASS-VARIABLE: CMAKE_QA_SRC_DIR_READONLY
|
||||
# @ECLASS_VARIABLE: CMAKE_QA_SRC_DIR_READONLY
|
||||
# @USER_VARIABLE
|
||||
# @DEFAULT_UNSET
|
||||
# @DESCRIPTION:
|
||||
@ -136,7 +136,7 @@ case ${CMAKE_MAKEFILE_GENERATOR} in
|
||||
BDEPEND="sys-devel/make"
|
||||
;;
|
||||
ninja)
|
||||
BDEPEND="dev-util/ninja"
|
||||
BDEPEND="${NINJA_DEPEND}"
|
||||
;;
|
||||
*)
|
||||
eerror "Unknown value for \${CMAKE_MAKEFILE_GENERATOR}"
|
||||
@ -363,13 +363,6 @@ cmake_src_prepare() {
|
||||
die "FATAL: Unable to find CMakeLists.txt"
|
||||
fi
|
||||
|
||||
# if ninja is enabled but not installed, the build could fail
|
||||
# this could happen if ninja is manually enabled (eg. make.conf) but not installed
|
||||
if [[ ${CMAKE_MAKEFILE_GENERATOR} == ninja ]] && ! has_version -b dev-util/ninja; then
|
||||
eerror "CMAKE_MAKEFILE_GENERATOR is set to ninja, but ninja is not installed."
|
||||
die "Please install dev-util/ninja or unset CMAKE_MAKEFILE_GENERATOR."
|
||||
fi
|
||||
|
||||
local modules_list
|
||||
if [[ ${EAPI} == 7 && $(declare -p CMAKE_REMOVE_MODULES_LIST) != "declare -a"* ]]; then
|
||||
modules_list=( ${CMAKE_REMOVE_MODULES_LIST} )
|
||||
@ -406,6 +399,12 @@ cmake_src_prepare() {
|
||||
_CMAKE_SRC_PREPARE_HAS_RUN=1
|
||||
}
|
||||
|
||||
# @VARIABLE: MYCMAKEARGS
|
||||
# @DEFAULT_UNSET
|
||||
# @DESCRIPTION:
|
||||
# User-controlled environment variable containing arguments to be passed to
|
||||
# cmake in cmake_src_configure.
|
||||
|
||||
# @FUNCTION: cmake_src_configure
|
||||
# @DESCRIPTION:
|
||||
# General function for configuring with cmake. Default behaviour is to start an
|
||||
@ -593,9 +592,12 @@ cmake_src_configure() {
|
||||
"${mycmakeargs_local[@]}"
|
||||
-DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}"
|
||||
-DCMAKE_TOOLCHAIN_FILE="${toolchain_file}"
|
||||
"${MYCMAKEARGS}"
|
||||
)
|
||||
|
||||
if [[ -n ${MYCMAKEARGS} ]] ; then
|
||||
cmakeargs+=( "${MYCMAKEARGS}" )
|
||||
fi
|
||||
|
||||
if [[ -n "${CMAKE_EXTRA_CACHE_FILE}" ]] ; then
|
||||
cmakeargs+=( -C "${CMAKE_EXTRA_CACHE_FILE}" )
|
||||
fi
|
||||
@ -665,7 +667,8 @@ cmake_src_test() {
|
||||
|
||||
[[ -n ${TEST_VERBOSE} ]] && myctestargs+=( --extra-verbose --output-on-failure )
|
||||
|
||||
set -- ctest -j "$(makeopts_jobs)" --test-load "$(makeopts_loadavg)" "${myctestargs[@]}" "$@"
|
||||
set -- ctest -j "$(makeopts_jobs "${MAKEOPTS}" 999)" \
|
||||
--test-load "$(makeopts_loadavg)" "${myctestargs[@]}" "$@"
|
||||
echo "$@" >&2
|
||||
if "$@" ; then
|
||||
einfo "Tests succeeded."
|
||||
@ -695,11 +698,7 @@ cmake_src_test() {
|
||||
cmake_src_install() {
|
||||
debug-print-function ${FUNCNAME} "$@"
|
||||
|
||||
_cmake_check_build_dir
|
||||
pushd "${BUILD_DIR}" > /dev/null || die
|
||||
DESTDIR="${D}" ${CMAKE_MAKEFILE_GENERATOR} install "$@" ||
|
||||
die "died running ${CMAKE_MAKEFILE_GENERATOR} install"
|
||||
popd > /dev/null || die
|
||||
DESTDIR="${D}" cmake_build install "$@"
|
||||
|
||||
if [[ ${EAPI} == 7 ]]; then
|
||||
pushd "${S}" > /dev/null || die
|
||||
|
Loading…
Reference in New Issue
Block a user