I want to cross compile an embedded application using Tasking TriCore toolchain and CMake (3.16 is ok).
I started with a complete toolchain file, where all paths to binaries and rules were specified, but then I read this thread and used the Compiler/IAR*
scripts as an example (https://github.com/Kitware/CMake/blob/master/Modules/Compiler) to end up with a cleaner way.
I know that by default in C/CXX projects, CMake tries to compile a simple test program CMakeCCompilerId.c
to detect the compiler id vendor and version. With IAR-DetermineCompiler.cmake I created my own Tasking-DetermineCompiler.cmake
which would used symbols defined by the ctc compiler. But even if this file is executed by CMake (syntax errors in there are detected) it does not seem to have any impact on the generated test source file.
This means that the default mechanism for compiler identification does not work for my compiler and I get the message "The C compiler identification is unknown". On my toolchain file I need to force the identification:
set(CMAKE_SYSTEM_NAME Generic)
# will load Platform/Generic.cmake under CMAKE_MODULE_PATH
# Normalize, convert Windows backslashes to forward slashes or CMake will crash
get_filename_component(TASKING_ROOT_PATH "$ENV{TASKING_TRICORE_PATH}" ABSOLUTE)
# Specify the compiler
# will load Platform/Generic-ctc.cmake CMAKE_MODULE_PATH
foreach (_prefix C CXX)
if ("${CMAKE_${_prefix}_COMPILER}" STREQUAL "")
set(CMAKE_${_prefix}_COMPILER "${TASKING_ROOT_PATH}/bin/cctc.exe")
endif()
# This is used only if we skip auto compiler identification
set(CMAKE_${_prefix}_COMPILER_ID "Tasking")
set(CMAKE_${_prefix}_COMPILER_VERSION "6.3.1r1")
# Skip compiler ID identification: use "Tasking"
set(CMAKE_${_prefix}_COMPILER_ID_RUN TRUE)
set(CMAKE_${_prefix}_COMPILER_FORCED TRUE)
endforeach()
# will load Compiler/Tasking.cmake under CMAKE_MODULE_PATH
# and Compiler/Tasking-FindBinUtils.cmake as well
So far, this is working but I would like to understand whether it is possible to use the default CMake way of identifying the compiler id and version. I could not find how to add other vendors in the documentation!
Many thanks