Suppose I have a system with multiple C/C++ compilers - various versions of GCC, clang and ICC. Also suppose I have a CMake C/C++ project which has certain requirements and certain preferences regarding the C/C++ compiler to use; and to complicate things, suppose these requirements and preferences and generated dynamically based on the combination of project options I've set (with ccmake
or otherwise).
Now, other answers about using a compiler other than the default suggest setting the CC or CXX environment variables - but this is clearly inappropriate here.
Is there a way to get CMake to:
- Detect the available compilers.
- Choose the one it likes based on some rules/ranking mechanism?
Notes:
- CMake 3.0 . You may assume a newer CMake version, but make that explicit please.
- The choice of C or C++ in this question is motivated by my own needs, but it could of course be some other language, if that solution is adaptable.