1 |
commit: ca79336c00701b0f0981adf57e2e0f6e614c3a0e |
2 |
Author: Andreas Sturmlechner <asturm <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Jul 18 11:25:20 2021 +0000 |
4 |
Commit: Andreas Sturmlechner <asturm <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Aug 21 13:10:11 2021 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/kde.git/commit/?id=ca79336c |
7 |
|
8 |
cmake.eclass: Support EAPI-8 |
9 |
|
10 |
Switch to using current working directory instead of ${S} |
11 |
when initializing ${CMAKE_USE_DIR} and ${BUILD_DIR}. |
12 |
|
13 |
Raise baseline cmake version to 3.20. |
14 |
|
15 |
Bug: https://bugs.gentoo.org/704524 |
16 |
Thanks-to: Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache.Org> |
17 |
Signed-off-by: Andreas Sturmlechner <asturm <AT> gentoo.org> |
18 |
|
19 |
eclass/cmake.eclass | 81 ++++++++++++++++++++++++++++++++++++----------------- |
20 |
1 file changed, 55 insertions(+), 26 deletions(-) |
21 |
|
22 |
diff --git a/eclass/cmake.eclass b/eclass/cmake.eclass |
23 |
index 05556e49f1..b78441bfaa 100644 |
24 |
--- a/eclass/cmake.eclass |
25 |
+++ b/eclass/cmake.eclass |
26 |
@@ -9,7 +9,7 @@ |
27 |
# Maciej Mrozowski <reavertm@g.o> |
28 |
# (undisclosed contributors) |
29 |
# Original author: Zephyrus (zephyrus@××××××.it) |
30 |
-# @SUPPORTED_EAPIS: 7 |
31 |
+# @SUPPORTED_EAPIS: 7 8 |
32 |
# @BLURB: common ebuild functions for cmake-based packages |
33 |
# @DESCRIPTION: |
34 |
# The cmake eclass makes creating ebuilds for cmake-based packages much easier. |
35 |
@@ -17,8 +17,8 @@ |
36 |
# out-of-source builds (default), in-source builds and an implementation of the |
37 |
# well-known use_enable function for CMake. |
38 |
|
39 |
-case ${EAPI:-0} in |
40 |
- 7) ;; |
41 |
+case ${EAPI} in |
42 |
+ 7|8) ;; |
43 |
*) die "EAPI=${EAPI:-0} is not supported" ;; |
44 |
esac |
45 |
|
46 |
@@ -28,12 +28,14 @@ if [[ -z ${_CMAKE_ECLASS} ]]; then |
47 |
_CMAKE_ECLASS=1 |
48 |
|
49 |
# @ECLASS-VARIABLE: BUILD_DIR |
50 |
+# @DEFAULT_UNSET |
51 |
# @DESCRIPTION: |
52 |
# Build directory where all cmake processed files should be generated. |
53 |
# For in-source build it's fixed to ${CMAKE_USE_DIR}. |
54 |
# For out-of-source build it can be overridden, by default it uses |
55 |
-# ${WORKDIR}/${P}_build. |
56 |
-: ${BUILD_DIR:=${WORKDIR}/${P}_build} |
57 |
+# ${CMAKE_USE_DIR}_build (in EAPI-7: ${WORKDIR}/${P}_build). |
58 |
+[[ ${EAPI} == 7 ]] && : ${BUILD_DIR:=${WORKDIR}/${P}_build} |
59 |
+# EAPI-8: set inside _cmake_check_build_dir |
60 |
|
61 |
# @ECLASS-VARIABLE: CMAKE_BINARY |
62 |
# @DESCRIPTION: |
63 |
@@ -65,16 +67,16 @@ _CMAKE_ECLASS=1 |
64 |
|
65 |
# @ECLASS-VARIABLE: CMAKE_REMOVE_MODULES_LIST |
66 |
# @DESCRIPTION: |
67 |
-# Space-separated list of CMake modules that will be removed in $S during |
68 |
-# src_prepare, in order to force packages to use the system version. |
69 |
-# Set to empty to disable removing modules entirely. |
70 |
+# Space-separated list of CMake modules to be removed in ${CMAKE_USE_DIR} |
71 |
+# (in EAPI-7: ${S}) during src_prepare, in order to force packages to use the |
72 |
+# system version. Set to empty to disable removing modules entirely. |
73 |
: ${CMAKE_REMOVE_MODULES_LIST:=FindBLAS FindLAPACK} |
74 |
|
75 |
# @ECLASS-VARIABLE: CMAKE_USE_DIR |
76 |
# @DESCRIPTION: |
77 |
# Sets the directory where we are working with cmake, for example when |
78 |
# application uses autotools and only one plugin needs to be done by cmake. |
79 |
-# By default it uses ${S}. |
80 |
+# By default it uses current working directory (in EAPI-7: ${S}). |
81 |
|
82 |
# @ECLASS-VARIABLE: CMAKE_VERBOSE |
83 |
# @DESCRIPTION: |
84 |
@@ -100,9 +102,9 @@ _CMAKE_ECLASS=1 |
85 |
# @USER_VARIABLE |
86 |
# @DEFAULT_UNSET |
87 |
# @DESCRIPTION: |
88 |
-# After running cmake_src_prepare, sets ${S} to read-only. This is |
89 |
-# a user flag and should under _no circumstances_ be set in the ebuild. |
90 |
-# Helps in improving QA of build systems that write to source tree. |
91 |
+# After running cmake_src_prepare, sets ${CMAKE_USE_DIR} (in EAPI-7: ${S}) to |
92 |
+# read-only. This is a user flag and should under _no circumstances_ be set in |
93 |
+# the ebuild. Helps in improving QA of build systems that write to source tree. |
94 |
|
95 |
inherit toolchain-funcs ninja-utils flag-o-matic multiprocessing xdg-utils |
96 |
|
97 |
@@ -127,7 +129,7 @@ case ${CMAKE_MAKEFILE_GENERATOR} in |
98 |
esac |
99 |
|
100 |
if [[ ${PN} != cmake ]]; then |
101 |
- BDEPEND+=" dev-util/cmake" |
102 |
+ BDEPEND+=" >=dev-util/cmake-3.20" |
103 |
fi |
104 |
|
105 |
# @FUNCTION: cmake_run_in |
106 |
@@ -264,14 +266,22 @@ cmake-utils_useno() { _cmake_banned_func "" "$@" ; } |
107 |
# @DESCRIPTION: |
108 |
# Determine using IN or OUT source build |
109 |
_cmake_check_build_dir() { |
110 |
- : ${CMAKE_USE_DIR:=${S}} |
111 |
+ if [[ ${EAPI} == 7 ]]; then |
112 |
+ : ${CMAKE_USE_DIR:=${S}} |
113 |
+ else |
114 |
+ : ${CMAKE_USE_DIR:=${PWD}} |
115 |
+ fi |
116 |
if [[ -n ${CMAKE_IN_SOURCE_BUILD} ]]; then |
117 |
# we build in source dir |
118 |
BUILD_DIR="${CMAKE_USE_DIR}" |
119 |
+ else |
120 |
+ : ${BUILD_DIR:=${CMAKE_USE_DIR}_build} |
121 |
fi |
122 |
|
123 |
+ einfo "Source directory (CMAKE_USE_DIR): \"${CMAKE_USE_DIR}\"" |
124 |
+ einfo "Build directory (BUILD_DIR): \"${BUILD_DIR}\"" |
125 |
+ |
126 |
mkdir -p "${BUILD_DIR}" || die |
127 |
- einfo "Working in BUILD_DIR: \"$BUILD_DIR\"" |
128 |
} |
129 |
|
130 |
# @FUNCTION: _cmake_modify-cmakelists |
131 |
@@ -320,12 +330,14 @@ _cmake_modify-cmakelists() { |
132 |
cmake_src_prepare() { |
133 |
debug-print-function ${FUNCNAME} "$@" |
134 |
|
135 |
- # FIXME: workaround from cmake-utils; use current working directory instead, bug #704524 |
136 |
- # esp. test with 'special' pkgs like: app-arch/brotli, media-gfx/gmic, net-libs/quiche |
137 |
- pushd "${S}" > /dev/null || die |
138 |
+ if [[ ${EAPI} == 7 ]]; then |
139 |
+ pushd "${S}" > /dev/null || die # workaround from cmake-utils |
140 |
+ # in EAPI-8, we use current working directory instead, bug #704524 |
141 |
+ # esp. test with 'special' pkgs like: app-arch/brotli, media-gfx/gmic, net-libs/quiche |
142 |
+ fi |
143 |
+ _cmake_check_build_dir |
144 |
|
145 |
default_src_prepare |
146 |
- _cmake_check_build_dir |
147 |
|
148 |
# check if CMakeLists.txt exist and if no then die |
149 |
if [[ ! -e ${CMAKE_USE_DIR}/CMakeLists.txt ]] ; then |
150 |
@@ -351,17 +363,28 @@ cmake_src_prepare() { |
151 |
|
152 |
local name |
153 |
for name in "${modules_list[@]}" ; do |
154 |
- find "${S}" -name ${name}.cmake -exec rm -v {} + || die |
155 |
+ if [[ ${EAPI} == 7 ]]; then |
156 |
+ find "${S}" -name ${name}.cmake -exec rm -v {} + || die |
157 |
+ else |
158 |
+ find -name "${name}.cmake" -exec rm -v {} + || die |
159 |
+ fi |
160 |
done |
161 |
|
162 |
# Remove dangerous things. |
163 |
_cmake_modify-cmakelists |
164 |
|
165 |
- popd > /dev/null || die |
166 |
+ if [[ ${EAPI} == 7 ]]; then |
167 |
+ popd > /dev/null || die |
168 |
+ fi |
169 |
|
170 |
- # make ${S} read-only in order to detect broken build-systems |
171 |
+ # Make ${CMAKE_USE_DIR} (in EAPI-7: ${S}) read-only in order to detect |
172 |
+ # broken build systems. |
173 |
if [[ ${CMAKE_QA_SRC_DIR_READONLY} && ! ${CMAKE_IN_SOURCE_BUILD} ]]; then |
174 |
- chmod -R a-w "${S}" |
175 |
+ if [[ ${EAPI} == 7 ]]; then |
176 |
+ chmod -R a-w "${S}" |
177 |
+ else |
178 |
+ chmod -R a-w "${CMAKE_USE_DIR}" |
179 |
+ fi |
180 |
fi |
181 |
|
182 |
_CMAKE_SRC_PREPARE_HAS_RUN=1 |
183 |
@@ -657,9 +680,15 @@ cmake_src_install() { |
184 |
die "died running ${CMAKE_MAKEFILE_GENERATOR} install" |
185 |
popd > /dev/null || die |
186 |
|
187 |
- pushd "${S}" > /dev/null || die |
188 |
- einstalldocs |
189 |
- popd > /dev/null || die |
190 |
+ if [[ ${EAPI} == 7 ]]; then |
191 |
+ pushd "${S}" > /dev/null || die |
192 |
+ einstalldocs |
193 |
+ popd > /dev/null || die |
194 |
+ else |
195 |
+ pushd "${CMAKE_USE_DIR}" > /dev/null || die |
196 |
+ einstalldocs |
197 |
+ popd > /dev/null || die |
198 |
+ fi |
199 |
} |
200 |
|
201 |
fi |