[cmake-developers] CMakeForceCompiler (was: Regression caused by compute-default-dialect topic)

Brad King brad.king at kitware.com
Tue Sep 22 16:39:07 EDT 2015


On 09/22/2015 04:29 PM, Stephen Kelly wrote:
> I've pushed fix-forced-toolchain-dialect to fix this. It uses an existing 
> mechanism already in use to determine whether the compiler was forced.

Looks good, thanks.

> Is there any legitimate need to force the compiler?

The CMakeForceCompiler module was added here:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fda7753f

The commit message mentions:

 ... embedded compilers need a user specific linker file for compiling
 an executable ... thus cannot build the compiler-id program...

Since then the compiler id logic has learned to do things like pass
the --version flag and match vendor-specific output.  That could be
used to identify these embedded compilers.  Then the test for working
compiler will still need a linker file but perhaps we can generate
one once we know the compiler id.

> For example, why does the android toolchain file force GNU and Clang 
> compilers? Is it misunderstanding on the part of the toolchain author?

I don't think the android.toolchain.cmake file needs to force the
compiler.  It can simply set CMAKE_{C,CXX}_COMPILER and let the
normal detection proceed.

> Ie: Should CmakeForceCompiler.cmake be deprecated? It seems to date from a 
> time when the compiler id and whether it 'basically works' were the only 
> things CMake wished to know in order to initialize. Today there is much 
> more, including compiler version, ABI and features. 

Yes, I think it should be deprecated if possible.  First we must
provide alternatives for all its use cases though.

-Brad



More information about the cmake-developers mailing list