That's great. Thanks for your patience!

David

> -----Original Message-----
> From: cmake-boun...@cmake.org [mailto:cmake-boun...@cmake.org] On Behalf
> Of Michael Wild
> Sent: 10 September 2010 12:30
> To: David Aldrich
> Cc: cmake@cmake.org
> Subject: Re: [CMake] Question about add_custom_command
> 
> 
> On 10. Sep, 2010, at 12:38 , David Aldrich wrote:
> 
> > Hi Michael
> >
> > Thanks for your help. Please see question below.
> >
> >> CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR) PROJECT(GENDEP C)
> >> FILE(WRITE ${CMAKE_BINARY_DIR}/g.c "void g(void){}\n")
> >> ADD_CUSTOM_COMMAND(
> >>    OUTPUT ${CMAKE_BINARY_DIR}/f.c
> >>    COMMAND echo "void f(void){}" > ${CMAKE_BINARY_DIR}/f.c
> >>    DEPENDS ${CMAKE_BINARY_DIR}/g.c
> >>    VERBATIM)
> >> FILE(WRITE ${CMAKE_BINARY_DIR}/main.c "int main(void){f();return
> >> 0;}\n") ADD_EXECUTABLE(main main.c f.c)
> >>
> >> "f.c" is regenerated and, thus, "main" rebuilt if "g.c" is touched
> >> although it's not incorporated in "main".
> >
> > In my case, the dependencies of the f.c will be all the dependencies of
> main. i.e. if any source file contributing to the exe changes we must
> first regenerate f.c.
> >
> > Now our executable depends on many source files. I assume you are saying
> that I need to add the same list of dependencies to the ADD_CUSTOM_COMMAND.
> Can I specify a list of files further up in CMakeLists.txt so that I only
> need to enumerate the list once?
> >
> > Regards
> >
> > David
> 
> set(SRCS a.c b.c d.c e.c)
> 
> add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/f.c
>   COMMAND ...
>   DEPENDS ${SRCS}
>   COMMENT "Generating f.c"
>   VERBATIM)
> list(APPEND SRCS ${CMAKE_BINARY_DIR}/f.c)
> 
> add_executable(main ${SRCS})
> 
> 
> HTH
> 
> Michael
> 
> --
> There is always a well-known solution to every human problem -- neat,
> plausible, and wrong.
> H. L. Mencken

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to