[Cmake] Generated header file

Andy Cedilnik andy . cedilnik at kitware . com
17 Oct 2003 13:02:18 -0400


Hello Ondrej,

This is described in Mastering CMake on page 82. In general what you do
is to add custom command which takes a source file and generates your
header file. Then you add a source file property (DEPENDS) to the source
file that includes header file and that is it.

Something like:

ADD_EXECUTABLE(foo foo.cxx)

ADD_CUSTOM_COMMAND(
  OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/bar.h
  DEPENDS foo
  COMMAND ${EXE_DIR}/foo
  ARGS ${CMAKE_CURRENT_BINARY_DIR}/bar.h)

SET_SOURCEFILES_PROPERTIES(zot.cxx PROPERTIES DEPENDS  
${CMAKE_CURRENT_BINARY_DIR}/bar.h)

			Andy

On Fri, 2003-10-17 at 12:09, Ondrej Svetlik wrote:
> I have a problem. I have one CMake project which generates a tool that 
> produces a header file. In the second CMake project I need to run the 
> tool before any other compilation is performed.
> 
> Can anybody help?
> 
> With regards
> 
> Ondrej Svetlik