Use include paths extracted from an external source

Hello all,

I’m working on an embedded project built on top of IAR Embedded Workbench.

One of the tasks I’m working on here is adding unit tests that will be running in a host environment (Windows for the devs and Linux for CI). I’m using CMake as the build tool for this job.

One of the cumbersome things I want to deal with is the number of include paths specified in the IAR project. Each time tests or code are added, this include list grown within the IAR project and the top level CMakeLists.txt needs to be updated as well. I know this is not the CMake way of doing things, but well I have to treat the IAR project as the source of truth.

What I thought I might do is use a script, that I already have, to extract the include paths from the IAR project and use it with the include_directories command. Maybe use a custom target called includes.cmake or something that depends on the IAR project.

Would this work?
is there a better way to approach this?


Hi again,

Just a follow up with things I’ve tried. Any help would be appreciated.

So what I did was, create an interface target with the aim of updating the include paths using target_include_directories(). But the problem I have is, then

  1. I can’t create a custom command off that target
  2. Nor can I make the ewp file a dependency for this target

Next I tried creating a custom target. With this approach, I can’t link this target as a library for executable targets that require the include paths (not yet) specified in this target

The other hurdle I’m facing is, the only way I can capture the output of a commend is with execute_process(), but that doesn’t get executed during build time.

Right now it looks like there’s no way I can do what I want. Is there anything else someone can suggest?


Why would execute_process be insufficient? Do the paths change so much that rerunning CMake to find them on every configure (versus every build) insufficient?