[CMake] multiple targets depending on generated file
Clinton Stimpson
clinton at elemtech.com
Tue Apr 5 12:22:02 EDT 2011
I'm looking at bug #11884
http://public.kitware.com/Bug/view.php?id=11884
And I've noticed there is a problem with depending on generated headers across
directories but not within the same directory.
For example:
# section A
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/out.h COMMAND ....)
add_executable(... ${CMAKE_BINARY_DIR}/out.h ...)
# section B
add_custom_command(OUTPUT out2.h COMMAND .. DEPENDS ${CMAKE_BINARY_DIR}/out.h)
add_executable(... out2.h ...)
If section A and B are in the same CMakeLists.txt, then there is no problem.
If they are in sibling directories, then building section B first will lead to
an error about out.h missing. A workaround involves the user of
add_dependencies() and/or a custom target.
Is this a bug in CMake? It seems there is enough information given that CMake
could notice the dependency. But maybe it can't quite do it because its a
separate directory? Maybe cmake can do the add_dependencies() automatically?
--
Clinton Stimpson
Elemental Technologies, Inc
Computational Simulation Software, LLC
www.csimsoft.com
More information about the CMake
mailing list