[CMake] CMake 2.4 and OBJECT_DEPENDS and PROPERTIES GENERATED

Bill Hoffman bill.hoffman at kitware.com
Fri May 19 08:56:40 EDT 2006


Since this issue has come up in several posts (the chicken problem,
and the qt header file problem), I thought I would try to explain
how generated files work in  CMake 2.4.

In CMake 2.4, you should not have to specify OBJECT_DEPENDS, or even set
PROPERTIES GENERATED true. You should just make sure that the chain of 
inputs to outputs is complete.  Inputs are specified with DEPENDS or
MAIN_DEPENDENCY, and outputs are specified with OUTPUT.

custom_command1 DEPENDS foo OUTPUT bar    
custom_command2 DEPENDS bar OUTPUT car
custom_command3 DEPENDS car OUTPUT done.c
add_library(thing done.c)   

(foo is a file on the disk, bar is created from foo,
car is created from bar, done.c is created from car)

cmake will make sure the commands are run 1,2,3 so that done.c can
be created for use by the library thing.    A configured file
is really not a generated file, as it will be around by the time cmake
is run since the cmake run creates it.   The GENERATED status is used to
tell cmake about files that will not be created until the build process is
run.  Outputs of custom commands are automatically marked generated.  

OBJECT_DEPENDS was added for support of generated .h files.  However, in
CMake 2.4 its use is deprecated and all you need to do is put the .h file
in the list of sources.   In addition, you have to make sure that the directory
where the .h file will be is in the -I paths for the build.  INCLUDE_DIRECTORIES should
be used for that.

In summary OBJECT_DEPENDS and GENERATED should not be required in new projects based
on CMake 2.4.


-Bill



More information about the CMake mailing list