[CMake] Using ADD_CUSTOM_COMMAND to generate sources...

Ken Martin ken.martin at kitware.com
Thu May 17 14:28:12 EDT 2007


Well CMake does not /really/ know about the dependency :) Because the
dependency is done through #include in the source code it is not known at
CMake Configure/Generate time. Dependency analysis of source code is done at
build time. For "make" based builds CMake does this during the build process
(because someone has to) and stores the results. The reason this is delayed
until build time is that the generated source code and possibly the
executables that run to generate it have to be generated before we can
inspect them for dependencies etc.

The typical way to setup dependencies on generated files is by adding them
(the generated files) to the target, for example:

add_library(libname src1.cxx generated1.h generated1.cxx generated2.h
generated3.h) 

Ken


Ken Martin PhD 
Kitware Inc.
28 Corporate Drive
Clifton Park NY 12065
518 371 3971 

-----Original Message-----
From: cmake-bounces+ken.martin=kitware.com at cmake.org
[mailto:cmake-bounces+ken.martin=kitware.com at cmake.org] On Behalf Of Matthew
Woehlke
Sent: Tuesday, May 15, 2007 11:46 AM
To: cmake at cmake.org
Subject: [CMake] Using ADD_CUSTOM_COMMAND to generate sources...

Ok... so I see that ADD_CUSTOM_COMMAND is silently ignored if no targets 
depend on the OUTPUT. What is strange is that the output is #include'd 
from one of my source files, and I can see from looking at the generated 
CMakeFiles/mytarget.dir/CXX.includecache that cmake /does/ know about 
the dependency. So why do I still have to explicitly tell CMake about 
the dependency? (This occurs even if the file is output to the source 
directory, i.e. the full path matches what is in the CXX.includecache.)

Also, what is the correct way to set up the dependency? I am using:

set_source_files_properties(main.cpp PROPERTIES OBJECT_DEPENDS 
${objects_def})

...but I seem to recall someone saying that this is deprecated?

-- 
Matthew
People say I'm going insane. I say, "what do you mean, 'going'?".

_______________________________________________
CMake mailing list
CMake at cmake.org
http://www.cmake.org/mailman/listinfo/cmake



More information about the CMake mailing list