Travis CI with Clang 3.4 and C++11

后端 未结 3 599
我在风中等你
我在风中等你 2021-01-30 00:26

Is it possible to get Travis CI working with Clang that is capable of C++11? (I want Clang, not GCC, I already have GCC 4.8 working in Travis CI.) It appears that the version th

3条回答
  •  臣服心动
    2021-01-30 00:47

    There is now a better way to do this.

    sudo: false
    dist: trusty
    language: cpp
    os:
      - linux
    compiler:
      - gcc
      - clang
    install:
    # /usr/bin/gcc is 4.6 always, but gcc-X.Y is available.
    - if [[ $CXX = g++ ]]; then export CXX="g++-4.9" CC="gcc-4.9"; fi
    # /usr/bin/clang has a conflict with gcc, so use clang-X.Y.
    - if [[ $CXX = clang++ ]]; then export CXX="clang++-3.5" CC="clang-3.5"; fi
    addons:
      apt:
        sources:
        - ubuntu-toolchain-r-test
        - llvm-toolchain-precise-3.5 # not sure why we needed this
      packages:
        - gcc-4.9
        - g++-4.9
        - clang-3.5
    

    (The explicit sudo: false will let it build in Docker (for speed) even if you have a pre-docker repo, according to Travis support.)

    Thanks to solarce at Travis support for noticing my error and fixing the docs.

    • http://docs.travis-ci.com/user/apt/
    • http://genbattle.bitbucket.org/blog/2016/01/17/c++-travis-ci/
    • https://github.com/open-source-parsers/jsoncpp/blob/master/.travis.yml (for up-to-date example)

提交回复
热议问题