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?
This is the command that will be used as the <LANG> compiler. Once set, you can not change this variable. This variable can be set by the user during the first time a build tree is configured. If a non-full path value is supplied then CMake will resolve the full path of the compiler.
If the default compiler chosen by cmake is gcc and you have installed clang, you can use the easy way to compile your project with clang: $ mkdir build && cd build $ CXX=clang++ CC=clang cmake.. $ make -j2
To switch between gcc and clang, you should have two completely separate build trees, and simply cd back and forth to "switch" compilers. Once a build tree is generated with a given compiler, you cannot switch the compiler for that build tree.
The order the compilers appear in the list depends on your PATH. On the C/C++ Configuration screen, scroll down and expand Advanced Settings and ensure that Mac framework path points to the system header files. For example: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks VS Code is now configured to use Clang on macOS.
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).
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With