<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>We're looking to use cmake on a project which has some dependencies which are not properly picked up by cmake's dependency scanner. I'm not looking to fix the scanner, because I feel the scanner is fundamentally broken:</div><div><br></div><div>In order to properly scan a file for dependencies, you need to either use the compiler specific dependency scanner [1][2], or implement a fully featured c preprocessor. You can't do a partial job like the current dependency scanner does. I'd encourage you to read "Recursive Make Considered Harmful" [3] which discusses the importance of creating correct dependency graphs (with neither missing, nor erroneous dependencies). I'll provide a few examples of where cmake's method is lacking:</div><div><br></div><div>1. #define ARCH x86</div><div> #define ASM_INCLUDE <ARCH/asm.h></div><div> #include ASM_INCLUDE</div><div> cmake adds a dependency on ASM_INCLUDE instead of x86/asm.h</div><div><br></div><div>2. #ifdef DEBUG</div><div> #include <debug_config.h></div><div> #else</div><div> #include <config.h></div><div> #endif</div><div> cmake adds a dependency on both debug_config.h and config.h</div><div> In a worst-case scenario here (one which our project has), this could generate circular dependencies which cause the build to fail.</div><div><br></div><div>3. #if 0</div><div> #include <nonexistantfile.h></div><div> #endif</div><div> cmake adds a dependency on nonexistantfile.h when it shouldn't have</div><div><br></div><div>My suggestion for a solution to this problem is to use the compiler specific dependency generation methods. This could be done cleanly by converting dependency generation into a plugin based system with plugins for all the supported compilers.</div><div><br></div><div>I would have (tried to) made these changes to cmake already, but since this is both a non-trivial change and an architectural change, I felt it necessary to get an ok from you before I changed anything. I'm not really willing to do the work if it won't be accepted upstream (and I'm not willing to use cmake if this doesn't get fixed).</div><div><br></div><div>Thanks for your time</div><div>Russell Harmon</div><div><br></div><div><span class="Apple-style-span" style="-webkit-text-decorations-in-effect: underline; "><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Courier; ">[1] <a href="http://gcc.gnu.org/onlinedocs/gcc-4.5.0/gcc/Preprocessor-Options.html#index-dependencies_002c-make-867">http://gcc.gnu.org/onlinedocs/gcc-4.5.0/gcc/Preprocessor-Options.html#index-dependencies_002c-make-867</a></div></span></div><div><span class="Apple-style-span" style="-webkit-text-decorations-in-effect: underline; ">[2] </span><span class="Apple-style-span" style="font-size: 12px; "><a href="http://msdn.microsoft.com/en-us/library/hdkef6tk.aspx">http://msdn.microsoft.com/en-us/library/hdkef6tk.aspx</a></span></div><div>[3] <a href="http://aegis.sourceforge.net/auug97.pdf">http://aegis.sourceforge.net/auug97.pdf</a></div></body></html>