[CMake] Visual Studio 2010 generator and custom command

elizabeta petreska elizabeta.petreska at gmail.com
Wed Sep 29 09:38:39 EDT 2010


If I use such a script for comparing time stamps of input and output files,
I would need to rewrite every cmakelists.txt that uses add_custom_command,
and execute the needed commands only if input file is older than output,or
maybe I did not understand you idea with the script.  This seems like a lot
of mess for something that cmake should do.

Also is anybody experiencing this issue with vs2010 generator ?
Can anybody confirm that this is bug with vs2010 generator, and maybe some
workaround ?

One more observation:
This problem seems to happen only when the output file goes to subdirectory
in PROJECT_BINARY_DIR, in the example the subdirectory is
PROJECT_BINARY_DIR/$(ConfigurationName).

If I put the generated file to go straight under PROJECT_BINARY_DIR than
everything works ok. Also if I put the generated files to go under
PROJECT_SOURCE_DIR or its subdirectories everything works well.

Thanks

On Wed, Sep 29, 2010 at 1:38 PM, Campbell Barton <ideasman42 at gmail.com>wrote:

> On Wed, Sep 29, 2010 at 10:02 AM, elizabeta petreska
> <elizabeta.petreska at gmail.com> wrote:
> > Hi,
> >
> > I asked this question some time ago in the mailing list. Unfortunately, I
> > did not try to resolve this issue since then, so I am trying again. :)
> >
> > I am using Visual Studio 2010 generator and cmake 2.8.2.
> >
> > Why the following custom command is runing all the time, although the
> input
> > dependency ( myfile.txt ) is not changed ? With Visual Studio 2005 it is
> > working ok.
> >
> > CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
> > PROJECT(quick_test)
> >
> > ADD_CUSTOM_COMMAND(
> >  OUTPUT "${PROJECT_BINARY_DIR}/$(ConfigurationName)/generated.txt"
> >  COMMAND ${CMAKE_COMMAND} -E copy
> >   "${PROJECT_SOURCE_DIR}/myfile.txt"
> >   "${PROJECT_BINARY_DIR}/$(ConfigurationName)/generated.txt"
> >  DEPENDS "${PROJECT_SOURCE_DIR}/myfile.txt"
> >  )
> > ADD_CUSTOM_TARGET(${PROJECT_NAME} DEPENDS
> > "${PROJECT_BINARY_DIR}/$(ConfigurationName)/generated.txt")
>
> Was just about to mail this list with the same problem, but using
> Makefiles on linux so its probably not build system spesific.
> Basically the command to generate always runs even if the inputs are
> older then the outputs.
>
> The only work around I can think of is to write a cmake script which
> is called rather then the generator directly, this cmake script can do
> the file comparisons to work out if generating the files is really
> needed, but would prefer if this wasnt needed.
> _______________________________________________
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100929/ca5b6ccc/attachment.htm>


More information about the CMake mailing list