[CMake] Why is this custom command run twice?

elizabeta petreska elizabeta.petreska at gmail.com
Fri Apr 30 05:28:53 EDT 2010


Hello

>>Can you create a VS project manually through the IDE in which
>>this works correctly?

I add custom build step manually through VS10 dialog for the following cmake
code , and it works as it should. But if I run this through cmake ( not
manually ) it does not work:

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_TARGET(${PROJECT_NAME} DEPENDS generated.txt)

What it seems odd is this :
If I change the name of the input file or the name od the output file , then
it does work with cmake too.

Maybe this just my imagination can not tell for sure. My guess is maybe this
has to do something that the output file ( generated.txt) is substring of
the input file ( generated.txt.in ).

Thank you






On Wed, Apr 28, 2010 at 6:52 PM, Brad King <brad.king at kitware.com> wrote:

> elizabeta petreska wrote:
> >  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.
>
> Can you create a VS project manually through the IDE in which
> this works correctly?
>
> -Brad
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100430/99e86302/attachment.htm>


More information about the CMake mailing list