File: install_abseil.sh

package info (click to toggle)
opentelemetry-cpp 1.19.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,744 kB
  • sloc: cpp: 79,029; sh: 1,640; makefile: 43; python: 31
file content (68 lines) | stat: -rwxr-xr-x 1,955 bytes parent folder | download | duplicates (2)
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
65
66
67
68
#!/bin/bash

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

set -ex
export DEBIAN_FRONTEND=noninteractive
[ -z "${ABSEIL_CPP_VERSION}" ] && export ABSEIL_CPP_VERSION="20240116.1"

TOPDIR=`pwd`

BUILD_DIR=/tmp/
INSTALL_DIR=/usr/local/
pushd $BUILD_DIR
git clone --depth=1 -b ${ABSEIL_CPP_VERSION} https://github.com/abseil/abseil-cpp.git
cd abseil-cpp
ABSEIL_CPP_BUILD_OPTIONS=(
    "-DBUILD_TESTING=OFF"
    "-DCMAKE_POSITION_INDEPENDENT_CODE=ON"
    "-DCMAKE_INSTALL_PREFIX=$INSTALL_DIR"
)

if [ ! -z "${CXX_STANDARD}" ]; then
    ABSEIL_CPP_BUILD_OPTIONS=(${ABSEIL_CPP_BUILD_OPTIONS[@]} "-DCMAKE_CXX_STANDARD=${CXX_STANDARD}")
fi

#
# ABSEIL_CPP_VERSION="20240116.1" fails to build with CMake 3.30
# ABSEIL_CPP_VERSION="20240116.2" fails to build with CMake 3.30
# note that somehow the same builds with CMake 3.29.6
#
# Error reported:
#   CMake Error at CMake/AbseilHelpers.cmake:317 (target_link_libraries):
#    The link interface of target "test_allocator" contains:
#
#      GTest::gmock
#
#    but the target was not found.  Possible reasons include:
#
#      * There is a typo in the target name.
#      * A find_package call is missing for an IMPORTED target.
#      * An ALIAS target is missing.
#
#   Call Stack (most recent call first):
#    absl/container/CMakeLists.txt:206 (absl_cc_library)
#
# Root cause:
#   https://github.com/abseil/abseil-cpp/pull/1536
#
# Applying fix from abseil commit 779a3565ac6c5b69dd1ab9183e500a27633117d5
#
# TODO(marcalff) Cleanup once abseil is upgraded to the next LTS


if [ "${ABSEIL_CPP_VERSION}" = "20240116.1" ] || [ "${ABSEIL_CPP_VERSION}" = "20240116.2" ]; then
  echo "Patching abseil"
  patch -p1 < ${TOPDIR}/ci/fix-abseil-cpp-issue-1536.patch
else
  echo "Not patching abseil"
fi

mkdir build && pushd build
cmake "${ABSEIL_CPP_BUILD_OPTIONS[@]}" ..
make -j $(nproc)
make install
popd
popd
export PATH=${INSTALL_DIR}/bin:$PATH  # ensure to use the installed abseil