6

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}")
ichiwahato
  • 211
  • 1
  • 2
  • 15
  • Have you tried creating your own [CMake Toolchain file](https://cmake.org/cmake/help/v3.7/manual/cmake-toolchains.7.html)? We do something similar to the cross-compiling for Linux. Since we build for both the host and an embedded target, we specify the toolchain on the command line with `-DCMAKE_TOOLCHAIN_FILE=path/to/toolchain.cmake`. – John Szakmeister Jan 11 '17 at 11:34
  • `CMake cannot identify my compiler (TriCore_v6.0r1).` - Try to identify compiler in toolchain, by setting [CMAKE_C_COMPILER_ID](https://cmake.org/cmake/help/v3.7/variable/CMAKE_LANG_COMPILER_ID.html) variable. If none of indentification, listed in the doc, suits for your case, you may use any string. At least, this will omit compilation of `CMakeCCompilerId.c`, which is failed for you. – Tsyvarev Jan 11 '17 at 11:37
  • Welcome to StackOverflow. Can you please please add your toolchain file? Just from the output there seems to be something weird going on. If you really have to force the compiler using `SET(CMAKE_C_COMPILER_WORKS 1 CACHE INTERNAL "")` and `SET(CMAKE_CXX_COMPILER_WORKS 1 CACHE INTERNAL "")` does still work also with newer versions of CMake. – Florian Jan 11 '17 at 11:38
  • @Tsyvarev I set the variable `CMAKE_C_COMPILER_ID` to my own string, however `CMakeCCompilerId.c` compilation is still attempted and fails due to the `-Aa` flag. – ichiwahato Jan 11 '17 at 13:28
  • @jszakmeister, Yes I have a Toolchain file for this compiler which specifies the compiler install and ID etc. – ichiwahato Jan 11 '17 at 13:31
  • @Florian Thanks for the hint. Forcing the compiler with `SET(CMAKE_C_COMPILER_WORKS 1 CACHE INTERNAL "")` somehow makes CMake misidentify the compiler as GNU, `The C compiler identification is GNU 4.8.1` despite specifying the TASKING path in the toolchain file. I'll post the Toolchain file. – ichiwahato Jan 11 '17 at 13:37
  • Ok, you are then still missing to set `CMAKE_C_COMPILER_ID` to `ctc`. And one problem with your toolchain could be that you are prefixing some scripts before your compiler/linker calls. That's something normally added via [`RULE_LAUNCH_COMPILE`](https://cmake.org/cmake/help/latest/prop_gbl/RULE_LAUNCH_COMPILE.html) and [`RULE_LAUNCH_LINK`](https://cmake.org/cmake/help/latest/prop_gbl/RULE_LAUNCH_LINK.html) global properties. – Florian Jan 11 '17 at 14:52
  • And it looks like you are mixing environment variables with normal CMake variables. If you actually wanted to set/overwrite environment variables then you would have to call `SET(ENV{CC} "${CCPATH}/ctc/bin/cctc.exe")` and `SET(ENV{CXX} "${CCPATH}/ctc/bin/cctc.exe")`. – Florian Jan 11 '17 at 15:31
  • @Florian, Thanks! I didn't know about that - I updated my outermost `CMakeLists.txt` file to call the perl scripts. The GNU confusion was solved by adding the `CMAKE_C_COMPILER` variable to the toolchain file instead the cmake commandline call. It looks like cmake was re-called and didn't get this variable again. Compilation of the project is now starting, but still some problems. I am often receiving the notification that `Detecting C compiler ABI info - failed` – ichiwahato Jan 11 '17 at 15:50
  • @Florian And another possible symptom - receiving compile errors that some header files cannot be opened when scanning the dependencies of my project – ichiwahato Jan 11 '17 at 15:52

1 Answers1

8

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.

0xC0000022L
  • 20,597
  • 9
  • 86
  • 152
ichiwahato
  • 211
  • 1
  • 2
  • 15
  • set(CMAKE_C_COMPILER_FORCED TRUE) worked for me to stop compiler checks when i'm trying to cross compile MSP430 with the CGT (TI tools) instead of ti-gcc. I had a weird problem where find_library worked just fine for the initial cmake configure, but when it got the part where the compiler checks were occurring, the same find_library code didn't work. :( – jerrylogansquare Jul 12 '21 at 15:39