[CMake] Why is this custom command run twice?

David Cole david.cole at kitware.com
Fri Apr 30 09:37:53 EDT 2010


Use full paths for all OUTPUT and DEPENDS args and try again.

i.e.
 OUTPUT ${PROJECT_BINARY_DIR}/generated.txt
 DEPENDS ${PROJECT_SOURCE_DIR}/generated.txt.in
ADD_CUSTOM_TARGET(${PROJECT_NAME} DEPENDS
${PROJECT_BINARY_DIR}/generated.txt)


Does it work then?


On Fri, Apr 30, 2010 at 5:28 AM, elizabeta petreska <
elizabeta.petreska at gmail.com> wrote:

> 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
>>
>
>
> _______________________________________________
> 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/20100430/dc75c55f/attachment.htm>


More information about the CMake mailing list