Embarcadero C++Builder: Transitive project dependencies and includes?

228 views Asked by At

Let's say I have such project dependencies:

  • SerialPortDemo (EXE) --> SerialPort (DLL) -> ByteIo (DLL).
  • XYZ-App (EXE) -> XYZ-Lib (DLL) -> ByteIo (DLL)

Each DLL project has two folders, include and src. include contains the public interface header(s) and src/ the implementation along with the non-public headers.

Being used to CMake's target_include_directories with its PUBLIC, PRIVATE and INTERFACE keywords, I'd like to tell the ByteIo project if and which directory its consumers have to add to their own list of include directories in order to use the ByteIo project. The same applies to the linked libraries - again, just like target_link_libraries in CMake.

Right now I am forced to add ByteIo's include directory manually to each and every project directly or indirectly depending on ByteIo's headers. For example, the class SerialPort in the SerialPort.dll project subclasses ByteIo defined in the ByteIo.ddl project and therefore the project SerialPortDemo.exe has to add the (public) include paths of both projects, ByteIo and SerialPort. Even for the tiny example above (SerialPortDemo, SerialPort, XYZ-App and XYZ-Lib) this is a huge waste of time and very error-prone.

Does not work:

  • Option sets: Too limited to be of use as the relative include path needs to change according to the location of the consumer project of a DLL project. The only workaround I could come up so far is to add full paths to the include path list in the option set - which is unacceptable.
  • Environment Variables: Not an acceptable solution, as it forces me to check out the projects on a very specific location and/or denies me the possibility to have the project checked out multiple times on the same machine.

Does Embarcadero C++Builder XE8 offer a sane, maintainable solution to this problem?

1

There are 1 answers

3
Remy Lebeau On

Right now I am forced to add ByteIo's include directory manually to each and every project directly or indirectly depending on ByteIo.

You only need to add it for projects that directly depend on ByteIo (SerialPort and XYZ-Lib). There is no reason for other projects (SerialPortDemo and XYZ-App) to have any reference to ByteIo at all.

Does Embarcadero C++Builder XE8 offer a solution to problem?

One thing that comes to mind is to create an Option Set that contains your shared settings, like the path to the ByteIo folders, and save it to an .optset file. Then you can apply that Option Set to each project as needed. You can import the .optset file directly into a project, overwriting its current configuration. Or you can create a reference to the .optset file so that multiple projects can share it.

If that does not work, you can always create a custom Environment Variable that points it at ByteIO's include folder, and then add that variable to the includes path of each project.