I&#39;m trying to add a custom command that takes one output and generates an additional output.<div><br></div><div>source1.cpp -&gt; source1.obj</div><div>source2.cpp -&gt; source2.obj</div><div>source1.obj + source2.obj -&gt; temp.obj</div>

<div>link source1.obj source2.obj temp.obj</div><div><br></div><div>For VS 2008 and Makefiles, this works out just fine.  For VS 2010 it doesn&#39;t seem to understand that if source1.obj or source2.obj changes that it needs to run the temp.obj build rule.  The dependencies look correct in the project.</div>

<div><br></div><div>In a fresh build it builds source1.obj, source2.obj and temp.obj just fine.  In subsequent builds where source1.obj or source2.obj are compiled, it fails to build temp.obj on the first build command (as if it didn&#39;t understand that building source1.obj or source2.obj were a dependency for temp.obj).  On a subsequent build, MSbuild recognizes that source1.obj or source2.obj have changed and runs the build command for temp.obj.</div>

<div><br></div><div>I&#39;ve attached the zip file if anyone cares to take a look.  Here&#39;s the CMake code inlines, in case mail systems eat the zip file.  source1.cpp and source2.cpp don&#39;t have anything really useful in it.</div>

<div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><span style="font-family:&#39;courier new&#39;,monospace">cmake_minimum_required(VERSION 2.8.0)</span></div><div><span style="font-family:&#39;courier new&#39;,monospace">project(obj-translate)</span></div>

<div><span style="font-family:&#39;courier new&#39;,monospace">set(s1 &quot;${CMAKE_CURRENT_SOURCE_DIR}/source1.cpp&quot;)</span></div><div><span style="font-family:&#39;courier new&#39;,monospace">set(s2 &quot;${CMAKE_CURRENT_SOURCE_DIR}/source2.cpp&quot;)</span></div>

<div><span style="font-family:&#39;courier new&#39;,monospace">set(o1 &quot;${CMAKE_CFG_INTDIR}/source1${CMAKE_CXX_OUTPUT_EXTENSION}&quot;)</span></div><div><span style="font-family:&#39;courier new&#39;,monospace">set(o2 &quot;${CMAKE_CFG_INTDIR}/source2${CMAKE_CXX_OUTPUT_EXTENSION}&quot;)</span></div>

<div><span style="font-family:&#39;courier new&#39;,monospace">set(temp &quot;${CMAKE_CFG_INTDIR}/temp${CMAKE_CXX_OUTPUT_EXTENSION}&quot;)</span></div><div><span style="font-family:&#39;courier new&#39;,monospace">add_custom_command(</span></div>

<div><span style="font-family:&#39;courier new&#39;,monospace">  OUTPUT ${o1}</span></div><div><span style="font-family:&#39;courier new&#39;,monospace">  MAIN_DEPENDENCY ${s1}</span></div><div><span style="font-family:&#39;courier new&#39;,monospace">  COMMAND ${CMAKE_CXX_COMPILER} ${s1} -c &quot;/Fo\&quot;${o1}\&quot;&quot;</span></div>

<div><span style="font-family:&#39;courier new&#39;,monospace">  COMMENT &quot;11111111111111  Making ${s1} -&gt; ${o1}\n\n&quot;</span></div><div><span style="font-family:&#39;courier new&#39;,monospace">  )</span></div>

<div><span style="font-family:&#39;courier new&#39;,monospace">add_custom_command(</span></div><div><span style="font-family:&#39;courier new&#39;,monospace">  OUTPUT ${o2}</span></div><div><span style="font-family:&#39;courier new&#39;,monospace">  MAIN_DEPENDENCY ${s2}</span></div>

<div><span style="font-family:&#39;courier new&#39;,monospace">  COMMAND ${CMAKE_CXX_COMPILER} ${s2} -c &quot;/Fo\&quot;${o2}\&quot;&quot;</span></div><div><span style="font-family:&#39;courier new&#39;,monospace">  COMMENT &quot;22222222222222  Making ${s2} -&gt; ${o2}\n\n&quot;</span></div>

<div><span style="font-family:&#39;courier new&#39;,monospace">  )</span></div><div><span style="font-family:&#39;courier new&#39;,monospace">add_custom_command(</span></div><div><span style="font-family:&#39;courier new&#39;,monospace">  OUTPUT ${temp}</span></div>

<div><span style="font-family:&#39;courier new&#39;,monospace">  DEPENDS ${o1} ${o2}</span></div><div><span style="font-family:&#39;courier new&#39;,monospace">  COMMAND &quot;${CMAKE_COMMAND}&quot; -E copy &quot;${o1}&quot; &quot;${temp}&quot;</span></div>

<div><span style="font-family:&#39;courier new&#39;,monospace">  COMMENT &quot;TTTTTTTTTTTTTT  Making ${o1} + ${o2} -&gt; ${temp}\n\n&quot;</span></div><div><span style="font-family:&#39;courier new&#39;,monospace">  )</span></div>

<div><span style="font-family:&#39;courier new&#39;,monospace">set_source_files_properties(&quot;${s1}&quot; &quot;${s2}&quot;</span></div><div><span style="font-family:&#39;courier new&#39;,monospace">  PROPERTIES</span></div>

<div><span style="font-family:&#39;courier new&#39;,monospace">  HEADER_FILE_ONLY TRUE # Don&#39;t let VS compile this file</span></div><div><span style="font-family:&#39;courier new&#39;,monospace">  )</span></div><div>
<span style="font-family:&#39;courier new&#39;,monospace">set_source_files_properties(&quot;${o1}&quot; &quot;${o2}&quot; &quot;${temp}&quot;</span></div>
<div><span style="font-family:&#39;courier new&#39;,monospace">  PROPERTIES</span></div><div><span style="font-family:&#39;courier new&#39;,monospace">  GENERATED TRUE       # This file is generated during the build</span></div>

<div><span style="font-family:&#39;courier new&#39;,monospace">  EXTERNAL_OBJECT TRUE # This is an object file not to be compiled, but only be linked.</span></div><div><span style="font-family:&#39;courier new&#39;,monospace">  )</span></div>

<div><span style="font-family:&#39;courier new&#39;,monospace">add_library(obj-translate STATIC</span></div><div><span style="font-family:&#39;courier new&#39;,monospace">  ${s1} ${s2} ${temp} ${o1} ${o2}</span></div><div>

<font face="courier new, monospace">  )</font></div></blockquote><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

</blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><blockquote></blockquote></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<blockquote></blockquote></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><blockquote></blockquote>

</blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><blockquote></blockquote></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<blockquote></blockquote></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><blockquote></blockquote>

</blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><blockquote></blockquote></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<blockquote></blockquote></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><blockquote></blockquote>

</blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><blockquote></blockquote></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<blockquote></blockquote></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><blockquote></blockquote>

</blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><blockquote></blockquote></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<blockquote></blockquote></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><blockquote></blockquote>

</blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><blockquote></blockquote></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<blockquote></blockquote></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><blockquote></blockquote>

</blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><blockquote></blockquote></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<blockquote></blockquote></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><blockquote></blockquote>

</blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><blockquote></blockquote></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<blockquote></blockquote></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><blockquote></blockquote>

</blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><blockquote></blockquote></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<blockquote></blockquote></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><blockquote></blockquote>

</blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><blockquote></blockquote></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<blockquote></blockquote></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><blockquote></blockquote>

</blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><blockquote></blockquote></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<blockquote></blockquote></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><blockquote></blockquote>

</blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><blockquote></blockquote></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<blockquote></blockquote></blockquote><div><br></div></div>