ShS
ShS

Reputation: 129

change cmake compiler from clang to g++ for mac

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?

Upvotes: 7

Views: 11323

Answers (2)

valiano
valiano

Reputation: 18551

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.

Upvotes: 2

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).

Upvotes: 9

Related Questions