<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.&nbsp;#define ARCH x86</div><div>&nbsp;&nbsp; #define ASM_INCLUDE &lt;ARCH/asm.h&gt;</div><div>&nbsp;&nbsp; #include ASM_INCLUDE</div><div>&nbsp;&nbsp; cmake adds a dependency on ASM_INCLUDE instead of x86/asm.h</div><div><br></div><div>2. #ifdef DEBUG</div><div>&nbsp;&nbsp; #include &lt;debug_config.h&gt;</div><div>&nbsp;&nbsp; #else</div><div>&nbsp;&nbsp; #include &lt;config.h&gt;</div><div>&nbsp;&nbsp; #endif</div><div>&nbsp;&nbsp; cmake adds a dependency on both debug_config.h and config.h</div><div>&nbsp;&nbsp; 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>&nbsp;&nbsp; #include &lt;nonexistantfile.h&gt;</div><div>&nbsp;&nbsp; #endif</div><div>&nbsp;&nbsp; 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]&nbsp;<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]&nbsp;</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]&nbsp;<a href="http://aegis.sourceforge.net/auug97.pdf">http://aegis.sourceforge.net/auug97.pdf</a></div></body></html>