CMake C 编译器识别失败

标签 c cmake windows64

最近将 CMake 从 2.8.1 更新到 3.7.1 版,运行良好。

更新需要删除已弃用的 CMAKE_FORCE_C_COMPILER工具链文件中的命令,该文件用于跳过对工作编译器的自动检查。

我试图设置变量,SET(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)跳过测试,但行为没有变化。

现在似乎需要检查,CMake 无法识别我的编译器 (TriCore_v6.0r1)。

错误信息:

The C compiler identification could not be found in "C:/Build/CMakeFiles/3.7.1/CompilerIdC/CMakeCCompilerId.elf"

The C compiler identification could not be found in "C:/Build/CMakeFiles/3.7.1/CompilerIdC/CMakeCCompilerId.map"

The C compiler identification could not be found in "C:/Build/CMakeFiles/3.7.1/CompilerIdC/CMakeCCompilerId.mdf"

The C compiler identification could not be found in "C:/Build/CMakeFiles/3.7.1/CompilerIdC/CMakeCCompilerId.o"

Compiling the C compiler identification source file "CMakeCCompilerId.c" failed. Compiler: C:/TASKING/TriCore_v6.0r1/ctc/bin/cctc.exe Build flags: Id flags: -Aa



注意:根据用法,编译器不接受这个标志(-Aa)

The output was:

1

ctc E200: commandline: option "-A": invalid sub-option "a"

The C compiler identification could not be found in "C:/Build/CMakeFiles/3.7.1/CompilerIdC/CMakeCCompilerId.elf"

The C compiler identification could not be found in "C:/Build/CMakeFiles/3.7.1/CompilerIdC/CMakeCCompilerId.map"

The C compiler identification could not be found in "C:/Build/CMakeFiles/3.7.1/CompilerIdC/CMakeCCompilerId.mdf"

Checking whether the C compiler is IAR using "" did not match "IAR .+ Compiler":



理想情况下,我希望编译器能够被识别,但由于 Altium 不支持 CMake 工具,如果它解决了我的问题并允许我再次成功构建,我将决定跳过这些检查。

工具链文件:
#################################
# CMake Tool Chain File
# for TASKING Build Environment
#################################

# Deprecated!
# INCLUDE(CMakeForceCompiler)

# Skip CMake’s checks for a working compiler by omitting compilation of CMakeCCompilerId.c
# SET(CMAKE_C_COMPILER_ID "Tasking") 

# Try to force the compiler
SET(CMAKE_C_COMPILER_WORKS 1 CACHE INTERNAL "")
SET(CMAKE_CXX_COMPILER_WORKS 1 CACHE INTERNAL "")

# Use of "Generic", because target system is an embedded device
SET(CMAKE_SYSTEM_NAME Generic)
SET(CMAKE_SYSTEM_VERSION 1)
SET(can_use_assembler TRUE)

# Specify the cross compiler
SET(CCPATH $ENV{TASKING_PATH})
SET(CC "${CCPATH}/ctc/bin/cctc.exe")
SET(CXX "${CCPATH}/ctc/bin/cctc.exe")

SET(CMAKE_AR "${CCPATH}/ctc/bin/artc.exe" CACHE FILEPATH "Archiver")

# Deprecated! 
# Force CMake to use the specified cross compiler
# CMAKE_FORCE_C_COMPILER (${CC} ctc)
# CMAKE_FORCE_CXX_COMPILER (${CXX} ctc)


SET(CCVERBOSE "")

# Specify compiler call notation and compiler flags
SET(CMAKE_C_COMPILE_OBJECT "${CMAKE_CURRENT_SOURCE_DIR}/../../DevelopmentEnv/BuildEnv/BuildUtilities/bin/perl.exe ${CMAKE_CURRENT_SOURCE_DIR}/../../DevelopmentEnv/BuildEnv/BuildUtilities/compliation_manager.pl <CMAKE_C_COMPILER>  <DEFINES>  <FLAGS> -o <OBJECT> <SOURCE> -c")

# Specify linker call notation and linker flags
#SET(CMAKE_C_LINK_EXECUTABLE "<CMAKE_C_COMPILER> <OBJECTS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> -r -o <TARGET>")
#The Call to the perl script to manage the cross core linking, and will call the linker and scripts for updating the symbols
SET(CMAKE_C_LINK_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}/../../DevelopmentEnv/BuildEnv/BuildUtilities/bin/perl.exe ${CMAKE_CURRENT_SOURCE_DIR}/../../DevelopmentEnv/BuildEnv/BuildUtilities/linking_manager.pl -DListOfObjects <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> -o <TARGET>  -Wl--output=${PROJECT_NAME}.hex:IHEX:4,linear")

# search for programs in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)

# search for libraries and headers in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

#Commented as previously used for Greenhills
#SET (MAP_OPTIONS "-map=${PROJECT_NAME}.map -Ml -Mu -Mx -keepmap")

