Travis CI,使用包缓存更新 CMake

Travis CI, update CMake using the packages cache

我正在使用此代码片段在 travis 虚拟机中预安装所需的编译器版本

 - os: linux
  compiler: clang
  addons:
    apt:
      sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.5']
      packages: ['clang-3.5']
  env: COMPILER=clang++-3.5

这样做的优点是 运行 无需使用 sudo 即可在机器内部构建,从而加快构建速度。

使用 travis 时,如何使用它在 linux 和 osx 上安装 cmake 2.8.12(或更新版本)?我试过了

  - os: linux
  compiler: clang
  addons:
    apt:
      sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.5', 'add-apt-repository']
      packages: ['clang-3.5', 'ppa:kalakris/cmake']
  env: COMPILER=clang++-3.5

没有成功

要从 kalakris 安装 cmake,请使用:

addons:
    apt:
      packages:
        - cmake
      sources:
        - kalakris-cmake

更新的 CMake(来自 https://github.com/ldionne/hana/blob/master/.travis.yml

if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then
  CMAKE_URL="http://www.cmake.org/files/v3.3/cmake-3.3.1-Linux-x86_64.tar.gz"
  mkdir cmake && travis_retry wget --quiet -O - ${CMAKE_URL} | tar --strip-components=1 -xz -C cmake
  export PATH=${DEPS_DIR}/cmake/bin:${PATH}
else
  brew install cmake
fi

您案例中的完整代码段是:

 - os: linux
  compiler: clang
  addons:
    apt:
      sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.7', 'kalakris-cmake']
      packages: ['clang-3.7', 'cmake']
  env: COMPILER=clang++-3.7