[CMake] Problem added file dependency to a library.

Alexander Neundorf a.neundorf-work at gmx.net
Tue Mar 25 12:57:40 EDT 2008


On Tuesday 25 March 2008, Josef Karthauser wrote:
> Hi there,
>
>
>
> I'm having major woes trying to add a file dependency to a library, and
> was wondering if anyone can point me in the right direction.
>
>
>
> I have a library which depends upon an external object file, produced by
> a process outside of cmake.  I've created a custom target to fire that
> process off, which makes an object file, but I can't get the library to
> rebuild its target when that external object changes.
>
>
>
> What I'm trying to do is this:
>
>
>
>                 # Create the foo library target.
>
>                 ADD_LIBRARY(foo test.cpp)
>
>
>
>                 # Add rules to build the external object file
>
>                 SET(OUTFILE "${CMAKE_BINARY_DIR}/ext.obj")
>
>                 ADD_CUSTOM_TARGET(foo.external  COMMAND doit.bat
> ${OUTFILE})

I'd suggest use add_custom_command(OUTPUT .../ext.obj ... ) for that
and then add the object file to the source files for the library.

Does that work ?

Alex


More information about the CMake mailing list