SET (CORE0_C_FLAGS ${CCVERBOSE} "-t --core=tc1.6.x --iso=90 --eabi-compliant --integer-enumeration --language=-comments,-gcc,+volatile,-strings --switch=auto --align=0 --default-near-size=0 --default-a0-size=0 --default-a1-size=0 -O2ROPYG --tradeoff=4 -g --source -DOS_TRICOREARCH=OS_TRICOREARCH_16EP -DOS_CPU=OS_TC29XT -DUSE_TASKING_INIT=1 -DCOMPILERCFG_EXTENSION_MCAL_FILE -D__TRICORE -DDEM_DONT_PROVIDE_LEGACY_SYMBOLIC_NAMES  -DTS_ARCH_FAMILY=TS_TRICORE -DTS_ARCH_DERIVATE=TS_TC29XT -DOS_KERNEL_TYPE=OS_SYSTEM_CALL -DOS_USE_TRACE=0 -DOS_USE_CLZ_QUEUE_ALGORITHM=1 -DOS_DEVELOPMENT_SANITY_CHECKS=0 -DOS_MEMORY_MODEL=OS_MM_DEFAULT -DOS_MEMMAP=0 -DOS_MULTICORE=OS_SINGLE -DOS_TRICORE_USED_CORE=0 -DOS_CPU=OS_TC29XT -DOS_TOOL=OS_tasking -DOS_ARCH=OS_TRICORE -DOS_RELEASE_SUFFIX=OS_AS403")
SET (CORE0_LINK_FILE "${CMAKE_CURRENT_SOURCE_DIR}/99_Env/LinkerScript/Core0-TRICORE-tasking.lsl")
SET (CORE0_LIB "${CMAKE_CURRENT_SOURCE_DIR}/01_Static/04_OS/Os_AS403/Lib/Os_c2038bfb98_kern_lib_SoRoooS0.a ${CMAKE_CURRENT_SOURCE_DIR}/01_Static/04_OS/Os_AS403/Lib/Os_ca2b8bdbb8_kern_lib_SoRoooS0.a ${CMAKE_CURRENT_SOURCE_DIR}/01_Static/04_OS/Os_AS403/Lib/Os_Extended_error_lib_SoRoooS0.a ${CMAKE_CURRENT_SOURCE_DIR}/01_Static/04_OS/Os_AS403/Lib/Os_Static_kern_lib_SoRoooS0.a ${CMAKE_CURRENT_SOURCE_DIR}/01_Static/04_OS/Os_AS403/Lib/Os_Static_user_lib_SoRoooS0.a")
SET (CORE0_LINK_FLAGS ${CCVERBOSE} "-lrt -lc -DCore=0 -Wl--define=PreLink=ON -I${CMAKE_CURRENT_SOURCE_DIR}/01_Static/01_App/boards/TriboardTC29XT ${CORE0_LIB} -Wl-OCLtxY -Wl--error-limit=0 --map-file-format=+lsl --library=fp_fpu -d ${CORE0_LINK_FILE}" )

SET (CORE1_C_FLAGS ${CCVERBOSE} "-t --core=tc1.6.x --iso=90 --eabi-compliant --integer-enumeration --language=-comments,-gcc,+volatile,-strings --switch=auto --align=0 --default-near-size=0 --default-a0-size=0 --default-a1-size=0 -O2ROPYG --tradeoff=4 -g --source -DOS_TRICOREARCH=OS_TRICOREARCH_16EP -DOS_CPU=OS_TC29XT -DUSE_TASKING_INIT=0 -DCOMPILERCFG_EXTENSION_MCAL_FILE -D__TRICORE -DDEM_DONT_PROVIDE_LEGACY_SYMBOLIC_NAMES  -DTS_ARCH_FAMILY=TS_TRICORE -DTS_ARCH_DERIVATE=TS_TC29XT -DOS_KERNEL_TYPE=OS_SYSTEM_CALL -DOS_USE_TRACE=0 -DOS_USE_CLZ_QUEUE_ALGORITHM=1 -DOS_DEVELOPMENT_SANITY_CHECKS=0 -DOS_MEMORY_MODEL=OS_MM_DEFAULT -DOS_MEMMAP=0 -DOS_MULTICORE=OS_SINGLE -DOS_TRICORE_USED_CORE=1 -DOS_CPU=OS_TC29XT -DOS_TOOL=OS_tasking -DOS_ARCH=OS_TRICORE -DOS_RELEASE_SUFFIX=OS_AS403")
SET (CORE1_LINK_FILE "${CMAKE_CURRENT_SOURCE_DIR}/99_Env/LinkerScript/Core1-TRICORE-tasking.lsl")
SET (CORE1_LIB "${CMAKE_CURRENT_SOURCE_DIR}/01_Static/04_OS/Os_AS403/Lib/Os_c203cbfb98_kern_lib_SoRoooS0.a ${CMAKE_CURRENT_SOURCE_DIR}/01_Static/04_OS/Os_AS403/Lib/Os_Extended_error_lib_SoRoooS0.a ${CMAKE_CURRENT_SOURCE_DIR}/01_Static/04_OS/Os_AS403/Lib/Os_Static_user_lib_SoRoooS0.a")
SET (CORE1_LINK_FLAGS ${CCVERBOSE} "-lrt -lc -DCore=1 -Wl--define=PreLink=ON -DSPM_PATH=${CMAKE_CURRENT_SOURCE_DIR}/01_Static/01_App/application/cvc/obj/ -I${CMAKE_CURRENT_SOURCE_DIR}/01_Static/01_App/boards/TriboardTC29XT ${CORE1_LIB} -Wl-OCLtxY -Wl--error-limit=0  --user-provided-initialization-code --library=fp_fpu -d ${CORE1_LINK_FILE}")

