summaryrefslogtreecommitdiffstats
path: root/do_cmake.sh
diff options
context:
space:
mode:
authorKefu Chai <tchaikov@gmail.com>2022-08-05 05:48:30 +0200
committerKefu Chai <tchaikov@gmail.com>2022-08-05 05:53:12 +0200
commit3d3b94a9dc9284465769176ceff4676a50fb2a6c (patch)
treee385ff13d15631b7f46ae73060d8b1b2f70732ad /do_cmake.sh
parentMerge pull request #47427 from tchaikov/wip-strong-ordering (diff)
downloadceph-3d3b94a9dc9284465769176ceff4676a50fb2a6c.tar.xz
ceph-3d3b94a9dc9284465769176ceff4676a50fb2a6c.zip
do_cmake:sh: use newer gcc if available
despite that we are using clang in `run-make-check.sh`, `do_cmake.sh` is still used by some workflows like jenkins' ceph-pr-api job. now that we've migrated to C++20, we need to use GCC-11 or up for building the tree. GCC-11 is installed from PPA repo in `install-deps.sh`, but to avoid interfere with the build of older branches which do not use GCC-11, as their builds might break if we use GCC-11 for building them. we don't use the alternative machinary to point gcc to gcc-11, see 8f342a32ce4a236c45c67497ae34f508e032a9e1. so, in this change, we try to use the newest GCC in system when running `do_cmake.sh`. Signed-off-by: Kefu Chai <tchaikov@gmail.com>
Diffstat (limited to 'do_cmake.sh')
-rwxr-xr-xdo_cmake.sh13
1 files changed, 13 insertions, 0 deletions
diff --git a/do_cmake.sh b/do_cmake.sh
index 3eb9b08d8af..7b4d9ddc644 100755
--- a/do_cmake.sh
+++ b/do_cmake.sh
@@ -59,6 +59,19 @@ if type ccache > /dev/null 2>&1 ; then
ARGS+=" -DWITH_CCACHE=ON"
fi
+cxx_compiler="g++"
+c_compiler="gcc"
+# 20 is used for more future-proof
+for i in $(seq 20 -1 11); do
+ if type -t gcc-$i > /dev/null; then
+ cxx_compiler="g++-$i"
+ c_compiler="gcc-$i"
+ break
+ fi
+done
+ARGS+=" -DCMAKE_CXX_COMPILER=$cxx_compiler"
+ARGS+=" -DCMAKE_C_COMPILER=$c_compiler"
+
mkdir $BUILD_DIR
cd $BUILD_DIR
if type cmake3 > /dev/null 2>&1 ; then