Unset CC and CXX environment variables when compiler is set to msvc

Maybe a good one for the future. If “compiler:” is set to something like msvc on Windows, consider unsetting CC and CXX. For automatically detecting the compiler version in (at least) Conan (https://conan.io) the environment variables get in the way. i.e. Conan detects gcc. Even setting the environment variable CC to cl.exe does not work. I’m not sure if automatic detection works as expected in for example CMake. I currently just work around it by unsetting the variables if os.

1 Like

I agree, it’s very confusing that my travis.yml says this:

    language: c
        # Windows x64 builds (MSVC)
        - os: windows
          env: CC=CL.exe CXX=CL.exe

and my log says this:

Setting environment variables from .travis.yml
$ export CC=CL.exe
$ export CXX=CL.exe
$ export TRAVIS_COMPILER=gcc
$ export CC=gcc
$ export CC_FOR_BUILD=gcc
$ gcc --version

Hey, I guess it’s late, but this might help. Basically:

    - os: Windows
      # ...
         - MATRIX_EVAL="CC=CL.exe && CXX=CL.exe"
# ...
    - eval "${MATRIX_EVAL}"