I'm trying to add a custom command that takes one output and generates an additional output.<div><br></div><div>source1.cpp -> source1.obj</div><div>source2.cpp -> source2.obj</div><div>source1.obj + source2.obj -> 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'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'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've attached the zip file if anyone cares to take a look. Here's the CMake code inlines, in case mail systems eat the zip file. source1.cpp and source2.cpp don'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:'courier new',monospace">cmake_minimum_required(VERSION 2.8.0)</span></div><div><span style="font-family:'courier new',monospace">project(obj-translate)</span></div>
<div><span style="font-family:'courier new',monospace">set(s1 "${CMAKE_CURRENT_SOURCE_DIR}/source1.cpp")</span></div><div><span style="font-family:'courier new',monospace">set(s2 "${CMAKE_CURRENT_SOURCE_DIR}/source2.cpp")</span></div>
<div><span style="font-family:'courier new',monospace">set(o1 "${CMAKE_CFG_INTDIR}/source1${CMAKE_CXX_OUTPUT_EXTENSION}")</span></div><div><span style="font-family:'courier new',monospace">set(o2 "${CMAKE_CFG_INTDIR}/source2${CMAKE_CXX_OUTPUT_EXTENSION}")</span></div>
<div><span style="font-family:'courier new',monospace">set(temp "${CMAKE_CFG_INTDIR}/temp${CMAKE_CXX_OUTPUT_EXTENSION}")</span></div><div><span style="font-family:'courier new',monospace">add_custom_command(</span></div>
<div><span style="font-family:'courier new',monospace"> OUTPUT ${o1}</span></div><div><span style="font-family:'courier new',monospace"> MAIN_DEPENDENCY ${s1}</span></div><div><span style="font-family:'courier new',monospace"> COMMAND ${CMAKE_CXX_COMPILER} ${s1} -c "/Fo\"${o1}\""</span></div>
<div><span style="font-family:'courier new',monospace"> COMMENT "11111111111111 Making ${s1} -> ${o1}\n\n"</span></div><div><span style="font-family:'courier new',monospace"> )</span></div>
<div><span style="font-family:'courier new',monospace">add_custom_command(</span></div><div><span style="font-family:'courier new',monospace"> OUTPUT ${o2}</span></div><div><span style="font-family:'courier new',monospace"> MAIN_DEPENDENCY ${s2}</span></div>
<div><span style="font-family:'courier new',monospace"> COMMAND ${CMAKE_CXX_COMPILER} ${s2} -c "/Fo\"${o2}\""</span></div><div><span style="font-family:'courier new',monospace"> COMMENT "22222222222222 Making ${s2} -> ${o2}\n\n"</span></div>
<div><span style="font-family:'courier new',monospace"> )</span></div><div><span style="font-family:'courier new',monospace">add_custom_command(</span></div><div><span style="font-family:'courier new',monospace"> OUTPUT ${temp}</span></div>
<div><span style="font-family:'courier new',monospace"> DEPENDS ${o1} ${o2}</span></div><div><span style="font-family:'courier new',monospace"> COMMAND "${CMAKE_COMMAND}" -E copy "${o1}" "${temp}"</span></div>
<div><span style="font-family:'courier new',monospace"> COMMENT "TTTTTTTTTTTTTT Making ${o1} + ${o2} -> ${temp}\n\n"</span></div><div><span style="font-family:'courier new',monospace"> )</span></div>
<div><span style="font-family:'courier new',monospace">set_source_files_properties("${s1}" "${s2}"</span></div><div><span style="font-family:'courier new',monospace"> PROPERTIES</span></div>
<div><span style="font-family:'courier new',monospace"> HEADER_FILE_ONLY TRUE # Don't let VS compile this file</span></div><div><span style="font-family:'courier new',monospace"> )</span></div><div>
<span style="font-family:'courier new',monospace">set_source_files_properties("${o1}" "${o2}" "${temp}"</span></div>
<div><span style="font-family:'courier new',monospace"> PROPERTIES</span></div><div><span style="font-family:'courier new',monospace"> GENERATED TRUE # This file is generated during the build</span></div>
<div><span style="font-family:'courier new',monospace"> EXTERNAL_OBJECT TRUE # This is an object file not to be compiled, but only be linked.</span></div><div><span style="font-family:'courier new',monospace"> )</span></div>
<div><span style="font-family:'courier new',monospace">add_library(obj-translate STATIC</span></div><div><span style="font-family:'courier new',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>