[cmake-developers] Cross-compiling with clang

Brad King brad.king at kitware.com
Wed Jun 19 09:08:50 EDT 2013


On 6/13/2013 11:39 AM, Stephen Kelly wrote:
> However, even when LDFLAGS is set, the ABI compiler test fails, and the 
> triple is not automatically determined, or the implicit link dirs etc. Only 
> the patch to the CMakeDetermineCompilerABI.cmake file I posted helps with 
> that. Is that expected, or is there a bug somewhere there?

I think something like your patch is needed, but perhaps more.
If linking flags are needed then of course they should be used in
all test builds.  This extends to all try_compile calls including
those made by CheckSymbolExists and similar modules.  See below.

>> Shouldn't you create a platform file that sets
>> CMAKE_*_LINKER_FLAGS_INIT appropriately?
> 
> I don't follow your thinking. Would such a file live in the cmake tree? What 
> would it be called and what else would it contain?

Well, either in CMake or in CMAKE_MODULE_PATH.  However, I think
my suggestion may be incorrect because in this case we're working
around trouble with the host system's arrangement of the compiler,
not anything specific to the target system for which the platform
file would be defined.

Until now we've depended on platform files always setting things
like CMAKE_EXE_LINKER_FLAGS_INIT because they are loaded in the
test projects inside try_compile.  The LDFLAGS environment variable
makes it into them too.  Now we have a case where we would like
flags specified for linking by the toolchain file to go through
also.  Therefore we need logic to pass such flags through.

The try_compile command already handles CMAKE_<LANG>_FLAGS by
itself when generating the project for the srcfile mode.  Perhaps
it can be taught to do more.

-Brad



More information about the cmake-developers mailing list