File: setup-cmake.sh

package info (click to toggle)
opentelemetry-cpp 1.23.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,368 kB
  • sloc: cpp: 96,239; sh: 1,766; makefile: 38; python: 31
file content (64 lines) | stat: -rwxr-xr-x 1,462 bytes parent folder | download | duplicates (3)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash

# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

#
# This script installs latest CMake on Linux machine
#
set -e

export PATH=/usr/local/bin:$PATH
# Min required CMake version
export CMAKE_MIN_VERSION=${1:-3.1.0}
# Target version to install if min required is not found
export CMAKE_VERSION=${2:-3.18.4}

UPGRADE_NEEDED=no

function splitVersion {
  pattern='([^0-9]*\([0-9]*\)[.]\([0-9]*\)[.]'
  v1=$(cut -d '.' -f 1 <<< $ver )
  v2=$(cut -d '.' -f 2 <<< $ver )
  v3=$(cut -d '.' -f 3 <<< $ver )
}

function checkVersion {
  # Current CMake version
  currVer=`cmake --version | grep version | cut -d' ' -f 3`
  ver=$currVer splitVersion
  cv1=$v1
  cv2=$v2
  cv3=$v3
  cv=`echo "65536*$v1+256*$v2+$v3" | bc`

  # New CMake version
  ver=$CMAKE_MIN_VERSION splitVersion
  nv=`echo "65536*$v1+256*$v2+$v3" | bc`
  if [ "$cv" -ge "$nv" ]; then
    echo "CMake is already installed: $currVer"
  else
    UPGRADE_NEEDED=yes
  fi
}

checkVersion

if [[ "$UPGRADE_NEEDED" == "no" ]]; then
  echo "Skipping CMake installation"
  exit 0
fi

# Download cmake to /tmp
pushd /tmp
if [[ ! -f "/tmp/cmake.tar.gz" ]]; then
  wget -O /tmp/cmake.tar.gz https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}.tar.gz
  tar -zxvf /tmp/cmake.tar.gz
fi
# Bootstrap CMake
cd cmake-${CMAKE_VERSION}
./bootstrap --prefix=/usr/local
# Build CMake without CMake and without Ninja (slow)
make
make install
popd