CMake Files#

This section provides additional details about using source control with CMake files.

  • PROJECTNAME.cmake and CMakePresets.json: These files should not be source-controlled because they are regenerated during project generation.

  • CMakeLists.txt: The CMakeLists.txt file is special in that users can—and should—make additions for source files, symbols, and settings they add to the project. If users make such changes, the file should be under source control. By default, include paths, symbols and compiler flags are applied only to added source files, not to the original project source files or software development kit (SDK) files. If these settings need to apply to the original project source files in the project root or to SDK files, use a text editor to add them to the project’s .slcp file. They will then be included in the PROJECTNAME.cmake file.

  • toolchain.cmake: This file is also special in that it is not updated by the project generator, so it is safe to modify. This file is important for portability between developers using different computers and operating systems. For maximum portability, all users should place the path to the slt command line tool on their system path. If this is done, slt is used to locate the tool paths referenced in this file. See Useful Paths for the location of slt.

If the slt path is not added to the system path, each user can define the environment variables ARM_GCC_DIR, POST_BUILD_EXE, and NINJA_EXE_PATH to maintain portability. Starting with the Simplicity Studio 6.1 release, the generated toolchain.cmake file is portable between users on the same operating system because environment variables are used to locate tools. As an alternative, users on different operating systems can merge their toolchain.cmake files to achieve portability across all supported operating systems.