- I'm having issues with the way CMake scans for dependencies. It's causing unpredictable rebuilds of my project which means I need to run 'make' multiple times (until nothing rebuilds) before I can 'sudo make install'.
- The project incorporates a code generator. It parses all C++ header files and produces .h and .cpp files, which are then built into the main program. The codegen and program both depend on a set of common utility files, which contain lines like this:
- #ifndef CODEGEN
- #include "GeneratedFile.h"
- From a compile standpoint, there is no problem -- the codegen is built with -DCODEGEN so it won't include the generated file, which of course wouldn't even exist on the first pass. But since CMake doesn't preprocess headers, it creates a circular dependency situation, where the code generator "depends" on files which it generates. This causes unnecessary rebuilds, since the code generator gets rebuilt after every time it regenerates files.
- I thought I could create a dummy "GeneratedFile.h" in the directory containing the codegen files, and put this into the CMakeLists.txt in that directory:
- That seemed to work the first time -- if I looked at the codegen's depend.make file I saw lines like "SomeUtilityFile.cpp.o: ..../codegen/GeneratedFile.h" -- the dummy version of the file.
- The problem is that CMake seems to have a global dependency cache, so once SomeUtilityFile.cpp gets built for the program, the dependency globally changes to the real GeneratedFile.h.
- Any ideas to make this work, or other ways I can work around the problem?
- Thank you
CMake mailing list question
a guest Oct 3rd, 2012 35 Never
RAW Paste Data