[CMake] [ADD_CUSTOM_COMMAND] How to add source dependences to
the target ouside of the command?
Brandon J. Van Every
bvanevery at gmail.com
Thu Aug 24 18:29:55 EDT 2006
Tristan Carel wrote:
>
> 1.
> ADD_DEPENDENCIES(wrapper.cxx foo.hh)
> it doesn't work because `foo.hh' is a source file, so not considered
> by CMake as a target.
Right.
>
> 2.
> INCLUDE(AddFileDependencies)
> ADD_FILE_DEPENDENCIES(foo.i foo.hh)
> It compiles but doesn't work and I don't understand why. It should
> generate something like:
My recollection is that ADD_FILE_DEPENDENCIES works only with source
files, is slated for removal, and is not recommended for use. If you
peruse the list archives, you'll see my posts relating to that.
I've not paid a great deal of attention to the specifics of your
problem. I don't have the brain cells for it right now. But what I
have generally done to resolve dependency difficulties, is to wrap the
ADD_CUSTOM_COMMAND with an ADD_CUSTOM_TARGET. Then I do
ADD_DEPENDENCIES on the custom target. The behavior of the latter is
far more predictable. I do this whenever I'm getting paranoid about my
dependencies being resolved, or whenever I have an actual build bug that
needs resolution. Example:
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/foo.c
[etc.]
)
ADD_CUSTOM_TARGET(foo_c
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/foo.c
)
ADD_EXECUTABLE(fanny
[etc.]
)
ADD_DEPENDENCIES(fanny foo_c)
Cheers,
Brandon Van Every
More information about the CMake
mailing list