eclass/cmake: Sync with Gentoo

It's from Gentoo commit a0e313b883d68d1f58c007a2b431a0d544dd6871.
This commit is contained in:
Flatcar Buildbot 2023-03-27 07:22:38 +00:00
parent 5c9ff03b62
commit a72c6c1cbf

View File

@ -35,15 +35,15 @@ inherit flag-o-matic multiprocessing ninja-utils toolchain-funcs xdg-utils
# For in-source build it's fixed to ${CMAKE_USE_DIR}.
# For out-of-source build it can be overridden, by default it uses
# ${CMAKE_USE_DIR}_build (in EAPI-7: ${WORKDIR}/${P}_build).
[[ ${EAPI} == 7 ]] && : ${BUILD_DIR:=${WORKDIR}/${P}_build}
[[ ${EAPI} == 7 ]] && : "${BUILD_DIR:=${WORKDIR}/${P}_build}"
# EAPI-8: set inside _cmake_check_build_dir
# @ECLASS_VARIABLE: CMAKE_BINARY
# @DESCRIPTION:
# Eclass can use different cmake binary than the one provided in by system.
: ${CMAKE_BINARY:=cmake}
: "${CMAKE_BINARY:=cmake}"
[[ ${EAPI} == 7 ]] && : ${CMAKE_BUILD_TYPE:=Gentoo}
[[ ${EAPI} == 7 ]] && : "${CMAKE_BUILD_TYPE:=Gentoo}"
# @ECLASS_VARIABLE: CMAKE_BUILD_TYPE
# @DESCRIPTION:
# Set to override default CMAKE_BUILD_TYPE. Only useful for packages
@ -55,7 +55,7 @@ inherit flag-o-matic multiprocessing ninja-utils toolchain-funcs xdg-utils
# build type to achieve desirable results.
#
# In EAPI 7, the default was non-standard build type of Gentoo.
: ${CMAKE_BUILD_TYPE:=RelWithDebInfo}
: "${CMAKE_BUILD_TYPE:=RelWithDebInfo}"
# @ECLASS_VARIABLE: CMAKE_IN_SOURCE_BUILD
# @DEFAULT_UNSET
@ -69,7 +69,7 @@ inherit flag-o-matic multiprocessing ninja-utils toolchain-funcs xdg-utils
# Specify a makefile generator to be used by cmake.
# At this point only "emake" and "ninja" are supported.
# The default is set to "ninja".
: ${CMAKE_MAKEFILE_GENERATOR:=ninja}
: "${CMAKE_MAKEFILE_GENERATOR:=ninja}"
# @ECLASS_VARIABLE: CMAKE_REMOVE_MODULES_LIST
# @PRE_INHERIT
@ -100,14 +100,14 @@ fi
# @USER_VARIABLE
# @DESCRIPTION:
# Set to OFF to disable verbose messages during compilation
: ${CMAKE_VERBOSE:=ON}
: "${CMAKE_VERBOSE:=ON}"
# @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}
: "${CMAKE_WARN_UNUSED_CLI:=yes}"
# @ECLASS_VARIABLE: CMAKE_EXTRA_CACHE_FILE
# @USER_VARIABLE
@ -284,15 +284,15 @@ cmake-utils_useno() { _cmake_banned_func "" "$@" ; }
# Determine using IN or OUT source build
_cmake_check_build_dir() {
if [[ ${EAPI} == 7 ]]; then
: ${CMAKE_USE_DIR:=${S}}
: "${CMAKE_USE_DIR:=${S}}"
else
: ${CMAKE_USE_DIR:=${PWD}}
: "${CMAKE_USE_DIR:=${PWD}}"
fi
if [[ -n ${CMAKE_IN_SOURCE_BUILD} ]]; then
# we build in source dir
BUILD_DIR="${CMAKE_USE_DIR}"
else
: ${BUILD_DIR:=${CMAKE_USE_DIR}_build}
: "${BUILD_DIR:=${CMAKE_USE_DIR}_build}"
fi
einfo "Source directory (CMAKE_USE_DIR): \"${CMAKE_USE_DIR}\""
@ -526,6 +526,7 @@ cmake_src_configure() {
set(CMAKE_USER_MAKE_RULES_OVERRIDE "${build_rules}" CACHE FILEPATH "Gentoo override rules")
set(CMAKE_INSTALL_DOCDIR "${EPREFIX}/usr/share/doc/${PF}" CACHE PATH "")
set(BUILD_SHARED_LIBS ON CACHE BOOL "")
set(Python3_FIND_UNVERSIONED_NAMES FIRST CACHE STRING "")
_EOF_
if [[ -n ${_ECM_ECLASS} ]]; then