[CMake] file not generated with ADD_CUSTOM_COMMAND

Alexander Neundorf a.neundorf-work at gmx.net
Wed Jan 4 13:29:02 EST 2006


> Von: "William A. Hoffman" <billlist at nycap.rr.com> 
... 
> See the FAQ: 
>

http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_generate_a_source_file_during_the_build.3F

>  
> Generating a header file works similarly. Note that generated headers 
> can often cause unnecessary rebuilds and should be avoided if possible. 
> Consider using the CONFIGURE_FILE command to prepare the header at 
> CMake time. If you must generate a header file, use code like this:  
>  
>  ADD_CUSTOM_COMMAND( 
>    OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/foo.h 
>    COMMAND ${CMAKE_COMMAND} 
>    ARGS -E copy ${CMAKE_CURRENT_SOURCE_DIR}/bar.h 
>                 ${CMAKE_CURRENT_BINARY_DIR}/foo.h 
>    DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bar.h 
>    ) 
>  SET_SOURCE_FILES_PROPERTIES(foo.c PROPERTIES 
>    OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/foo.h) 
>  ADD_EXECUTABLE(foo foo.c) 
>  
> The generation of the header works similarly to the first example 
> above. Since the header does not exist at the time foo.c's dependencies 
> are scanned there is no way for CMake to know that it requires foo.h. 
> The OBJECT_DEPENDS source file property gives CMake this knowledge. 
> This custom command will automatically be placed in the generated build 
> system for any target using a source file with this OBJECT_DEPENDS 
> property.  
 
This might be problematic. 
The current FindQt4.cmake contains a macro QT4_WRAP_UI: 
 
SET(my_SRCS main.cpp widget.cpp foo.cpp) 
QT4_WRAP_UI(my_SRCS widgetform.ui) 
 
Now QT4_WRAP_UI generates a ui_widgetform.h from the ui-file and nothing 
else, i.e. no source file. This header contains a class (struct) with all 
function inlined. It is not known by which file it will be included, so 
that calling OBJECT_DEPENDS is not really possible. 
 
Wouldn't it be possible to detect during the dependency scanning that, 
although an included file doesn't exist, it can be generated by a 
ADD_CUSTOM_COMMAND and so its dependency can be added ? 
Or make this possible by adding ui_formwidget.h to the list of sources, 
and cmDependC.cxx would add non-existent files if they are in the list of 
the sources ? 
 
Bye 
Alex 
 
 

-- 
10 GB Mailbox, 100 FreeSMS/Monat http://www.gmx.net/de/go/topmail
+++ GMX - die erste Adresse für Mail, Message, More +++


More information about the CMake mailing list