Why wouldn&#39;t having this:<div>// CMAKE_CXX_FLAGS = &#39;@CMAKE_CXX_FLAGS@&#39;<br><br></div><div>in the <a href="http://header.h.in">header.h.in</a> file at configure time solve the issue of recompiling if you change the compilation flags? If you change the flags, CMake will change header.h when it configures it...</div>
<div><br></div><div>Or this:<br></div><div>#if 0</div><div>CMAKE_CXX_FLAGS = &#39;@CMAKE_CXX_FLAGS@&#39;<br><div class="gmail_quote">#endif</div><div class="gmail_quote"><br></div><div class="gmail_quote">if you&#39;re worried about whether the flags contain something that might break a compiler if found on a comment line... (Like a \ at the end of the line...?)</div>
<div class="gmail_quote"><br></div><div class="gmail_quote">Am I missing something?</div><div class="gmail_quote"><br></div><div class="gmail_quote"><br></div><div class="gmail_quote"><br></div><div class="gmail_quote">On Wed, Dec 10, 2008 at 3:23 PM, James Bigler <span dir="ltr">&lt;<a href="mailto:jamesbigler@gmail.com">jamesbigler@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">In other projects in the past (using autoconf), this is what we did.<br>
We used header files with configured options in them. &nbsp;After switching<br>
to CMake we noticed that when using makefiles changing compile flags<br>
would recompile the appropriate files. &nbsp;Hurray! &nbsp;It wasn&#39;t until<br>
recently we started to make more VS projects and noticed that it<br>
didn&#39;t follow the same behavior.<br>
<br>
One possible solution to this would be to create dependency file at<br>
each level you specify a set of flags for (i.e.<br>
directories/targets/source file). &nbsp;Then for each source you add a<br>
dependency on that file to the appropriate set of dependency files.<br>
If a flag or something else changes that should trigger a recompile<br>
the corresponding dependency file would also change (configure_file<br>
mechanism perhaps if it is thread safe). &nbsp;This might get us most of<br>
the way there. &nbsp;The only reservation I would have would be the amount<br>
of extra file I/O involved, but perhaps it wouldn&#39;t be that bad.<br>
<br>
I imagine this would be a large undertaking for anyone to implement.<br>
<br>
It&#39;s unfortunate that VS recognizes when you change the settings from<br>
the IDE, but not if settings change after reloading though I can<br>
understand why it doesn&#39;t work.<br>
<br>
Well, the most reliable solution (for options) is to configure header<br>
files based on CMake options than to use compiler preprocessor<br>
definitions as you suggest. &nbsp;This doesn&#39;t solve the issue of not<br>
recompiling if you change compilation flags (i.e. CMAKE_CXX_FLAGS).<br>
<font color="#888888"><br>
James<br>
</font><div><div></div><div class="Wj3C7c"><br>
On Wed, Dec 10, 2008 at 7:27 AM, David Cole &lt;<a href="mailto:david.cole@kitware.com">david.cole@kitware.com</a>&gt; wrote:<br>
&gt; One way that might work would be to configure a header file that contains a<br>
&gt; string representing the options of interest.<br>
&gt; Then include that header file in *all* source files that you want to<br>
&gt; rebuild.<br>
&gt; When you change options in CMake and configure the header, it will only<br>
&gt; change if something has changed, and then it will trigger a rebuild of the<br>
&gt; source files that include it. For this to work reliably you&#39;d have to<br>
&gt; include that header in every source file in a given library or executable.<br>
&gt; I realize the downside of this approach, but it may work for your situation<br>
&gt; better than saying &quot;tell your developers to clean and rebuild everything<br>
&gt; when they change an ADD_DEFINITION&quot;....<br>
&gt;<br>
&gt; HTH,<br>
&gt; David<br>
&gt;<br>
&gt; On Wed, Dec 10, 2008 at 12:25 AM, Philip Lowman &lt;<a href="mailto:philip@yhbt.com">philip@yhbt.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; On Tue, Dec 9, 2008 at 1:08 PM, Philip Lowman &lt;<a href="mailto:philip@yhbt.com">philip@yhbt.com</a>&gt; wrote:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; This is a known problem. &nbsp;Visual Studio has no way of knowing that the<br>
&gt;&gt;&gt; compiler flags changed in a project file CMake is writing to.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; I would love to see a patch for this for CMake 2.8.<br>
&gt;&gt;<br>
&gt;&gt; One thought I had here was to have the &quot;vcbuild&quot; command clean any<br>
&gt;&gt; affected projects. &nbsp;This would have the advantage of isolating CMake from<br>
&gt;&gt; implementing any Visual Studio specific mods (i.e. delete these object files<br>
&gt;&gt; to force a recompilation, etc.). &nbsp;This would have some downsides though.<br>
&gt;&gt;<br>
&gt;&gt; 1. The easiest implementation would just be to perform the clean if a<br>
&gt;&gt; project file changes. &nbsp;This would result in more cleaning then necessary as<br>
&gt;&gt; changing source files (for example) shouldn&#39;t cause a rebuild. &nbsp;Certain<br>
&gt;&gt; project modifications like adding a source file to a target shouldn&#39;t cause<br>
&gt;&gt; a clean of that target.<br>
&gt;&gt;<br>
&gt;&gt; 2. Perhaps the biggest gotcha of all, &quot;cleaning&quot; a target would wipe out<br>
&gt;&gt; any binaries/libraries already generated. &nbsp;This is far different from the<br>
&gt;&gt; behavior of CMake&#39;s Makefile generator which simply causes targets to be<br>
&gt;&gt; rebuilt on the next &quot;make&quot;.<br>
&gt;&gt;<br>
&gt;&gt; Anyone have any ideas for fixing this? &nbsp;I&#39;ve been bit by this one before<br>
&gt;&gt; (forgetting to rebuild everything when I change a preprocessor definition at<br>
&gt;&gt; the global scope).<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; --<br>
&gt;&gt; Philip Lowman<br>
&gt;&gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; CMake mailing list<br>
&gt;&gt; <a href="mailto:CMake@cmake.org">CMake@cmake.org</a><br>
&gt;&gt; <a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
&gt;<br>
&gt;<br>
</div></div></blockquote></div><br></div>