How do I install clang from C ++ 17 on Travis CI?

I am trying to set up Trevis CI with clang 4.0. I need C ++ 17 support. I am using the following script:

language: cpp
sudo: required

os:
    - linux

compiler:
    - clang

env:
    - TARGET_CPU=x86 BUILD_CONFIGURATION=Debug
    - TARGET_CPU=x86 BUILD_CONFIGURATION=Release
    - TARGET_CPU=x64 BUILD_CONFIGURATION=Debug
    - TARGET_CPU=x64 BUILD_CONFIGURATION=Release
    - TARGET_CPU=amd64 BUILD_CONFIGURATION=Debug
    - TARGET_CPU=amd64 BUILD_CONFIGURATION=Release

before_install:  
  - sudo apt-add-repository "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-4.0 main"
  - sudo apt-get update -qq

install: 
  - sudo apt-get install libboost-all-dev
  - sudo apt-get install --allow-unauthenticated -qq clang++-4.0
  - export CXX="clang++-4.0"

script:
    - mkdir build
    - cd build
    - cmake .. -DTARGET_CPU=$TARGET_CPU -DCMAKE_BUILD_TYPE=$BUILD_CONFIGURATION
    - make

      

Despite the fact that the clang 4.0 was installed successfully build with the message error: no member named 'make_unique' in namespace 'std'

. This means I don't even support C ++ 11. How can I fix this? Am I missing something in travis.yml

?

+3


source to share


1 answer


Your Clang version should be fine, problem (based on my experience). Travis does not respect various CMake configurations. For some reason, in my experience, Travis CI seems to ignore the variable CMAKE_CXX_STANDARD

in CMake.

For example Travis will ignore the following lines (for C ++ 11) in my CMakeLists.txt.

set(CMAKE_CXX_STANDARD 11)
set(CXX_STANDARD TRUE)

      

If I add flags manually, I can get successful builds:



set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

      

For C ++ 17, you would like to change this to set(CMAKE_CXX_STANDARD 17)

and set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1z")

.

None of this is perfect IMO, but this is a workable workaround.

0


source







All Articles