summaryrefslogtreecommitdiffstats
path: root/src/ci/docker/scripts/cmake.sh
blob: 822666c89530d8a8f8b4751e61bb1ab2bdc4a4dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
set -ex

hide_output() {
  set +x
  on_err="
echo ERROR: An error was encountered with the build.
cat /tmp/cmake_build.log
exit 1
"
  trap "$on_err" ERR
  bash -c "while true; do sleep 30; echo \$(date) - building ...; done" &
  PING_LOOP_PID=$!
  "$@" &> /tmp/cmake_build.log
  trap - ERR
  kill $PING_LOOP_PID
  rm /tmp/cmake_build.log
  set -x
}

# LLVM 17 requires CMake 3.20 or higher.
# This script is not necessary for images using Ubuntu 22.04 or newer.
CMAKE=3.20.3
curl -L https://github.com/Kitware/CMake/releases/download/v$CMAKE/cmake-$CMAKE.tar.gz | tar xzf -

mkdir cmake-build
cd cmake-build
hide_output ../cmake-$CMAKE/configure
hide_output make -j$(nproc)
hide_output make install

cd ..
rm -rf cmake-build
rm -rf cmake-$CMAKE