macos_xcode_cmake.sh 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/bin/bash
  2. #
  3. # Copyright 2019 The Abseil Authors.
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. # https://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. set -euox pipefail
  17. if [[ -z ${ABSEIL_ROOT:-} ]]; then
  18. ABSEIL_ROOT="$(dirname ${0})/.."
  19. fi
  20. ABSEIL_ROOT=$(realpath ${ABSEIL_ROOT})
  21. source "${ABSEIL_ROOT}/ci/cmake_common.sh"
  22. # The MacOS build doesn't run in a docker container, so we have to override ABSL_GOOGLETEST_DOWNLOAD_URL.
  23. if [[ -r "${KOKORO_GFILE_DIR}/distdir/${ABSL_GOOGLETEST_COMMIT}.zip" ]]; then
  24. ABSL_GOOGLETEST_DOWNLOAD_URL="file://${KOKORO_GFILE_DIR}/distdir/${ABSL_GOOGLETEST_COMMIT}.zip"
  25. fi
  26. if [[ -z ${ABSL_CMAKE_BUILD_TYPES:-} ]]; then
  27. ABSL_CMAKE_BUILD_TYPES="Debug"
  28. fi
  29. if [[ -z ${ABSL_CMAKE_BUILD_SHARED:-} ]]; then
  30. ABSL_CMAKE_BUILD_SHARED="OFF ON"
  31. fi
  32. for compilation_mode in ${ABSL_CMAKE_BUILD_TYPES}; do
  33. for build_shared in ${ABSL_CMAKE_BUILD_SHARED}; do
  34. BUILD_DIR=$(mktemp -d ${compilation_mode}.XXXXXXXX)
  35. cd ${BUILD_DIR}
  36. # TODO(absl-team): Enable -Werror once all warnings are fixed.
  37. time cmake ${ABSEIL_ROOT} \
  38. -GXcode \
  39. -DBUILD_SHARED_LIBS=${build_shared} \
  40. -DABSL_BUILD_TESTING=ON \
  41. -DCMAKE_BUILD_TYPE=${compilation_mode} \
  42. -DCMAKE_CXX_STANDARD=14 \
  43. -DCMAKE_MODULE_LINKER_FLAGS="-Wl,--no-undefined" \
  44. -DABSL_GOOGLETEST_DOWNLOAD_URL="${ABSL_GOOGLETEST_DOWNLOAD_URL}"
  45. time cmake --build .
  46. time ctest -C ${compilation_mode} --output-on-failure
  47. done
  48. done