# GCC & CMake versions pre-installed on OSX

**URL:** <https://travis-ci.community/t/gcc-cmake-versions-pre-installed-on-osx/4693>\
**Category:** macOS\
**Tags:** build-env\
**Created:** [August 12, 2019, 1:34pm UTC](https://travis-ci.community/t/gcc-cmake-versions-pre-installed-on-osx/4693 "2019-08-12T13:34:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Farwaykorse](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/farwaykorse/32/762_2.png) [@Farwaykorse](https://travis-ci.community/u/Farwaykorse)\
**Post date:** [August 12, 2019, 1:34pm UTC](https://travis-ci.community/t/gcc-cmake-versions-pre-installed-on-osx/4693/1 "2019-08-12T13:34:19Z")

</div>

I use GCC to build a dependency and when GCC is present on the OSX images, the Homebrew update and install steps can be removed, reducing job execution times.  
But there is no [documentation](https://docs.travis-ci.com/user/languages/cpp/#gcc-on-macos) on which version is available on each image.

What I have found so far: ([test set](https://travis-ci.com/Farwaykorse/test_Travis_CMake/builds/125799604))

- `xcode11`:  
GCC 9.1.0: `gcc-9`; `g++-9`  
CMake 3.15.1
- `xcode10.3`:  
GCC 9.1.0: `gcc-9`; `g++-9`  
CMake 3.15.0
- `xcode10.2`:  
GCC 8.3.0: `gcc-8`; `g++-8`  
CMake 3.14.2
- `xcode10.1`:  
GCC 8.2.0: `gcc-8`; `g++-8`; use the command: `brew link gcc@8` to make GCC callable.  
CMake 3.12.3
- `xcode10`: …  
CMake 3.12.2
- `xcode9.4`: …  
CMake 3.11.4
- `xcode9.3`: …  
CMake 3.10.2
- `xcode9.2`: …  
CMake 3.10.0
- `xcode9.1`: …  
CMake 3.9.5
- `xcode9`: …  
CMake 3.9.2
- `xcode8.3`: …  
CMake 3.9.4
- `xcode8`:  
GCC 4.9.3: `gcc-4.9`; `g++-4.9`  
CMake 3.6.1
- `xcode7.3`:  
GCC 4.9.3: `gcc-4.9`; `g++-4.9`  
CMake 3.6.2
- `xcode6.4`:  
GCC 4.9.2: `gcc-4.9`; `g++-4.9`  
CMake 3.2.2

Does anyone have any additional information, or tips?

---

<div class="post-metadata">

**Author:** ![Farwaykorse](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/farwaykorse/32/762_2.png) [@Farwaykorse](https://travis-ci.community/u/Farwaykorse)\
**Post date:** [August 12, 2019, 1:40pm UTC](https://travis-ci.community/t/gcc-cmake-versions-pre-installed-on-osx/4693/2 "2019-08-12T13:40:31Z")

</div>

On the `xcode10.1` (and later) GCC is installed as the latest release available on Homebrew. To ensure the GCC version is not changed with `brew upgrade`, I relink the installs from `gcc` to `gcc@<version>`:

```auto
- |
  # OSX: set Homebrew gcc to gcc@<version>, to prevent version upgrades
  if [["${TRAVIS_OSX_IMAGE:-}" && ${TRAVIS_OSX_IMAGE} =~ ^xcode(11|10\.[12])$ ]]; then
    brew unlink gcc
    if [[${TRAVIS_OSX_IMAGE} == "xcode11"]]; then 
      brew link gcc@9
    else
      brew link gcc@8
    fi
  fi

```

This also covers the issue with `xcode10.1` where GCC is not callable with `g++-8`.

---

<div class="post-metadata">

**Author:** ![Farwaykorse](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/farwaykorse/32/762_2.png) [@Farwaykorse](https://travis-ci.community/u/Farwaykorse)\
**Post date:** [October 13, 2019, 8:28pm UTC](https://travis-ci.community/t/gcc-cmake-versions-pre-installed-on-osx/4693/3 "2019-10-13T20:28:01Z")

</div>

**New**

- `xcode11.2`:  
GCC 9.2.0: `gcc-9`; `g++-9` (homebrew GCC 9.2.0\_1)  
CMake 3.15.4
- `xcode11.1`:  
GCC 9.2.0: `gcc-9`; `g++-9`  
CMake 3.15.3

**Changed**

- `xcode11`:  
GCC 9.2.0: `gcc-9`; `g++-9`  
CMake 3.15.3
- `xcode10.1`:  
GCC is now callable with `gcc-8` and `g++-8` by default.

[test set](https://travis-ci.com/Farwaykorse/test_Travis_CMake/builds/133688957)

---

<div class="post-metadata">

**Author:** ![native-api](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/native-api/32/430_2.png) [@native-api](https://travis-ci.community/u/native-api)\
**Post date:** [October 13, 2019, 9:37pm UTC](https://travis-ci.community/t/gcc-cmake-versions-pre-installed-on-osx/4693/4 "2019-10-13T21:37:15Z")

</div>

You can check preinstalled version with `brew list --versions` and run `brew update && brew upgrade <package>` [if it’s lower than you want](https://stackoverflow.com/questions/4023830/how-to-compare-two-strings-in-dot-separated-version-format-in-bash) – or just fail the build to signal to yourself that you need to migrate to a newer image.
