Thanks for checking on this Brad.

-------------------------------------------------------------
Aaron Wright




From:
Brad King <brad.k...@kitware.com>
To:
aaron_wri...@selinc.com
Cc:
cmake@cmake.org, Michael Wild <them...@gmail.com>
Date:
04/23/2010 11:59 AM
Subject:
Re: [CMake] Why is this custom command run twice?
Sent by:
cmake-boun...@cmake.org



aaron_wri...@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

_______________________________________________
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

Reply via email to