SET (CORE2_C_FLAGS ${CCVERBOSE} "-t --core=tc1.6.x --iso=90 --eabi-compliant --integer-enumeration --language=-comments,-gcc,+volatile,-strings --switch=auto --align=0 --default-near-size=0 --default-a0-size=0 --default-a1-size=0 -O2ROPYG --tradeoff=4 -g --source -DOS_TRICOREARCH=OS_TRICOREARCH_16EP -DOS_CPU=OS_TC29XT -DUSE_TASKING_INIT=0 -DCOMPILERCFG_EXTENSION_MCAL_FILE -D__TRICORE -DDEM_DONT_PROVIDE_LEGACY_SYMBOLIC_NAMES  -DTS_ARCH_FAMILY=TS_TRICORE -DTS_ARCH_DERIVATE=TS_TC29XT -DOS_KERNEL_TYPE=OS_SYSTEM_CALL -DOS_USE_TRACE=0 -DOS_USE_CLZ_QUEUE_ALGORITHM=1 -DOS_DEVELOPMENT_SANITY_CHECKS=0 -DOS_MEMORY_MODEL=OS_MM_DEFAULT -DOS_MEMMAP=0 -DOS_MULTICORE=OS_SINGLE -DOS_TRICORE_USED_CORE=2 -DOS_CPU=OS_TC29XT -DOS_TOOL=OS_tasking -DOS_ARCH=OS_TRICORE -DOS_RELEASE_SUFFIX=OS_AS403")
SET (CORE2_LINK_FILE "${CMAKE_CURRENT_SOURCE_DIR}/99_Env/LinkerScript/Core2-TRICORE-tasking.lsl")
SET (CORE2_LIB "${CMAKE_CURRENT_SOURCE_DIR}/01_Static/04_OS/Os_AS403/Lib/Os_c203cbfb98_kern_lib_SoRoooS0.a ${CMAKE_CURRENT_SOURCE_DIR}/01_Static/04_OS/Os_AS403/Lib/Os_Extended_error_lib_SoRoooS0.a ${CMAKE_CURRENT_SOURCE_DIR}/01_Static/04_OS/Os_AS403/Lib/Os_Static_user_lib_SoRoooS0.a ")
SET (CORE2_LINK_FLAGS ${CCVERBOSE} "-lrt -lc -DCore=2 -Wl--define=PreLink=ON -I${CMAKE_CURRENT_SOURCE_DIR}/01_Static/01_App/boards/TriboardTC29XT ${CORE2_LIB} -Wl-OCLtxY -Wl--error-limit=0 -Wl--user-provided-initialization-code  --library=fp_fpu -d ${CORE2_LINK_FILE}")

最佳答案

感谢所有回复的人!
正如@Florian 所建议的,可以通过设置变量来强制编译器

SET(CMAKE_C_COMPILER_WORKS TRUE CACHE INTERNAL "")
SET(CMAKE_CXX_COMPILER_WORKS TRUE CACHE INTERNAL "")
但是,我也注意到上面的变量是未设置 没有以下内容:
SET(CMAKE_C_COMPILER_FORCED TRUE CACHE INTERNAL "")
SET(CMAKE_CXX_COMPILER_FORCED TRUE CACHE INTERNAL "")
最后,需要设置另一对变量以防止尝试识别编译器:
SET(CMAKE_C_COMPILER_ID_RUN TRUE CACHE INTERNAL "")
SET(CMAKE_CXX_COMPILER_ID_RUN TRUE CACHE INTERNAL "")
但是,应该注意 Brad King 的评论 in this ticket :

Those toolchain files are setting internal CMake variables like

set(CMAKE_C_COMPILER_ID_RUN TRUE)
set(CMAKE_C_COMPILER_FORCED TRUE)
set(CMAKE_C_COMPILER_WORKS TRUE)

That is not supported because it causes CMake to skip its internal checks that are used to populate other internal settings. Any toolchain file that does that is taking responsibility for updating to set other internal variables as they are added.

关于CMake C 编译器识别失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41589430/

相关文章:

c++ - 以最佳方式从 system() 命令捕获标准输出

c++ - 在单个接口(interface)后面隐藏多个实现

c++ - 如何使用 Bamboo CI 处理 C++ CMake 项目之间的依赖关系?

c++ - 如何修复 CMake 中缺少的库错误?

java - 使用适用于 32 位和 64 位 Windows 的 log4j2 配置进行 Windows 事件日志记录

pip - 解决Windows上的Python 3.4安装问题

c - C标准库中有类似 `fcntl()`的函数吗?

c - scanf 函数不适用于字符

c - 32位计算机中long long整型的大小是多少?

c++ - `__m256` 的包装器使用构造函数产生段错误 - Windows 64 + MinGW + AVX 问题