cmake-multilib.eclass (2624B)
1 # Copyright 1999-2021 Gentoo Authors 2 # Distributed under the terms of the GNU General Public License v2 3 4 # @ECLASS: cmake-multilib.eclass 5 # @MAINTAINER: 6 # Michał Górny <mgorny@gentoo.org> 7 # @AUTHOR: 8 # Author: Michał Górny <mgorny@gentoo.org> 9 # @SUPPORTED_EAPIS: 7 8 10 # @PROVIDES: cmake cmake-utils multilib-minimal 11 # @BLURB: cmake wrapper for multilib builds 12 # @DESCRIPTION: 13 # The cmake-multilib.eclass provides a glue between cmake.eclass(5) 14 # and multilib-minimal.eclass(5), aiming to provide a convenient way 15 # to build packages using cmake for multiple ABIs. 16 # 17 # Inheriting this eclass sets IUSE and exports default multilib_src_*() 18 # sub-phases that call cmake phase functions for each ABI enabled. 19 # The multilib_src_*() functions can be defined in ebuild just like 20 # in multilib-minimal, yet they ought to call appropriate cmake 21 # phase rather than 'default'. 22 23 [[ ${EAPI} == 7 ]] && : ${CMAKE_ECLASS:=cmake-utils} 24 # @ECLASS_VARIABLE: CMAKE_ECLASS 25 # @PRE_INHERIT 26 # @DESCRIPTION: 27 # Only "cmake" is supported in EAPI-8 and later. 28 # In EAPI-7, default is "cmake-utils" for compatibility. Specify "cmake" for 29 # ebuilds that ported to cmake.eclass already. 30 : ${CMAKE_ECLASS:=cmake} 31 32 # @ECLASS_VARIABLE: _CMAKE_ECLASS_IMPL 33 # @INTERNAL 34 # @DESCRIPTION: 35 # TODO: Cleanup once EAPI-7 support is gone. 36 _CMAKE_ECLASS_IMPL=cmake 37 38 case ${EAPI} in 39 7|8) 40 case ${CMAKE_ECLASS} in 41 cmake-utils|cmake) ;; 42 *) 43 eerror "Unknown value for \${CMAKE_ECLASS}" 44 die "Value ${CMAKE_ECLASS} is not supported" 45 ;; 46 esac 47 _CMAKE_ECLASS_IMPL=${CMAKE_ECLASS} 48 ;; 49 *) die "${ECLASS}: EAPI=${EAPI:-0} is not supported" ;; 50 esac 51 52 if [[ ${CMAKE_IN_SOURCE_BUILD} ]]; then 53 die "${ECLASS}: multilib support requires out-of-source builds." 54 fi 55 56 if [[ -z ${_CMAKE_MULTILIB_ECLASS} ]]; then 57 _CMAKE_MULTILIB_ECLASS=1 58 59 inherit ${_CMAKE_ECLASS_IMPL} multilib-minimal 60 61 cmake-multilib_src_configure() { 62 local _cmake_args=( "${@}" ) 63 64 multilib-minimal_src_configure 65 } 66 67 multilib_src_configure() { 68 ${_CMAKE_ECLASS_IMPL}_src_configure "${_cmake_args[@]}" 69 } 70 71 cmake-multilib_src_compile() { 72 local _cmake_args=( "${@}" ) 73 74 multilib-minimal_src_compile 75 } 76 77 multilib_src_compile() { 78 ${_CMAKE_ECLASS_IMPL}_src_compile "${_cmake_args[@]}" 79 } 80 81 cmake-multilib_src_test() { 82 local _cmake_args=( "${@}" ) 83 84 multilib-minimal_src_test 85 } 86 87 multilib_src_test() { 88 ${_CMAKE_ECLASS_IMPL}_src_test "${_cmake_args[@]}" 89 } 90 91 cmake-multilib_src_install() { 92 local _cmake_args=( "${@}" ) 93 94 multilib-minimal_src_install 95 } 96 97 multilib_src_install() { 98 ${_CMAKE_ECLASS_IMPL}_src_install "${_cmake_args[@]}" 99 } 100 101 fi 102 103 EXPORT_FUNCTIONS src_configure src_compile src_test src_install