<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  </head>
  <body bgcolor="" text="#000000">
    Hello all,<br>
    <br>
    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:<br>
    <br>
    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.<br>
    <br>
    Here's a simplified setup to reproduce the problem:<br>
    <br>
    ---------project_dir/-----------<br>
    <br>
        CMakeLists.txt<br>
        hello.c<br>
        hello.h<br>
        update_hello_h.sh<br>
    <br>
    --------CMakeLists.txt---------<br>
    <br>
    cmake_minimum_required(VERSION 2.8)<br>
    project(cmake_test)<br>
    <br>
    set_directory_properties(PROPERTIES CLEAN_NO_CUSTOM ON)  #so hello.h
    never gets cleaned away<br>
    <br>
    add_custom_command(OUTPUT hello.h COMMAND ./update_hello_h.sh
    DEPENDS update_hello_h.sh)<br>
    <br>
    add_executable(hello hello.c)<br>
    <br>
    ------------hello.c----------------<br>
    <br>
    #include &lt;stdio.h&gt;<br>
    #include "hello.h"<br>
    int main(int argc, char ** argv)<br>
    {<br>
        printf(HELLO_MSG "\n");<br>
        return 0;<br>
    }<br>
    <br>
    -----------hello.h----------------<br>
    <br>
    #define HELLO_MSG "Hello Fri Aug 24 09:01:53 PDT 2012"<br>
    <br>
    -------update_hello_h.sh-----<br>
    <br>
    #!/bin/sh<br>
    echo "#define HELLO_MSG" \"Hello `date`\" &gt; hello.h<br>
    <br>
    ----------------------------------<br>
    <br>
    What I would expect is for CMake to add a makefile rule to execute
    ./update_hello_h.sh if it's newer than hello.h.  No such rule gets
    generated.  However, if you add hello.c like so:<br>
    <br>
        add_custom_command(OUTPUT hello.h hello.c COMMAND
    ./update_hello_h.sh DEPENDS update_hello_h.sh)<br>
    <br>
    Then a rule gets generated.  Is this a bug or am I missing
    something?  I feel like I'm lying to CMake by telling it that
    hello.c is an output when it really isn't.<br>
    <br>
    I'm using CMake 2.8.0 on Ubuntu 10.04.<br>
    <br>
    Much thanks!<br>
    - Adam B.<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>