1010# Maciej Mrozowski <[email protected] >1111# (undisclosed contributors)
1212# Original author: Zephyrus ([email protected] )13- # @SUPPORTED_EAPIS: 7 8
13+ # @SUPPORTED_EAPIS: 8
1414# @PROVIDES: ninja-utils
1515# @BLURB: common ebuild functions for cmake-based packages
1616# @DESCRIPTION:
1919# out-of-source builds (default) and in-source builds.
2020
2121case ${EAPI} in
22- 7)
23- ewarn " ${CATEGORY} /${PF} : ebuild uses ${ECLASS} with deprecated EAPI ${EAPI} !"
24- ewarn " ${CATEGORY} /${PF} : Support will be removed on 2025-11-14. Please port to newer EAPI."
25- ;;
2622 8) ;;
2723 * ) die " ${ECLASS} : EAPI ${EAPI:- 0} not supported" ;;
2824esac
@@ -38,16 +34,13 @@ inherit flag-o-matic multiprocessing ninja-utils toolchain-funcs xdg-utils
3834# Build directory where all cmake processed files should be generated.
3935# For in-source build it's fixed to ${CMAKE_USE_DIR}.
4036# For out-of-source build it can be overridden, by default it uses
41- # ${CMAKE_USE_DIR}_build (in EAPI-7: ${WORKDIR}/${P}_build).
42- [[ ${EAPI} == 7 ]] && : " ${BUILD_DIR:= ${WORKDIR} / ${P} _build} "
43- # EAPI-8: set inside _cmake_check_build_dir
37+ # ${CMAKE_USE_DIR}_build (set inside _cmake_check_build_dir).
4438
4539# @ECLASS_VARIABLE: CMAKE_BINARY
4640# @DESCRIPTION:
4741# Eclass can use different cmake binary than the one provided in by system.
4842: " ${CMAKE_BINARY:= cmake} "
4943
50- [[ ${EAPI} == 7 ]] && : " ${CMAKE_BUILD_TYPE:= Gentoo} "
5144# @ECLASS_VARIABLE: CMAKE_BUILD_TYPE
5245# @DESCRIPTION:
5346# Set to override default CMAKE_BUILD_TYPE. Only useful for packages
@@ -57,8 +50,6 @@ inherit flag-o-matic multiprocessing ninja-utils toolchain-funcs xdg-utils
5750# The default is RelWithDebInfo as that is least likely to append undesirable
5851# flags. However, you may still need to sed CMake files or choose a different
5952# build type to achieve desirable results.
60- #
61- # In EAPI 7, the default was non-standard build type of Gentoo.
6253: " ${CMAKE_BUILD_TYPE:= RelWithDebInfo} "
6354
6455# @ECLASS_VARIABLE: CMAKE_IN_SOURCE_BUILD
@@ -79,15 +70,13 @@ inherit flag-o-matic multiprocessing ninja-utils toolchain-funcs xdg-utils
7970# @PRE_INHERIT
8071# @DEFAULT_UNSET
8172# @DESCRIPTION:
82- # Array of .cmake modules to be removed in ${CMAKE_USE_DIR} (in EAPI-7: ${S})
83- # during src_prepare, in order to force packages to use the system version.
73+ # Array of .cmake modules to be removed in ${CMAKE_USE_DIR} during
74+ # src_prepare, in order to force packages to use the system version.
8475# By default, contains "FindBLAS" and "FindLAPACK".
8576# Set to empty to disable removing modules entirely.
8677if [[ ${CMAKE_REMOVE_MODULES_LIST} ]]; then
87- if [[ ${EAPI} != 7 ]]; then
88- [[ ${CMAKE_REMOVE_MODULES_LIST@ a} == * a* ]] ||
89- die " CMAKE_REMOVE_MODULES_LIST must be an array"
90- fi
78+ [[ ${CMAKE_REMOVE_MODULES_LIST@ a} == * a* ]] ||
79+ die " CMAKE_REMOVE_MODULES_LIST must be an array"
9180else
9281 if ! [[ ${CMAKE_REMOVE_MODULES_LIST@ a} == * a* && ${# CMAKE_REMOVE_MODULES_LIST[@]} -eq 0 ]]; then
9382 CMAKE_REMOVE_MODULES_LIST=( FindBLAS FindLAPACK )
9887# @DESCRIPTION:
9988# Sets the directory where we are working with cmake, for example when
10089# application uses autotools and only one plugin needs to be done by cmake.
101- # By default it uses current working directory (in EAPI-7: ${S}) .
90+ # By default it uses current working directory.
10291
10392# @ECLASS_VARIABLE: CMAKE_VERBOSE
10493# @USER_VARIABLE
@@ -167,9 +156,9 @@ _CMAKE_MINREQVER_CMAKE316=()
167156# @USER_VARIABLE
168157# @DEFAULT_UNSET
169158# @DESCRIPTION:
170- # After running cmake_src_prepare, sets ${CMAKE_USE_DIR} (in EAPI-7: ${S}) to
171- # read-only. This is a user flag and should under _no circumstances_ be set in
172- # the ebuild. Helps in improving QA of build systems that write to source tree.
159+ # After running cmake_src_prepare, sets ${CMAKE_USE_DIR} to read-only.
160+ # This is a user flag and should under _no circumstances_ be set in the
161+ # ebuild. Helps in improving QA of build systems that write to source tree.
173162
174163# @ECLASS_VARIABLE: CMAKE_SKIP_TESTS
175164# @DEFAULT_UNSET
@@ -259,13 +248,8 @@ cmake_use_find_package() {
259248# @DESCRIPTION:
260249# Determine using IN or OUT source build
261250_cmake_check_build_dir () {
262- if [[ ${EAPI} == 7 ]]; then
263- : " ${CMAKE_USE_DIR:= ${S} } "
264- else
265- # Since EAPI-8 we use current working directory, bug #704524
266- # esp. test with 'special' pkgs like: app-arch/brotli, net-libs/quiche
267- : " ${CMAKE_USE_DIR:= ${PWD} } "
268- fi
251+ # Since EAPI-8 we use current working directory, bug #704524
252+ : " ${CMAKE_USE_DIR:= ${PWD} } "
269253 if [[ -n ${CMAKE_IN_SOURCE_BUILD} ]]; then
270254 # we build in source dir
271255 BUILD_DIR=" ${CMAKE_USE_DIR} "
@@ -477,15 +461,10 @@ _cmake_modify-cmakelists() {
477461# @FUNCTION: cmake_prepare
478462# @DESCRIPTION:
479463# Check existence of and sanitise CMake files, then make ${CMAKE_USE_DIR}
480- # read-only. *MUST* be run or cmake_src_configure will fail. EAPI-8 only.
464+ # read-only. *MUST* be run or cmake_src_configure will fail.
481465cmake_prepare () {
482466 debug-print-function ${FUNCNAME} " $@ "
483467
484- if [[ ${EAPI} == 7 ]]; then
485- eerror " ${FUNCNAME} is EAPI-8 only. Call cmake_src_prepare instead."
486- die " FATAL: Forbidden function call."
487- fi
488-
489468 _cmake_check_build_dir
490469
491470 # Check if CMakeLists.txt exists and if not then die
@@ -519,44 +498,12 @@ cmake_prepare() {
519498# @DESCRIPTION:
520499# Apply ebuild and user patches via default_src_prepare. In case of
521500# conflict with another eclass' src_prepare phase, use cmake_prepare
522- # instead (EAPI-8 only).
523- # In EAPI-7, this phase *must* be run or cmake_src_configure will fail.
501+ # instead.
524502cmake_src_prepare () {
525503 debug-print-function ${FUNCNAME} " $@ "
526504
527- if [[ ${EAPI} == 7 ]]; then
528- pushd " ${S} " > /dev/null || die # workaround from cmake-utils
529- default_src_prepare
530- _cmake_check_build_dir
531- # check if CMakeLists.txt exists and if not then die
532- if [[ ! -e ${CMAKE_USE_DIR} /CMakeLists.txt ]] ; then
533- eerror " Unable to locate CMakeLists.txt under:"
534- eerror " \" ${CMAKE_USE_DIR} /CMakeLists.txt\" "
535- eerror " Consider not inheriting the cmake eclass."
536- die " FATAL: Unable to find CMakeLists.txt"
537- fi
538- local modules_list
539- if [[ $( declare -p CMAKE_REMOVE_MODULES_LIST) != " declare -a" * ]]; then
540- modules_list=( ${CMAKE_REMOVE_MODULES_LIST} )
541- else
542- modules_list=( " ${CMAKE_REMOVE_MODULES_LIST[@]} " )
543- fi
544- local name
545- for name in " ${modules_list[@]} " ; do
546- find " ${S} " -name " ${name} .cmake" -exec rm -v {} + || die
547- done
548- _cmake_modify-cmakelists # Remove dangerous things.
549- _cmake_minreqver-info
550- popd > /dev/null || die
551- # Make ${S} read-only in order to detect broken build systems
552- if [[ ${CMAKE_QA_SRC_DIR_READONLY} && ! ${CMAKE_IN_SOURCE_BUILD} ]]; then
553- chmod -R a-w " ${S} "
554- fi
555- _CMAKE_PREPARE_HAS_RUN=1
556- else
557- default_src_prepare
558- cmake_prepare
559- fi
505+ default_src_prepare
506+ cmake_prepare
560507}
561508
562509# @VARIABLE: MYCMAKEARGS
@@ -583,11 +530,7 @@ cmake_src_configure() {
583530 debug-print-function ${FUNCNAME} " $@ "
584531
585532 if [[ -z ${_CMAKE_PREPARE_HAS_RUN} ]]; then
586- if [[ ${EAPI} == 7 ]]; then
587- die " FATAL: cmake_src_prepare has not been run"
588- else
589- die " FATAL: cmake_src_prepare (or cmake_prepare) has not been run"
590- fi
533+ die " FATAL: cmake_src_prepare (or cmake_prepare) has not been run"
591534 fi
592535
593536 _cmake_check_build_dir
@@ -709,11 +652,6 @@ cmake_src_configure() {
709652 echo ' set(CMAKE_COLOR_MAKEFILE OFF CACHE BOOL "pretty colors during make" FORCE)' >> " ${common_config} " || die
710653 fi
711654
712- # See bug 735820
713- if [[ ${EAPI} != 7 ]]; then
714- echo ' set(CMAKE_INSTALL_ALWAYS 1)' >> " ${common_config} " || die
715- fi
716-
717655 # Wipe the default optimization flags out of CMake
718656 if [[ ${CMAKE_BUILD_TYPE} != Gentoo ]]; then
719657 cat >> ${common_config} << - _EOF_ || die
@@ -726,6 +664,7 @@ cmake_src_configure() {
726664 set(CMAKE_MODULE_LINKER_FLAGS_${CMAKE_BUILD_TYPE^^} "" CACHE STRING "")
727665 set(CMAKE_SHARED_LINKER_FLAGS_${CMAKE_BUILD_TYPE^^} "" CACHE STRING "")
728666 set(CMAKE_STATIC_LINKER_FLAGS_${CMAKE_BUILD_TYPE^^} "" CACHE STRING "")
667+ set(CMAKE_INSTALL_ALWAYS 1) # see Gentoo-bug 735820
729668 _EOF_
730669 fi
731670
@@ -887,15 +826,9 @@ cmake_src_install() {
887826
888827 DESTDIR=" ${D} " cmake_build " $@ " install
889828
890- if [[ ${EAPI} == 7 ]]; then
891- pushd " ${S} " > /dev/null || die
829+ pushd " ${CMAKE_USE_DIR} " > /dev/null || die
892830 einstalldocs
893- popd > /dev/null || die
894- else
895- pushd " ${CMAKE_USE_DIR} " > /dev/null || die
896- einstalldocs
897- popd > /dev/null || die
898- fi
831+ popd > /dev/null || die
899832
900833 local file files=()
901834 while read -d ' ' -r file ; do
0 commit comments