0

For background, my eventual hardware target is a custom ASIC with several MCUs and DSPs, and I need to make a single "boot" file from that.

Our codebase is modularized, and can support building each appropriate target for each processor. CMake is configured with the target architecture and output in ./build/. The CMake scripting handles choosing the right source files when a module has specific source files for a given processor and building the appropriate libraries and to executable images/elf files.

What I haven't quite resolved is how to have an 'uber' CMake project that builds each architecture, then takes the appropriate elf files from each architecture and incorporates them in the "bootfile" to be downloaded to the target. I want to make sure that when I change the source in one of the DSP source files, the affected libraries rebuild for that, and the executable rebuilds, then that executable triggers a rebuild of the bootimage generation. (or maybe the cortex image depends on a generated header file or something).

Can anybody point to some examples of something like this? Or maybe the appropriate CMake functions to use?

I know I can do it in bash/bat/powershell but I'd like to be able to do this so it integrates well with VSCode and the CMake Tools extension.

Russ Schultz
  • 2,545
  • 20
  • 22
  • 1
    In my experience, CMake is best used one configuration (compiler+compiler options+linker+architecture) at a time. If you have multiple, script that "above cmake" in something else. – KamilCuk Nov 17 '21 at 16:11
  • 3
    CMake configures a project for a **single** compiler and other toolchain-specific things. See e.g. [that question](https://stackoverflow.com/questions/9542971/using-cmake-with-multiple-compilers-for-the-same-language). So, for prepare a project for several architectures, you need to configure the project several times, each time into its own build directory. – Tsyvarev Nov 17 '21 at 16:28
  • @Tsyvarev , yes. I get that and I'm doing that. I'm now at the stage where I need to stitch the different pieces together and am hoping there's a CMake centric way of doing that. Maybe an upper level CMake project that does `ExternalProject_Add()` or somethinglike that. – Russ Schultz Nov 17 '21 at 16:44

0 Answers0