xref: /aosp_15_r20/external/abseil-cpp/ci/macos_xcode_cmake.sh (revision 9356374a3709195abf420251b3e825997ff56c0f)
1*9356374aSAndroid Build Coastguard Worker#!/bin/bash
2*9356374aSAndroid Build Coastguard Worker#
3*9356374aSAndroid Build Coastguard Worker# Copyright 2019 The Abseil Authors.
4*9356374aSAndroid Build Coastguard Worker#
5*9356374aSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License");
6*9356374aSAndroid Build Coastguard Worker# you may not use this file except in compliance with the License.
7*9356374aSAndroid Build Coastguard Worker# You may obtain a copy of the License at
8*9356374aSAndroid Build Coastguard Worker#
9*9356374aSAndroid Build Coastguard Worker#    https://www.apache.org/licenses/LICENSE-2.0
10*9356374aSAndroid Build Coastguard Worker#
11*9356374aSAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software
12*9356374aSAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS,
13*9356374aSAndroid Build Coastguard Worker# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14*9356374aSAndroid Build Coastguard Worker# See the License for the specific language governing permissions and
15*9356374aSAndroid Build Coastguard Worker# limitations under the License.
16*9356374aSAndroid Build Coastguard Worker
17*9356374aSAndroid Build Coastguard Workerset -euox pipefail
18*9356374aSAndroid Build Coastguard Worker
19*9356374aSAndroid Build Coastguard Workerif [[ -z ${ABSEIL_ROOT:-} ]]; then
20*9356374aSAndroid Build Coastguard Worker  ABSEIL_ROOT="$(dirname ${0})/.."
21*9356374aSAndroid Build Coastguard Workerfi
22*9356374aSAndroid Build Coastguard WorkerABSEIL_ROOT=$(realpath ${ABSEIL_ROOT})
23*9356374aSAndroid Build Coastguard Worker
24*9356374aSAndroid Build Coastguard Workersource "${ABSEIL_ROOT}/ci/cmake_common.sh"
25*9356374aSAndroid Build Coastguard Worker
26*9356374aSAndroid Build Coastguard Workerif [[ -z ${ABSL_CMAKE_BUILD_TYPES:-} ]]; then
27*9356374aSAndroid Build Coastguard Worker  ABSL_CMAKE_BUILD_TYPES="Debug"
28*9356374aSAndroid Build Coastguard Workerfi
29*9356374aSAndroid Build Coastguard Worker
30*9356374aSAndroid Build Coastguard Workerif [[ -z ${ABSL_CMAKE_BUILD_SHARED:-} ]]; then
31*9356374aSAndroid Build Coastguard Worker  ABSL_CMAKE_BUILD_SHARED="OFF ON"
32*9356374aSAndroid Build Coastguard Workerfi
33*9356374aSAndroid Build Coastguard Worker
34*9356374aSAndroid Build Coastguard Workerif [[ -z ${ABSL_CMAKE_BUILD_MONOLITHIC_SHARED_LIBS:-} ]]; then
35*9356374aSAndroid Build Coastguard Worker  ABSL_CMAKE_BUILD_MONOLITHIC_SHARED_LIBS="OFF ON"
36*9356374aSAndroid Build Coastguard Workerfi
37*9356374aSAndroid Build Coastguard Worker
38*9356374aSAndroid Build Coastguard Workerfor compilation_mode in ${ABSL_CMAKE_BUILD_TYPES}; do
39*9356374aSAndroid Build Coastguard Worker  for build_shared in ${ABSL_CMAKE_BUILD_SHARED}; do
40*9356374aSAndroid Build Coastguard Worker    if [[ $build_shared == "OFF" ]]; then
41*9356374aSAndroid Build Coastguard Worker      monolithic_shared_options="OFF"
42*9356374aSAndroid Build Coastguard Worker    else
43*9356374aSAndroid Build Coastguard Worker      monolithic_shared_options="$ABSL_CMAKE_BUILD_MONOLITHIC_SHARED_LIBS"
44*9356374aSAndroid Build Coastguard Worker    fi
45*9356374aSAndroid Build Coastguard Worker
46*9356374aSAndroid Build Coastguard Worker    for monolithic_shared in $monolithic_shared_options; do
47*9356374aSAndroid Build Coastguard Worker      BUILD_DIR=$(mktemp -d ${compilation_mode}.XXXXXXXX)
48*9356374aSAndroid Build Coastguard Worker      cd ${BUILD_DIR}
49*9356374aSAndroid Build Coastguard Worker
50*9356374aSAndroid Build Coastguard Worker      # TODO(absl-team): Enable -Werror once all warnings are fixed.
51*9356374aSAndroid Build Coastguard Worker      time cmake ${ABSEIL_ROOT} \
52*9356374aSAndroid Build Coastguard Worker        -GXcode \
53*9356374aSAndroid Build Coastguard Worker        -DBUILD_SHARED_LIBS=${build_shared} \
54*9356374aSAndroid Build Coastguard Worker        -DABSL_BUILD_TESTING=ON \
55*9356374aSAndroid Build Coastguard Worker        -DCMAKE_BUILD_TYPE=${compilation_mode} \
56*9356374aSAndroid Build Coastguard Worker        -DCMAKE_CXX_STANDARD=14 \
57*9356374aSAndroid Build Coastguard Worker        -DCMAKE_MODULE_LINKER_FLAGS="-Wl,--no-undefined" \
58*9356374aSAndroid Build Coastguard Worker        -DABSL_BUILD_MONOLITHIC_SHARED_LIBS=${monolithic_shared} \
59*9356374aSAndroid Build Coastguard Worker        -DABSL_GOOGLETEST_DOWNLOAD_URL="${ABSL_GOOGLETEST_DOWNLOAD_URL}"
60*9356374aSAndroid Build Coastguard Worker      time cmake --build .
61*9356374aSAndroid Build Coastguard Worker      time TZDIR=${ABSEIL_ROOT}/absl/time/internal/cctz/testdata/zoneinfo \
62*9356374aSAndroid Build Coastguard Worker        ctest -C ${compilation_mode} --output-on-failure
63*9356374aSAndroid Build Coastguard Worker    done
64*9356374aSAndroid Build Coastguard Worker  done
65*9356374aSAndroid Build Coastguard Workerdone
66