Main Content

Code Compilation Customization

Customize compilation stage of build process

If you install supported build tools, you can configure a build process that produces executable code after code generation. You can customize the compilation stage of the build process.

For the toolchain approach:

  • Using the target package, create custom CMake toolchain definitions.

  • Using a ToolchainInfo object, register and use a custom toolchain.

For the template makefile approach:

  • Customize a shipped template makefile.

  • Create and run a post-code-generation command.

  • Create and apply hook methods at specific points of the build process.

  • Customize generated makefiles for S-functions.


targetManage target hardware and build tool information


expand all

target.ToolchainCapture high-level information about toolchain
target.CMakeSpecify CMake installation for building generated code
target.CMakeBuildTypeDescribe CMake build type or build configuration
target.CMakeBuilder Configure how CMake builds generated code
target.CMakeCacheEntryConfigure a CMake cache entry
target.EnvironmentConfigurationConfigure system environment for toolchain
target.HardwareComponentSupportDescribe support for a hardware component


expand all

RTW.BuildInfoProvide information for compiling and linking generated code


expand all

addCompileFlagsAdd compiler options to build information
addDefinesAdd preprocessor macro definitions to build information
addIncludeFilesAdd include files to build information
addIncludePathsAdd include paths to build information
addLinkFlagsAdd link options to build information
addLinkObjectsAdd link objects to build information
addNonBuildFilesAdd nonbuild-related files to build information
addSourceFilesAdd source files to build information
addSourcePathsAdd source paths to build information
addTMFTokensAdd template makefile (TMF) tokens to build information
findBuildArgFind a specific build argument in build information
findIncludeFilesFind and add include (header) files to build information
getBuildArgsGet build arguments from build information
getCompileFlagsGet compiler options from build information
getDefinesGet preprocessor macro definitions from build information
getFullFileListGet list of files from build information
getIncludeFilesGet include files from build information
getIncludePathsGet include paths from build information
getLinkFlagsGet link options from build information
getNonBuildFilesGet nonbuild-related files from build information
getSourceFilesGet source files from build information
getSourcePathsGet source paths from build information
setTargetProvidesMainDisable inclusion of code generator provided (generated or static) main.c source file during build
updateFilePathsAndExtensionsUpdate files in build information with missing paths and file extensions
updateFileSeparatorUpdate file separator character for file lists in build information
codebuildCompile and link generated code



Library Names and Locations

CMake Toolchain Approach

ToolchainInfo Approach

Template Makefile Approach

S-Function Build