[CMake] Setting compiler for cmake

Óscar Fuentes ofv at wanadoo.es
Sat Oct 5 03:59:52 EDT 2013


outro pessoa <outro.pessoa at gmail.com>
writes:

> Did it require any extra options outside of: clang bin/, clang lib/ , and
> the implicit link list when you started using "clang-is-compiler"?

It can be as easy as:

CC=clang CXX=clang cmake ...

or alternatively

cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ ...

Use a full path to clang/clang++ if they are installed on custom
directories outside of PATH.

If you wish tho use libc++ or other goodies I suppose(*) that you can
add the options in your CMakeLists.txt:

if( "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" )
...
endif()


[*] I don't use those libraries, so never checked that the above works.



More information about the CMake mailing list