0

I am developing a code generator which outputs a CMake project from abstract description.

I was wondering if I could somehow integrate this generation step inside Cmake, so that if the description is changed, cmake will regenerate the CMakeLists.txt.

So, can I have CMakeLists.txt integrate rules to generate itself?

kutschkem
  • 7,826
  • 3
  • 21
  • 56
  • It would be tricky but try using a custom target that depends on the abstract description files and runs the tools to rewrite the CMakeLists.txt file and then runs cmake to rebuild the project files. You'll probable need to use the builtin variables to track the current project and build directories to know the correct location of where to place the files. – fdk1342 Apr 12 '19 at 14:44
  • Assuming you generate not a main `CMakeLists.txt`, but a file which is included into it (with `include()` or `add_subdirectory()`) it should be no problems with generation. As for requirement for regenerate `CMakeLists.txt` see that question: https://stackoverflow.com/questions/24246037/how-to-make-cmake-reconfiguration-depend-on-custom-file. – Tsyvarev Apr 12 '19 at 23:34

0 Answers0