Re: [CMake] correct dependencies of update-if-different generated files?`

2013-09-19 Thread Matthew Woehlke

On 2013-07-29 19:02, Matthew Woehlke wrote:

Let's say¹ I have a code generation tool, 'gen', that I am naïvely using
to build a library, like so:

add_custom_command(
   OUTPUT a.cpp b.cpp
   COMMAND gen in.xml
   DEPENDS in.xml
)
add_library(foo a.cpp b.cpp)

Now let's say that 'gen' is clever and does not overwrite the output
files with identical content (sort-of like configure_file).

Now, if in.xml is changed, the 'gen' command will run every time because
the mtime of in.xml is newer than that of a.cpp and b.cpp.

BUT... this "only" affects gmake (at least, it does not affect ninja²
and reportedly does not affect VS).

Has anyone run into this before, and/or is there a way to express the
build rules so that the build will completely converge (will not execute
any commands) *without* unnecessarily recompiling the generated source
files?

And, since I don't believe that there is, how would folks feel about
improving add_custom_command to specifically handle this case? I think
in pure make it is possible to solve the problem by having the custom
command also update a sentinel file on successful completion, and doing
like:

a.cpp b.cpp: sentinel
   # No command here!

sentinel: in.xml
   gen in.xml
   touch sentinel

Such an enhancement would also be desirable as it would allow
'automatic' adjusting of the build rules for generators that have the
problem with only a minor change to the CMake rules, and without
penalizing generators that are more clever.

(¹ Original/actual code where I ran into this:
https://codereview.qt-project.org/61497)

(² Ninja is not affected because it records the last time it updated the
output files independent of their mtime.)


bump?

--
Matthew

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] correct dependencies of update-if-different generated files?`

2013-08-06 Thread Matthew Woehlke

On 2013-07-29 19:02, Matthew Woehlke wrote:

Let's say¹ I have a code generation tool, 'gen', that I am naïvely using
to build a library, like so:

add_custom_command(
   OUTPUT a.cpp b.cpp
   COMMAND gen in.xml
   DEPENDS in.xml
)
add_library(foo a.cpp b.cpp)

Now let's say that 'gen' is clever and does not overwrite the output
files with identical content (sort-of like configure_file).

Now, if in.xml is changed, the 'gen' command will run every time because
the mtime of in.xml is newer than that of a.cpp and b.cpp.

BUT... this "only" affects gmake (at least, it does not affect ninja²
and reportedly does not affect VS).

Has anyone run into this before, and/or is there a way to express the
build rules so that the build will completely converge (will not execute
any commands) *without* unnecessarily recompiling the generated source
files?

And, since I don't believe that there is, how would folks feel about
improving add_custom_command to specifically handle this case? I think
in pure make it is possible to solve the problem by having the custom
command also update a sentinel file on successful completion, and doing
like:

a.cpp b.cpp: sentinel
   # No command here!

sentinel: in.xml
   gen in.xml
   touch sentinel

Such an enhancement would also be desirable as it would allow
'automatic' adjusting of the build rules for generators that have the
problem with only a minor change to the CMake rules, and without
penalizing generators that are more clever.

(¹ Original/actual code where I ran into this:
https://codereview.qt-project.org/61497)

(² Ninja is not affected because it records the last time it updated the
output files independent of their mtime.)


No comments?

--
Matthew

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

[CMake] correct dependencies of update-if-different generated files?`

2013-07-29 Thread Matthew Woehlke
Let's say¹ I have a code generation tool, 'gen', that I am naïvely using 
to build a library, like so:


add_custom_command(
  OUTPUT a.cpp b.cpp
  COMMAND gen in.xml
  DEPENDS in.xml
)
add_library(foo a.cpp b.cpp)

Now let's say that 'gen' is clever and does not overwrite the output 
files with identical content (sort-of like configure_file).


Now, if in.xml is changed, the 'gen' command will run every time because 
the mtime of in.xml is newer than that of a.cpp and b.cpp.


BUT... this "only" affects gmake (at least, it does not affect ninja² 
and reportedly does not affect VS).


Has anyone run into this before, and/or is there a way to express the 
build rules so that the build will completely converge (will not execute 
any commands) *without* unnecessarily recompiling the generated source 
files?


And, since I don't believe that there is, how would folks feel about 
improving add_custom_command to specifically handle this case? I think 
in pure make it is possible to solve the problem by having the custom 
command also update a sentinel file on successful completion, and doing 
like:


a.cpp b.cpp: sentinel
  # No command here!

sentinel: in.xml
  gen in.xml
  touch sentinel

Such an enhancement would also be desirable as it would allow 
'automatic' adjusting of the build rules for generators that have the 
problem with only a minor change to the CMake rules, and without 
penalizing generators that are more clever.


(¹ Original/actual code where I ran into this: 
https://codereview.qt-project.org/61497)


(² Ninja is not affected because it records the last time it updated the 
output files independent of their mtime.)


--
Matthew

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake