[CMake] Bug? add_custom_command() ignores head file outputs

Rolf Eike Beer eike at sf-mail.de
Fri Aug 24 14:05:31 EDT 2012


Adam B wrote:
> 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:
> 
> 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.
> 
> Here's a simplified setup to reproduce the problem:
> 
> ---------project_dir/-----------
> 
>      CMakeLists.txt
>      hello.c
>      hello.h
>      update_hello_h.sh
> 
> --------CMakeLists.txt---------
> 
> cmake_minimum_required(VERSION 2.8)
> project(cmake_test)
> 
> set_directory_properties(PROPERTIES CLEAN_NO_CUSTOM ON)  #so hello.h never
> gets cleaned away

Who cares, noone builds in the source directory anyway, hm? ;)

> add_custom_command(OUTPUT hello.h COMMAND ./update_hello_h.sh DEPENDS
> update_hello_h.sh)
> 
> add_executable(hello hello.c)

Adding hello.h here may fix your problem.


Eike
-- 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120824/dfcf9cc2/attachment.pgp>


More information about the CMake mailing list