$ ls -R build/generated/
build/generated/:
test
build/generated/test:
MessageHeader.h Thing.h
I can then write a tiny CMake file pointing explicitly at this directory, which builds fine:
add_executable(Test src/test.cpp)
target_include_directories(Test PUBLIC build/generated)
What I want is to automate fetching the code generation tool, building it, and generating the headers for inclusion.
I’ve been fumbling around and come up with the below, which seems to fetch the repo OK but then not do anything (and, naturally, I get a build error about missing headers):
You cannot list a directory as the OUTPUT of a custom command. You should instead list the individual files produced by the run, and then add those files into the target you’re building. So effectively something like this:
That sucessully builds my code but I was hoping not to have to explicitly list the path to it in the custom command.
I’m probably misunderstanding something but I thought I might be able to access it via the target here. I tried passing it to the command like this but it complains:
-jar sbe::sbe-jar
Is there something I can add to the third-party CMake file to let me do this?