2/29/2024 0 Comments Cmake set source file properties![]() cmake -build build -no-print-directory Source File Wildcards You can suppress this directory tracking using the –no-print-directory option on the build command line. When using subdirectories to organise source code the generated build commands print out each directory name as it is being processed. Target_include_directories(Application PRIVATE For example: target_include_directories(Application PRIVATEĭirectory locations are relative to the project root but we can use the CMAKE_SOURCE_DIR variable to reinforce this: add_executable(Application We don’t specify the header files as part of the source dependencies.Īlthough we never list the header files as part of the configuration (as discussed in previous blogs), we need to specify the directories to search for header files by adding entries to the target_include_directories() directive. Remember that CMake will scan the source files looking for dependencies to build a dependency tree for the source files and included header files. We just add these source files to the add_executable() definition: add_executable(Application logic controller ( controller.cpp and controller.h).hardware devices ( devices.cpp and devices.h). ![]() Let’s say we have two separate modules for our project: We can extend our list of source files for the target executable. You can find the complete configuration files in the GitHub project accompanying this blog. Set_target_properties(Application PROPERTIES The following is a simplified project configuration file where we have omitted the compiler and linker options as we are now concentrating on source code management: cmake_minimum_required(VERSION 3.16) So far, our example project has just used a single main.cpp source file, although the supporting GitHub projects use multiple source files to build a usable ELF image.įrom the previous blog, you may remember that, for our build, we use a separate toolchain file ( toolchain-STM32F407.cmake) and a project configuration file ( CMakeLists.txt). Managing Source FilesĪny non-trivial project will use separate source files to encapsulate different functional areas of the system. In our training courses, we have identified two shared subsystems: the bare metal code used to initialise the C/C++ run time system and a middleware layer consisting of a real-time operating system (RTOS).īefore we look at configuring subsystems, we’ll briefly discuss managing a project with multiple source and header files. In this blog post I will look at how to configure project source code, identify subsystems and use CMake to manage the build for each subsystem. In previous blog posts in this series ( Part 1 and Part 2), I looked at using CMake to configure a build for a cross compilation to target hardware such as the STM32F4 Series.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |