[CMake] Question about add_custom_command
David Aldrich
David.Aldrich at EU.NEC.COM
Fri Sep 10 06:38:07 EDT 2010
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
More information about the CMake
mailing list