[CMake] Unnecessary dependency building

Eric Bolz ebolz at mitre.org
Fri Oct 22 11:45:42 EDT 2004


I am using a CUSTOM_COMMAND to build a file, FT.c, from all my object files.
FT.c depends on all of the object files and nothing depends on FT.c, 
except the final binary target.
Here is the command.
ADD_CUSTOM_COMMAND(
    OUTPUT      ${CMAKE_BINARY_DIR}/FT.c
    DEPENDS    ${MY_OBJECTS}         # a list of all my object files
    COMMAND   buildFtable                    # a perl script
    ARGS           ${MYOBJECTS}           #  list of  all object files
)
ADD_EXECUTABLE( my_executable  ${MY_SOURCES} FT.c)

Everything works fine but cmake does an unnecessary build of the 
dependencies after the FT.c file is created.
Example, say I touch a source file, src.c:
1)  src.c is compiled into src.o
2)  FT.c is rebuild by the CUSTOM_COMMAND
3)  FT.c is compiled into a FT.o
4)  cmake rebuilds the dependencies.   WHY?
5)  My target is linked.

Step 4 is completely unnecessary.  Is there a way to eliminate this 
unnecessary and time consuming depndency build.
Is there a way to completely turn off dependency building so that I can 
type 'make depend' when I think it is necessary.

Eric





More information about the CMake mailing list