<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="" text="#000000">
    On 08/24/2012 11:09 AM, Andreas Pakulat wrote:
    <blockquote
cite="mid:CAExHGmS5Cz0Otxz74nbSh1mp+ASB2PNcoHJkpJAK3i+NZroEzA@mail.gmail.com"
      type="cite">
      <pre wrap="">Hi,

On Fri, Aug 24, 2012 at 7:27 PM, Adam B <a class="moz-txt-link-rfc2396E" href="mailto:adamb@videx.com">&lt;adamb@videx.com&gt;</a> wrote:
</pre>
      <blockquote type="cite">
        <pre wrap="">Hello all,

I'm relatively new to CMake but I've encountered some unexpected behavior.
Perhaps it's by design or perhaps it's a bug - you tell me.  The short story
is this:
</pre>
      </blockquote>
      <pre wrap="">
It is a bug, but not in CMake, its in your cmake code.

</pre>
      <blockquote type="cite">
        <pre wrap="">It appears that add_custom_command() is ignored if the only OUTPUT is a C
header file (.h).  The generated makefiles do not include the custom
command.  However, if I also list a C source file (.c) as a second output,
the makefiles get the command.
</pre>
      </blockquote>
      <pre wrap="">
If you look at the add_custom_command documentation you'll notice that
it says "if a target defined in the same directory depends on the
output of a custom command a dependency rule is set up so the custom
command runs before the target is being built" (slightly different
wording, written from the top of my head). Your target however only
has the .c file in its source list and hence nothing in your target
depends on an output of the custom command and hence no such rule is
set up. You can either include the .h file in the list of sources for
your target (CMake does not generate compile-rules for files it
recognizes as C/C++ headers), you can setup a custom target that
depends on the .h file and has some no-op as command and make your
executable depend on the custom target or (as you already did) have
the .c file in the output of the custom command.
</pre>
    </blockquote>
    The light comes on!&nbsp; Thanks for the detailed explanation, Andreas.&nbsp;
    Adding the .h file to the executable sources list did the trick.&nbsp;
    (And thank you Eike for suggesting that too.)<br>
    <br>
    <blockquote
cite="mid:CAExHGmS5Cz0Otxz74nbSh1mp+ASB2PNcoHJkpJAK3i+NZroEzA@mail.gmail.com"
      type="cite">
      <pre wrap="">
Andreas
</pre>
    </blockquote>
    <br>
  <BR />
<BR />
<HR />
Videx,&nbsp;Inc.&nbsp;|&nbsp;1105&nbsp;NE&nbsp;Circle&nbsp;Blvd.&nbsp;|&nbsp;Corvallis,&nbsp;OR&nbsp;97330&nbsp;|&nbsp;(541)&nbsp;738-5500<BR />
This&nbsp;email&nbsp;is&nbsp;intended&nbsp;only&nbsp;for&nbsp;the&nbsp;addressee(s)&nbsp;and&nbsp;may&nbsp;include&nbsp;material&nbsp;that&nbsp;is&nbsp;privileged,&nbsp;confidential,&nbsp;and&nbsp;protected&nbsp;from&nbsp;disclosure.&nbsp;&nbsp;No&nbsp;contract&nbsp;is&nbsp;intended.&nbsp;&nbsp;©2012&nbsp;Videx,&nbsp;Inc.<BR />
<BR />
</body>
</html>