1

我想使用Tasking TriCore工具链和 CMake(3.16 可以)交叉编译嵌入式应用程序。

我从一个完整的工具链文件开始,其中指定了二进制文件和规则的所有路径,但后来我阅读了这个线程并将Compiler/IAR*脚本用作示例(https://github.com/Kitware/CMake/blob/master/Modules/编译器)以更清洁的方式结束。

我知道在 C/CXX 项目中默认情况下,CMake 会尝试编译一个简单的测试程序CMakeCCompilerId.c来检测编译器 ID 供应商和版本。使用IAR-DetermineCompiler.cmake,我创建了自己的Tasking-DetermineCompiler.cmake,它将使用由 ctc 编译器定义的符号。但即使这个文件是由 CMake 执行的(检测到语法错误),它似乎对生成的测试源文件没有任何影响。

这意味着编译器标识的默认机制不适用于我的编译器,并且我收到消息“C 编译器标识未知”。在我的工具链文件中,我需要强制识别:

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

到目前为止,是可行的,但我想了解是否可以使用默认的 CMake 方式来识别编译器 ID 和版本。我找不到如何在文档中添加其他供应商!

非常感谢

4

0 回答 0