🎉 We're happy to announce new public releases 🎉

  • TriCore v6.2r2 Inspector v1.0r9 - A family of tools that provide an automated method for identifying toolset issues in compiled output code
Contact us to get access

Configure TriCore VX-toolset in CMake

01-Sep-2026

Prerequisite

CMake and its respective Generators

Make sure that CMake is installed on your system along with the respective Generators. This article considers the use of Ninja and Ninja Multi-Config generators.


1. Place the Generator executable, in this case, ninja.exe, in the ..\CMake\bin subdirectory.

For example, C:\Program Files\CMake\bin. 


2. Add the ..\CMake\bin subdirectory, which contains cmake.exe to your Windows System PATH environment variable. For example, C:\Program Files\CMake\bin. 


3. To verify that CMake is successfully installed, open the command prompt (cmd.exe) and use the command:


cmake --version


This displays the current version of CMake installed, as shown below:





Solution

This article assumes that you want to build a main.c source file located in the src directory.

For example, C:\Tricore_Projects\MyProject\src.


1. Create an options.txt file containing the C/C++ compiler flags in the MyProject\src directory. This use case considers the following compiler/assembler flags:


-Ctc39x
-v
-t
-O3
--fp-model=3
--default-near-size=0
-g
-Wa-gAhLS

Note that the above options are only defined for the C/C++ compiler and the assembler. Linker options should be defined in the CMakeLists.txt file.


2. Navigate to the project directory, in this case, C:\Tricore_Projects\MyProject\, and create a CMakeLists.txt file. Copy the following content into the file:


 # Set the minimum required version of CMake
cmake_minimum_required (VERSION "3.25.1")

#Set the system name to Generic
set(CMAKE_SYSTEM_NAME Generic)

# Set the C compiler to the location where TASKING VX-toolset is installed. Please keep in mind to use Control Program here. Do not use ctc directly
set(CMAKE_C_COMPILER "C:/Program Files/TASKING/TriCore v6.3r1/ctc/bin/cctc.exe" )

# Set the C++ compiler to to the location where TASKING VX-toolset is installed. Please keep in mind to use Control Program here. Do not use cptc directly
set(CMAKE_CXX_COMPILER "C:/Program Files/TASKING/TriCore v6.3r1/ctc/bin/cctc.exe" )

#Set the path to the options file relative to the source directory. These options will be passed to cctc
add_compile_options(-f ${CMAKE_SOURCE_DIR}/src/options.txt)

# Use LINKER: prefix to ensure options are passed directly to the linker. Options without the LINKER prefix will be passed to the control program which is used to invoke the linker..
add_link_options (

LINKER:-m

LINKER:-OtxycL

-Ctc39x

--fp-model=3

-v

)

# Set the project name
project("MyProject")

# Add an executable
add_executable("${PROJECT_NAME}" "src/main.c")

#End of CMakeLists.txt file


In the CMakeLists.txt file, make sure you use a forward slash in the path entries, as a backslash (/) won't work.


Also, note that the file uses two CMake built-in environment variables:

  • CMAKE_SOURCE_DIR, which points to the root directory of the CMake source tree, where the top-level CMakeLists.txt is located, and
  • PROJECT_NAME, which holds the name of the current project as defined by the project() command.

Make sure that the value of the common compiler/assembler flags is identical to the linker flags defined in the CMakeLists.txt file. For example,   --fp-model=3 & -Ctc39x in the above use case. These options are required to enable the control program, which is used to invoke the linker tool to select the matching Standard C and run-time libraries for the selected floating-point model and AURIX derivative.

3. Build with the generator.

  • Using the Ninja Generator

Navigate to the directory containing CMakeLists.txt and open a command prompt (cmd.exe) from that location. Once the command prompt is open, use the command:

cmake . -G Ninja -B build/

This command configures a CMake project using the Ninja build system and specifies the build directory. It also creates a directory named build, which contains CMake configuration files. 

To build your CMake project using the Ninja build system generator (see Tricore_Projects for more details), use the command:

cmake --build build

You will find the resulting .elf file in the /build directory.

  • Using the Ninja Multi-Config Generator

If you want to build your project using another generator, such as the Ninja Multi-Config Generator, first delete the build directory created using the Ninja Generator. Then, rebuild the project using the Ninja Multi-Config Generator by using the following command:

cmake . -G "Ninja Multi-Config" -B build/

Similar to the Ninja Generator, this command configures a CMake project using the Ninja Multi-Config build system, specifies the build directory, and creates a build directory containing CMake configuration files.

Build your CMake project using the Ninja Multi-Config build system generator by using the following command  (see Tricore_Projects for more details):

cmake --build build --config Debug

You can find the resulting .elf file in the /build/Debug directory.


More resources

Was this answer helpful?