Prefer clang over gcc

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Prefer clang over gcc

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?

Yours,

Quaquaraqua


[1]
https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.69/html_node/C-Compiler.html

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Prefer clang over gcc

Rolf Eike Beer
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
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

signature.asc (201 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Prefer clang over gcc

Quaquaraquà

@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




--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake