[CMake] Two commands for a single dependency

James Bigler bigler at cs.utah.edu
Fri Aug 18 16:45:28 EDT 2006


Brandon J. Van Every wrote:
> James Bigler wrote:
>> Is it possible to run two commands and have them execute in order for 
>> a given rule.  Here is what I want to do in a makefile:
>>
>> default: child.o
>>
>> child-copy.d:
>>     touch child-copy.d
>>
>> include child-copy.d
>>
>> child.o: $(CXXPATH)/child.cc
>>     g++ -c $< -o $@ -MD
>>     cp child.d child-copy.d
> 
> Sure, just use ADD_CUSTOM_COMMAND.  Each COMMAND is executed in order.

So this would be this (for the last rule)?

ADD_CUSTOM_COMMAND(OUTPUT child.o
                    COMMAND g++
                    ARGS -c child.cc -o child.o -MD
                    DEPENDS ${CXXPATH}/child.cc
                    )

ADD_CUSTOM_COMMAND(OUTPUT child.o
                    COMMAND cp
                    ARGS child.d child-copy.d
                    DEPENDS ${CXXPATH}/child.cc
                    )

Thanks,
James


More information about the CMake mailing list