[cmake-developers] CMake compiler selection (was: CMake, Xcode 4.4, and Mountain Lion)

Brad King brad.king at kitware.com
Fri Aug 3 08:29:53 EDT 2012


On 08/01/2012 09:44 AM, Óscar Fuentes wrote:
> Brad King <brad.king at kitware.com> writes:
>> I'll think about other solutions.
> 
> For C++ projects, this heuristics may work:
> 
> - Find the C++ compiler.
> 
> - Unless the user asked for a specific C compiler, chose it depending on
>   the C++ compiler found (c++ for cc, g++ for gcc, clang for clang++,
>   etc)
> 
> Also, I'll propose that if CMake fails to find a matching C compiler on
> the second step above, the process shall error out.

The rules for each language need to be somewhat independent and
at most take hints from the other languages.  Each language is
enabled independently in the order listed in the project()
command or the order of invocation of enable_language().  The
default when the project() does not specify languages or NONE
explicitly is to enable C and then CXX.  Even if we changed the
default languages (unlikely) we still have to deal with projects
that list languages in arbitrary order.

Anyway, I've constructed a new topic to address this problem:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=796e3373
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7e58e5bb

The first commit does some refactoring with no functional change.
The second commit adjusts the compiler search order to prefer
system compilers by default.  This time it handles the case
sensitivity issues and allows per-platform system compiler names.

-Brad



More information about the cmake-developers mailing list