Out-of-Tree Source Libraries

Hi all,

I’m currently developing a solution to include an out-of-tree source-based library into a project.

Say I have a global library source folder “/home/test/Coding/libx” with many different components/parts which a would like to compile/link into my project “/home/test/Coding/project_y” as separate targets. The project (or every project using this source libarary libx) has some header files which customizes the library during compile-time and they should be included for building the library. The library “libx” is a microcontroller HAL/Base-Library and is included in many projects.

What I have currently is a set of cmake modules which I include into the projects, the source directory and the config include directory are passed to functions which create the final targets. I am asking myself whether this is the correct or agnostic way of doing this. This approach has the problem, that since the source files are added with absolute paths, the corresponding binary dirs also include them, which lead to quite some confusion and errors.

Do you have another Idea? I was also thinking about create a CMakeLists.txt file in the libx folder and use the fetch content module to include it into the project. The problem here is, that I have currently no access to add the CMakeLists.txt file to the distribution, so the user would have to copy it there.