<div dir="ltr"><div><div>If you run "make help" it will list targets it understands.  And as you pointed out there is no target for foo.cc.  You can "make foo" but if you really want a target for foo.cc you can add one yourself:<br><br>cmake_minimum_required(VERSION 3.0.0)<br><br>project(custom-command-target)<br><br>add_custom_command (<br>  OUTPUT  foo.cc<br>  COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/genFoo > foo.cc<br>  )<br><br>add_custom_target(foo.cc DEPENDS ${CMAKE_BINARY_DIR}/foo.cc)<br><br>add_executable (foo foo.cc)<br><br></div>That should create a foo.cc target that you can run that will do the right thing.<br><br>--<br></div>Glenn<br></div><div class="gmail_extra"><br><div class="gmail_quote">On 12 June 2015 at 14:20, Dave Yost <span dir="ltr"><<a href="mailto:Dave@yost.com" target="_blank">Dave@yost.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>I’m not doing it wrong. Remember, this is a simplified example.</div><div><br></div><div>We want to be able to make <a href="http://foo.cc" target="_blank">foo.cc</a> so we can look at it and compare it. Yes, we could make foo and then look at <a href="http://foo.cc" target="_blank">foo.cc</a>, but until <a href="http://foo.cc" target="_blank">foo.cc</a> is right, we will suffer a lot of compiler error clutter. When <a href="http://foo.cc" target="_blank">foo.cc</a> looks right, then we will make foo.</div><div><br></div><div>BTW, changing add_custom_command to add_custom_target has no apparent effect and doesn’t help.</div><br><div><blockquote type="cite"><span class=""><div>On 2015-06-12, at 12:24 AM, Nagy-Egri Máté Ferenc <<a href="mailto:csiga.biga@aol.com" target="_blank">csiga.biga@aol.com</a>> wrote:</div><br></span><div><div dir="ltr" style="font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;font-family:Calibri,'Segoe UI',Meiryo,'Microsoft YaHei UI','Microsoft JhengHei UI','Malgun Gothic',sans-serif;font-size:12pt"><span class=""><div>You’re doing it all wrong. You do not name source files as make targets, but the target name (or project name, I have no idea, because it rarely makes sense to name them differently). Try simply “foo” or “custom-command-target”. You would never say “make foo.cpp”, not even in an ordinary GNU Make script.<br></div><div><br></div><div style="padding-top:5px;border-top-color:rgb(229,229,229);border-top-width:1px;border-top-style:solid"><div><font style="line-height:15pt;letter-spacing:0.02em;font-family:Calibri,'Segoe UI',Meiryo,'Microsoft YaHei UI','Microsoft JhengHei UI','Malgun Gothic',sans-serif;font-size:12pt" face=" 'Calibri', 'Segoe UI', 'Meiryo', 'Microsoft YaHei UI', 'Microsoft JhengHei UI', 'Malgun Gothic', 'sans-serif'"><b>Feladó:</b> <a href="mailto:Dave@Yost.com" target="_blank">Dave Yost</a><br><b>Elküldve:</b> ‎péntek‎, ‎2015‎. ‎június‎ ‎12‎. ‎2‎:‎00<br><b>Címzett:</b> <a href="mailto:cmake@cmake.org" target="_blank">cmake@cmake.org</a></font></div></div><div><br></div></span><div><div class="h5"><div dir=""><div>In this example, how do I get</div><div>   make<span> </span><a href="http://foo.cc/" target="_blank">foo.cc</a></div><div>to work?</div><div><br></div><div><div style="margin:0px;color:rgb(255,207,130);font-family:Menlo;font-size:9px;background-color:rgb(5,13,17)"><div style="margin:0px">0 Thu 16:56:19 yost DaveBook ~/p/c++/cmake/custom-command-target</div><div style="margin:0px;color:rgb(255,255,255)"><span style="color:rgb(255,207,130)">369 Z%<span> </span></span>bundle CMakeLists.txt genFoo</div><div style="margin:0px;color:rgb(255,255,255)">#!/usr/bin/env unbundle</div><div style="margin:0px;color:rgb(255,255,255)"># See<span> </span><a href="http://yost.com/computers/bundle/" target="_blank">http://yost.com/computers/bundle/</a></div><div style="margin:0px;color:rgb(255,255,255)">======== CMakeLists.txt</div><div style="margin:0px;color:rgb(255,255,255)">cmake_minimum_required(VERSION 3.3.0)</div><div style="margin:0px;color:rgb(255,255,255);min-height:10px"><br></div><div style="margin:0px;color:rgb(255,255,255)">project(custom-command-target)</div><div style="margin:0px;color:rgb(255,255,255);min-height:10px"><br></div><div style="margin:0px;color:rgb(255,255,255);min-height:10px"><br></div><div style="margin:0px;color:rgb(255,255,255)">add_custom_command (</div><div style="margin:0px;color:rgb(255,255,255)">  OUTPUT <span> </span><a href="http://foo.cc/" target="_blank">foo.cc</a></div><div style="margin:0px;color:rgb(255,255,255)">  COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/genFoo ><span> </span><a href="http://foo.cc/" target="_blank">foo.cc</a></div><div style="margin:0px;color:rgb(255,255,255)">  )</div><div style="margin:0px;color:rgb(255,255,255);min-height:10px"><br></div><div style="margin:0px;color:rgb(255,255,255)">add_executable (foo<span> </span><a href="http://foo.cc/" target="_blank">foo.cc</a>)</div><div style="margin:0px;color:rgb(255,255,255);min-height:10px"><br></div><div style="margin:0px;color:rgb(255,255,255)">======== genFoo</div><div style="margin:0px;color:rgb(255,255,255)">#!/bin/bash</div><div style="margin:0px;color:rgb(255,255,255);min-height:10px"><br></div><div style="margin:0px;color:rgb(255,255,255)">echo "</div><div style="margin:0px;color:rgb(255,255,255)">int main() {</div><div style="margin:0px;color:rgb(255,255,255)">  return 0;</div><div style="margin:0px;color:rgb(255,255,255)">}"</div><div style="margin:0px;color:rgb(255,255,255)">========</div><div style="margin:0px">0 Thu 16:56:23 yost DaveBook ~/p/c++/cmake/custom-command-target</div><div style="margin:0px;color:rgb(255,255,255)"><span style="color:rgb(255,207,130)">370 Z%<span> </span></span>cd build                                                </div><div style="margin:0px">0 Thu 16:56:36 yost DaveBook ~/p/c++/cmake/custom-command-target/build</div><div style="margin:0px;color:rgb(255,255,255)"><span style="color:rgb(255,207,130)">371 Z%<span> </span></span>cmake ..                                                </div><div style="margin:0px;color:rgb(255,255,255)">-- Configuring done</div><div style="margin:0px;color:rgb(255,255,255)">-- Generating done</div><div style="margin:0px;color:rgb(255,255,255)">-- Build files have been written to: /Users/yost/p/c++/cmake/custom-command-target/build</div><div style="margin:0px">0 Thu 16:56:41 yost DaveBook ~/p/c++/cmake/custom-command-target/build</div><div style="margin:0px;color:rgb(255,255,255)"><span style="color:rgb(255,207,130)">372 Z%<span> </span></span>make clean                                              </div><div style="margin:0px">0 Thu 16:56:45 yost DaveBook ~/p/c++/cmake/custom-command-target/build</div><div style="margin:0px;color:rgb(255,255,255)"><span style="color:rgb(255,207,130)">373 Z%<span> </span></span>make<span> </span><a href="http://foo.cc/" target="_blank">foo.cc</a>                                             </div><div style="margin:0px;color:rgb(255,255,255)">make: *** No rule to make target '<a href="http://foo.cc/" target="_blank">foo.cc</a>'.  Stop.</div><div style="margin:0px">2 Thu 16:56:49 yost DaveBook ~/p/c++/cmake/custom-command-target/build</div><div style="margin:0px">374 Z% </div></div></div></div></div></div></div></div></blockquote></div><br></div><br>--<br>
<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/cmake" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/cmake</a><br></blockquote></div><br></div>