[CMake] Run/build custom command/target only when "input" files change

Rolf Eike Beer eike at sf-mail.de
Tue Mar 8 06:21:07 EST 2011


> foreach(in_file ${ARGN})
>
> ....
>
> ADD_CUSTOM_COMMAND(
>         OUTPUT ${IDL_OUTPUT_DIR}/${out_file}.h
>                 ${IDL_OUTPUT_DIR}/${out_file}.tlb
>         DEPENDS ${in_file}
>         COMMAND(${MIDL_EXECUTABLE} ${in_file} <insert other args here>
>         WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
> )
>
> ....
>
> endforeach()
>
> i'm using this to generate files from IDL files so i can neatly list them
> and because there is no way to set the working directory for the midl tool
> in cmake
>
> I didn't put the rest of the file here because it's on another computer
> and i had to copy this by writing it.
>
> from what i read in the "Mastering CMake" book, the DEPENDS thing should
> work.
>
> I'v had 2 variations to the value, with absolute path and with relative,
> neither work.
>
> I checked that they were correct by writing the value out with the
> 'message' command and by testing the path printed out.
>
> Did i miss something?

Providing us the CMake version you are using ;) There was some fixes to
that dependencies stuff in 2.8.4 so maybe it would "just work" then?

Eike


More information about the CMake mailing list