I'm working on a CMake toolchain file for the new LLVM/Clang based compiler from Texas Instruments (see ARM-CGT-CLANG-1).
CMake properly detects that it's a clang based compiler if I simply set CMAKE_C_COMPILER
to the correct path of the tiarmclang
binary.
Unfortunately, I've noticed that it does not set CMAKE_AR
, CMAKE_NM
, CMAKE_READELF
and CMAKE_STRIP
correctly.
I've went through some of the modules included with CMake, including CMakeDetermineCCompiler and CMakeFindBinUtils.
What I get from that, is that CMakeDetermineCCompiler determines the _CMAKE_TOOLCHAIN_PREFIX
using a regular expression which expects a dash (-
) in front of clang
in the name of the compiler.
This _CMAKE_TOOLCHAIN_PREFIX
is later on used in CMakeFindBinUtils to prefix the names of the tools.
Unfortunately, TI decided to not include a dash in the name, which I think is the root cause of CMake not being able to detect the bin utils.
I tried setting the _CMAKE_TOOLCHAIN_PREFIX
from the toolchain file, but this does not work (it is overwritten in the CMakeDetermineCCompiler module).
Is there a way to have CMake find the tools automatically, despite the wonky prefix? Or is setting the variables for each binutil by hand from the toolchain file the only workaround (which I'm doing at the moment)?
After some further investigation, it turns out that setting the correct prefix in the cache will result in the bin utils to be discovered correctly (at least the ones that are included in the TI toolchain):
set(_CMAKE_TOOLCHAIN_PREFIX "tiarm" CACHE INTERNAL "Toolchain prefix" FORCE)