[CMake] Why is this custom command run twice?

elizabeta petreska elizabeta.petreska at gmail.com
Wed Apr 28 05:33:03 EDT 2010


Hello

 I am using Visual Studio 2010 generator and cmake 2.8.1
The example code you show, does work with Visual Studio 2005 generator and
visual studio 2008 generator , but does not work with  Visual Studio 2010
generator, i.e
If I touch the ${PROJECT_BINARY_DIR}/generated.txt, the target is not built
anew.

Thanks




On Fri, Apr 23, 2010 at 8:59 PM, Brad King <brad.king at kitware.com> wrote:

> Aaron_Wright at selinc.com wrote:
> > This builds ok the first time, but then change the "generated.txt.in"
> > and run the build twice and the second time you'll see "Using
> > generated.txt" again, which I don't want to see. I've tried VS 2008 and
> > NMake, using CMake 2.8 and 2.8.1.
>
> I was able to reproduce this.  There is nothing wrong with the project
> that CMake generates in VS.  The problem seems to be with the windows
> filesystem timestamp granularity.  The code below changes the touch
> into a copy, and the problem goes away.
>
> The code can actually be simpler, too.  CMake 2.8 (and 2.6 I think)
> automatically handles relative output files with respect to the
> build tree.
>
> -Brad
>
>
> CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
> PROJECT(quick_test)
>
> ADD_CUSTOM_COMMAND(
>   OUTPUT generated.txt
>   COMMAND ${CMAKE_COMMAND} -E copy
>   ${PROJECT_SOURCE_DIR}/generated.txt.in
>   ${PROJECT_BINARY_DIR}/generated.txt
>   DEPENDS generated.txt.in
>  )
>
> ADD_CUSTOM_COMMAND(
>  OUTPUT generated_used.stamp
>  COMMAND ${CMAKE_COMMAND} -E copy
>    ${PROJECT_BINARY_DIR}/generated.txt
>    ${PROJECT_BINARY_DIR}/generated_used.stamp
>   DEPENDS generated.txt
>  COMMENT "Using generated.txt"
>  )
>
> ADD_CUSTOM_TARGET(${PROJECT_NAME} DEPENDS generated_used.stamp)
> _______________________________________________
> 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/20100428/a9b6309f/attachment.htm>


More information about the CMake mailing list