[LLVMdev] clean CMake build failing (Mac OS X 10.8)
Dimitry Andric
dimitry at andric.com
Mon Jul 30 14:13:57 PDT 2012
On 2012-07-30 19:03, Marshall Clow wrote:
> Over the weekend I upgraded my system to Mac OS X 10.8, and now a clean cmake build fails.
>
> The error message:
>> Building C object runtime/libprofile/CMakeFiles/profile_rt-static.dir/CommonProfiling.c.o
>> cc1: error: unrecognized command line option "-Wcovered-switch-default"
>
>
> The configuration:
>> Mac OS X 10.8
>> CMake 2.8.8
>> LLVM tot
>> Apple clang version 4.0 (tags/Apple/clang-421.0.57) (based on LLVM 3.1svn)
>
>
> Running cmake to generate the make files gives the following output:
>> -- The C compiler identification is GNU 4.2.1
>> -- The CXX compiler identification is Clang 4.0.0
>>
>
> Diagnosis:
> cmake is passing "-Wcovered-switch-default" to the c compiler.
> It also thinks that the c compiler should be gcc, rather than clang.
> gcc does not support that switch, and fails.
>
> Possible solutions:
> * use clang to compile the C code (note that /usr/bin/cc is clang on this system; why it's picking gcc, I don't know)
This is a problem in CMake; for a C compiler, it always picks a 'gcc'
executable in the PATH over a 'cc' executable. See the file
/opt/local/share/cmake-2.8/Modules/CMakeDetermineCCompiler.cmake, where
it has:
[...]
SET(CMAKE_C_COMPILER_LIST ${_CMAKE_TOOLCHAIN_PREFIX}gcc ${_CMAKE_TOOLCHAIN_PREFIX}cc cl bcc xlc)
Maybe this was done, because some systems used to have a bad default cc?
Like Solaris? :) I don't think that reasoning is really valid anymore,
these days, though.
In any case, I usually just add these to the cmake invocation, just to
be sure:
-DCMAKE_C_COMPILER=/usr/bin/cc -DCMAKE_CXX_COMPILER=/usr/bin/c++
More information about the llvm-dev
mailing list