We are trying to move our build system from GNU Make to CMake and have run into issues defining an unconventional part of our build. This pattern repeats itself multiple places, so it would be useful to write a function or macro (or several) to set this up.
First, we take a collection of C++ sources and compile them together with some set of dependencies to produce a generator. This much is easy to do via the usual add_executable
command.
Second, the generator is capable of producing multiple shared (sometimes static, controlled by command line args) libraries, along with their associated headers. We use LLVM to do this. It is run once for each library it is capable of producing.
This second part is what I’m having trouble defining. The libraries that are produced might have distinct usage requirements like defines, other library dependencies, etc. that would be nice to implement via INTERFACE
properties. But it isn’t clear to me how to use add_library
or similar to tell CMake about the generated library and also make sure the right command is run to generate it.