]> git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/opentelemetry-cpp/tools/setup-cmake.sh
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / jaegertracing / opentelemetry-cpp / tools / setup-cmake.sh
1 #!/bin/bash
2 #
3 # This script installs latest CMake on Linux machine
4 #
5 export PATH=/usr/local/bin:$PATH
6 # Min required CMake version
7 export CMAKE_MIN_VERSION=${1:-3.1.0}
8 # Target version to install if min required is not found
9 export CMAKE_VERSION=${2:-3.18.4}
10
11 UPGRADE_NEEDED=no
12
13 function splitVersion {
14 pattern='([^0-9]*\([0-9]*\)[.]\([0-9]*\)[.]'
15 v1=$(cut -d '.' -f 1 <<< $ver )
16 v2=$(cut -d '.' -f 2 <<< $ver )
17 v3=$(cut -d '.' -f 3 <<< $ver )
18 }
19
20 function checkVersion {
21 # Current CMake version
22 currVer=`cmake --version | grep version | cut -d' ' -f 3`
23 ver=$currVer splitVersion
24 cv1=$v1
25 cv2=$v2
26 cv3=$v3
27 cv=`echo "65536*$v1+256*$v2+$v3" | bc`
28
29 # New CMake version
30 ver=$CMAKE_MIN_VERSION splitVersion
31 nv=`echo "65536*$v1+256*$v2+$v3" | bc`
32 if [ "$cv" -ge "$nv" ]; then
33 echo "CMake is already installed: $currVer"
34 else
35 UPGRADE_NEEDED=yes
36 fi
37 }
38
39 checkVersion
40
41 if [[ "$UPGRADE_NEEDED" == "no" ]]; then
42 echo "Skipping CMake installation"
43 exit 0
44 fi
45
46 # Download cmake to /tmp
47 pushd /tmp
48 if [[ ! -f "/tmp/cmake.tar.gz" ]]; then
49 wget -O /tmp/cmake.tar.gz https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}.tar.gz
50 tar -zxvf /tmp/cmake.tar.gz
51 fi
52 # Bootstrap CMake
53 cd cmake-${CMAKE_VERSION}
54 ./bootstrap --prefix=/usr/local
55 # Build CMake without CMake and without Ninja (slow)
56 make
57 make install
58 popd