[CMake] Generate headers and inherit include_directories

Nagy-Egri Máté Ferenc csiga.biga at aol.com
Tue Oct 3 09:54:22 EDT 2017


Hi!

I am a seasoned Cmake user but cannot solve a fairly simple problem, so I might be mistaking the forest for the trees.

I have a project in which there is a custom_command/custom_target pair that creates a header file as part of a (currently) header-only target. I want to create an imported target (or really, any kind of target), which is responsible for triggering header generation at build time AND relaying the include directory so consumers need not worry about the location where the generated header files go. My problem is:

- I cannot invoke target_include_directories on a custom_target
- Imported targets cannot have source files (for proper depending on the result header file)
- Imported targets cannot link to a custom_target
- Interface and Unkown libraries cannot be non-imported
- All other library types result in objects/libraries (which I don’t need)

How can I create the dependency graph where my custom_command is invoked if the inputs to it change (or if its output doesn’t exist yet) and depending targets are rebuilt accordingly AND I also inherit build properties (include directories)?

Cheers,
Máté
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20171003/f830ea36/attachment.html>


More information about the CMake mailing list