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