File: build-gtest.sh

package info (click to toggle)
opentelemetry-cpp 1.23.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,372 kB
  • sloc: cpp: 96,239; sh: 1,766; makefile: 36; python: 31
file content (41 lines) | stat: -rwxr-xr-x 1,375 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
#!/usr/bin/env bash

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

# Switch to workspace root directory first
DIR="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
WORKSPACE_ROOT=$DIR/..
pushd $WORKSPACE_ROOT

BUILD_ROOT=${BUILD_ROOT:-/tmp/build}
[[ ! -d "${BUILD_ROOT}"           ]] && mkdir -p "${BUILD_ROOT}"           || echo "Output directory already exists: BUILD_ROOT=${BUILD_ROOT}"

GTEST_BUILD_ROOT=${BUILD_ROOT}/gtest
[[ ! -d "${GTEST_BUILD_ROOT}"     ]] && mkdir -p "${GTEST_BUILD_ROOT}"     || echo "Output directory already exists: GTEST_BUILD_ROOT=${GTEST_BUILD_ROOT}"

# Path to Google Test source. Prefer Google Test from submodule if available:
export GTEST_SRC_PATH=${WORKSPACE_ROOT}/third_party/googletest
if [ ! -d "${GTEST_SRC_PATH}" ]; then
  # If not available, then use Google Test that is installed by OS package:
  export GTEST_SRC_PATH=/usr/src/gtest
  if [ ! -d "${GTEST_SRC_PATH}" ]; then
    echo "GTest not found!"
    exit 1
  fi
  echo Building GTest from source: ${GTEST_SRC_PATH} ...
fi

pushd $GTEST_BUILD_ROOT
cmake -Dgtest_build_samples=OFF \
      -Dgmock_build_samples=OFF \
      -Dgtest_build_tests=OFF \
      -Dgmock_build_tests=OFF \
      -DCMAKE_CXX_FLAGS="-fPIC $CXX_FLAGS -Wno-return-type" \
      -DCMAKE_INSTALL_PREFIX=$BUILD_ROOT \
      "${GTEST_SRC_PATH}"
make install
popd

popd