[CMake] Prefer clang over gcc

Quaquaraquà nuquaquaraqua at gmail.com
Sun Jun 24 07:23:44 EDT 2018


@Eike, indeed, that's the behaviour I wanted to change.

Digging in the src code it seems that what I'm looking is the var 
CMAKE_C_COMPILER_NAMES, apparently undocumented.

set(CMAKE_C_COMPILER_NAMES clang gcc icc cc)
set(CMAKE_CXX_COMPILER_NAMES clang++ g++ icpc c++ cxx)
project(hellogtest)
set(CMAKE_CXX_STANDARD 17)


On 24/06/18 12:20, Rolf Eike Beer wrote:
> Am Sonntag, 24. Juni 2018, 11:32:32 CEST schrieb Quaquaraquà:
>> Dear users,
>>
>> how do you specify the order of compilers to select from the system?
>> That is, if the user didn't set neither CMAKE_C_COMPILER nor the env.
>> var. CC, I wish the build system would pick one of the compilers from a
>> given list. In AutoConf, this is achieved through AC_PROG_CC([clang gcc
>> icc cc]) [1]. What would be the corresponding snippet in cmake?
> CMake will look at /usr/bin/cc if nothing else is set.
>
> Eike
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180624/2f5ca7e9/attachment.html>


More information about the CMake mailing list