Target with multiple interfaces

I want to implement a CMake-based build system for the following architecture:


As you can see: the Model component has two interfaces: ModelRead and ModelEdit.
What is the preferred way to implement this architecture?

  • Implementing ModelEdit and ModelRead as separate targets, e. g. STATIC libraries with target_include_directories set to PUBLIC? The Model component itself actually does not really exist as a dedicated target.
  • Implementing the Model component as a STATIC library with ModelEdit and ModelRead being INTERFACE libraries that target_link_libraries to the Model target and having INTERFACE include directories containing the public headers/functions? The directories containing the public headers/functions are target_include_directories with the PRIVATE keyword to the Model target.
  • Or maybe something completely different?

To keep things simple, targets can all be static libraries which are finally linked into an executable.

Thanks for your thoughts and ideas, Rainer

Is Model actually two libraries? If so, the first is the better one. If it is one library, I recommend the second (though I suspect you may need to do some tweaking on the target_include_directories(PRIVATE)).