[CMake] Toolchains and CMAKE_FORCE_C_COMPILER in 3.5

James Crosby James.Crosby at arm.com
Mon Feb 15 12:47:24 EST 2016


Hi Brad,

For context, I'm the maintainer of yotta (github: ARMmbed/yotta), a
module system primarily for cross-compiled embedded software, which
uses CMake for the build.

> Basically CMake now needs to detect a lot more from the compiler than
> we can expect a caller to provide in a CMAKE_FORCE_C_COMPILER call.
> We need to make the compiler detection work for everyone.

I'm worried that built-in compiler detection might not be possible across
the variety of cross-compilers used. In some cases, for example, the
existence of a particular compiler, or a modified version of it, might be
a secret outside of the company using it.

> For linking the actual binaries during your build you must have some
> linker scripts.  Perhaps we should provide a way for the toolchain
> file to specify a linker script to use for try_compile checks.  That
> would then be used during the check for a working compiler, ABI check,
> and later try_compile checks to allow them to work as normal but still
> represent the real target platform.  Might that work for this use case?

This could work, but it may be necessary to specify arbitrary flags, and
the format of the link command not just a link script to get a link step to
succeed.

Since the link script that people are actually using to build their program
might contain assertions about the things being linked, or reference
symbols which need to have been defined, it would need to be possible
to use a different link script at this point than in the actual
CMAKE_<LANG>_LINK_X commands.

Using a dummy link command to check that linking works seems to
undermine the purpose of checking in the first place, which suggests
that perhaps it should still be possible to skip the check?

Best regards,
James





IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.



More information about the CMake mailing list