7

I am working with a very inconvenient software, and it doesn't support clang. So, I am required to change my cmake compiler and as I read almost everywhere, and here How can I make CMake use GCC instead of Clang on Mac OS X?, I tried :

cmake -DCMAKE_CXX_COMPILER=/usr/bin/g++

However, I am still getting this error

CMake Error at CMakeLists.txt:59 (message):

GAMBIT does not support the Clang compiler. Please choose another compiler.

-- Configuring incomplete, errors occurred!

Any suggestion, please?

ShS
  • 109
  • 2
  • 9

2 Answers2

8

I've found setting environment variables CC and CXX before running CMake for the first time peferrable to messing with CMAKE_CXX_COMPILER. Also note that it's probably a good idea to set both. So get into an empty binary directory and run this:

CC=/usr/bin/gcc CXX=/usr/bin/g++ cmake ...

Also make sure that /usr/bin/gcc is really GCC and not e.g. a symlinked or otherwise disguised Clang (I believe such setup can exist in the MacOS world).

Angew is no longer proud of SO
  • 161,995
  • 14
  • 331
  • 433
2

You probably need to set CMAKE_C_COMPILER as well, that is:

cmake -DCMAKE_CXX_COMPILER=/usr/bin/g++ -DCMAKE_C_COMPILER=/usr/bin/gcc

Indeed, looking at Gambit source code, it seems it's mostly C.

Personally, I usually like to set both, just in case.

valiano
  • 13,473
  • 5
  • 50
  • 72
  • 1
    my /usr/bin/g++ was actually a symlink to clang and the real address for my g++ was /opt/local/bin/g++! the default /usr/bin/g++ is the one coming with xcode – ShS Sep 29 '17 at 18:36