[CMake] Generated Source Files

Toralf Niebuhr niebuhr at niebuhrt.de
Sun May 1 05:16:26 EDT 2011


Hi.

I've got the following problem:

I've got a CMake Project with the following directory structure:

project/src
project/include
project/resources

In the directory project/resources/ is a file res.gen.
I have a command that generates res.cpp and res.h files from it.

I want the .cpp files to be compiled and linked to the library generated by CMake with the other source files.
I want the header files to be available such that my project can include them (so they need to be generated before compilation).
I also need a target that installs the header files into the proper install directory.
It should be possible to do this as out of source build, such that the generated files are not copied to the project/src and project/include directory.
If the res.cpp file changes, the generation command should be invoked again.

Basically before building the project, the script should generate the resource files if needed and than build the project as if the generated files are in project/src, project/include.

What would be the correct approach for this?


Thanks ahead

Toralf Niebuhr


More information about the CMake mailing list