Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMake C compiler identification fails

Tags:

c

cmake

windows64

Recently updated CMake to version 3.7.1 from 2.8.1, which was working perfectly.

The update required the removal of the deprecated CMAKE_FORCE_C_COMPILER command from the toolchain file, which was used to skip the automatic check for a working compiler.

I tried to set the variable, SET(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) to skip the test, but there is no change in behaviour.

Now that the checks seem to be required, CMake cannot identify my compiler (TriCore_v6.0r1).


Error messages:

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

Note: according to the usage, the compiler doesn't accept this flag (-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":

Ideally I'd like the compiler to be recognised, but as Altium does not support the CMake tool, I'd settle for skipping these checks if it solves my problem and allows me to build successfully again.

Toolchain file:

#################################
# 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}")
like image 624
ichiwahato Avatar asked Jan 11 '17 11:01

ichiwahato


1 Answers

Thanks to everyone who replied!

As @Florian suggested, the compiler could be forced by setting the variables

SET(CMAKE_C_COMPILER_WORKS TRUE CACHE INTERNAL "")
SET(CMAKE_CXX_COMPILER_WORKS TRUE CACHE INTERNAL "")

However, I also noticed that the above variables are unset without the following:

SET(CMAKE_C_COMPILER_FORCED TRUE CACHE INTERNAL "")
SET(CMAKE_CXX_COMPILER_FORCED TRUE CACHE INTERNAL "")

Finally, another pair of variables needed to be set to prevent an attempt to identify the compiler:

SET(CMAKE_C_COMPILER_ID_RUN TRUE CACHE INTERNAL "")
SET(CMAKE_CXX_COMPILER_ID_RUN TRUE CACHE INTERNAL "")

However, it should be noted what Brad King remarks 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.

like image 129
ichiwahato Avatar answered Oct 21 '22 12:10

ichiwahato