I want to have the same file produce different output files and have the same MAIN_DEPENDENCY.<br><br><span style="font-family: courier new,monospace;">project(&quot;My Prog&quot;)</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">cmake_minimum_required(VERSION 2.6)</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">add_custom_command(OUTPUT file1.obj</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">  MAIN_DEPENDENCY source.cpp</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">  COMMAND buildit -o file1.obj source.cpp</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">  COMMENT &quot;Making file1 from source&quot;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">  )</span><br style="font-family: courier new,monospace;">

<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">add_custom_command(OUTPUT file2.obj</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">  MAIN_DEPENDENCY source.cpp</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">  COMMAND buildit -o file2.obj source.cpp</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">  COMMENT &quot;Making file2 from source&quot;</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">  )</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">set_source_files_properties(file1.obj file2.obj</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">  PROPERTIES</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">  EXTERNAL_OBJECT true # This is an object file not to be compiled, but only be linked.</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">  GENERATED       true # Not an error if this file doesn&#39;t exist at the start of build.</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">  )</span><br style="font-family: courier new,monospace;">

<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">add_executable(prog1 source.cpp)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">add_executable(prog2 source.cpp)</span><br style="font-family: courier new,monospace;">

<br><br>In Visual Studio I see this:<br><br><span style="font-family: courier new,monospace;">Solution &#39;My Proj&#39;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">+ All Build</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">- prog1</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">  - Source Files</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">      source.cpp   -&gt; Outputs file1.obj</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    CMakeLists.txt</span><br style="font-family: courier new,monospace;">
<font style="font-family: courier new,monospace;" face="courier new,monospace">- prog2<br>
  - Source Files<br>
      source.cpp   -&gt; Outputs file1.obj instead of file2.obj<br>
    CMakeLists.txt<br>
</font><span style="font-family: courier new,monospace;">+ ZERO_CHECK    </span><br style="font-family: courier new,monospace;">
<br>Is it a limitation with Visual Studio or with CMake?<br><br>Note that if I add file1.obj and file2.obj to the project I get this:<br><br><span style="font-family: courier new,monospace;">Solution &#39;My Proj&#39;</span><br style="font-family: courier new,monospace;">


<span style="font-family: courier new,monospace;">+ All Build</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">- prog1</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">  - Source Files</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">      source.cpp     -&gt; Outputs file1.obj</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    CMakeLists.txt</span><br><font face="courier new,monospace">    file1.obj        -&gt; no custom build step</font><br style="font-family: courier new,monospace;">
<font style="font-family: courier new,monospace;" face="courier new,monospace">- prog2<br>  - CMake Rules<br>      file2.obj.rule -&gt; Outputs file2.obj<br>
  - Source Files<br>
      source.cpp     -&gt; Outputs file1.obj instead of file2.obj<br>
    CMakeLists.txt<br>    file2.obj        -&gt; no custom build step<br>
</font><span style="font-family: courier new,monospace;">+ ZERO_CHECK    </span><br style="font-family: courier new,monospace;">
<br>Thanks,<br>James<br>