MantisBT - CMake
View Issue Details
0014894CMakeCMakepublic2014-04-23 11:562015-06-11 08:56
Peter Kuemmel 
Peter Kuemmel 
normalminoralways
closedfixed 
Windows7
 
CMake 3.1 
0014894: Regression/Qt: cmake touches on each run moc_*.cxx_parameters
Reproduced with ninja on Windows:

- build CMake with Qt-GUI
- run cmake
- call "ninja -d explain" which shows that all moc_*.cxx_parameters files are touched
- all moc files are recompiled, all is new linked, this is very annoying
No tags attached.
Issue History
2014-04-23 11:56Peter KuemmelNew Issue
2014-04-23 12:47Peter KuemmelAssigned To => Stephen Kelly
2014-04-23 12:47Peter KuemmelStatusnew => assigned
2014-04-23 12:47Peter KuemmelNote Added: 0035763
2014-04-23 12:53Brad KingNote Added: 0035764
2014-04-24 03:58Stephen KellyNote Added: 0035767
2014-04-24 03:58Stephen KellyAssigned ToStephen Kelly => Peter Kuemmel
2014-04-24 05:23Peter KuemmelNote Added: 0035768
2014-04-24 05:23Peter KuemmelNote Added: 0035769
2014-04-24 05:23Peter KuemmelStatusassigned => resolved
2014-04-24 05:23Peter KuemmelFixed in Version => CMake 3.0
2014-04-24 05:23Peter KuemmelResolutionopen => fixed
2014-04-24 09:16Brad KingNote Added: 0035770
2014-04-24 09:21Brad KingStatusresolved => assigned
2014-04-24 09:21Brad KingResolutionfixed => open
2014-04-24 09:21Brad KingProduct VersionCMake 3.0 =>
2014-04-24 09:21Brad KingFixed in VersionCMake 3.0 =>
2014-04-24 09:40Stephen KellyNote Added: 0035771
2014-04-25 03:58Peter KuemmelNote Added: 0035777
2014-04-25 04:06Peter KuemmelNote Added: 0035778
2014-04-25 04:44Stephen KellyNote Added: 0035779
2014-04-25 06:38Peter KuemmelNote Added: 0035780
2014-04-25 07:37Stephen KellyNote Added: 0035781
2014-04-25 07:41Stephen KellyNote Added: 0035782
2014-04-25 07:51Stephen KellyNote Added: 0035783
2014-04-25 07:54Stephen KellyNote Added: 0035784
2014-04-25 08:50Peter KuemmelNote Added: 0035785
2014-04-25 08:59Brad KingNote Added: 0035786
2014-04-25 08:59Brad KingNote Edited: 0035786bug_revision_view_page.php?bugnote_id=35786#r1455
2014-04-25 09:51Stephen KellyNote Added: 0035787
2014-04-25 10:06Brad KingNote Added: 0035790
2014-04-25 12:30Peter KuemmelNote Added: 0035791
2014-04-29 10:39Stephen KellyNote Added: 0035801
2014-04-29 13:34Peter KuemmelNote Added: 0035805
2014-05-02 03:16Peter KuemmelNote Added: 0035813
2014-05-02 03:16Peter KuemmelStatusassigned => resolved
2014-05-02 03:16Peter KuemmelFixed in Version => CMake 3.0
2014-05-02 03:16Peter KuemmelResolutionopen => fixed
2014-11-03 08:37Robert MaynardNote Added: 0037128
2014-11-03 08:37Robert MaynardStatusresolved => closed
2015-06-11 08:56Brad KingFixed in VersionCMake 3.0 => CMake 3.1

Notes
(0035763)
Peter Kuemmel   
2014-04-23 12:47   
Introduced by "Qt4: Fix moc command dependencies for incremental build."
734df96f5ad3d47b3c7825715f0b524292aa6ede
(0035764)
Brad King   
2014-04-23 12:53   
Re 0014894:0035763: I suspect the files were always re-touched but before that commit there was no dependency on them.
(0035767)
Stephen Kelly   
2014-04-24 03:58   
The first thing that's needed is an http://www.sscce.org/ [^]

Can you create one? Is this Windows only?
(0035768)
Peter Kuemmel   
2014-04-24 05:23   
Any Qt program is good for reproducing. But I have not much time ATM.
(0035769)
Peter Kuemmel   
2014-04-24 05:23   
http://cmake.org/gitweb?p=stage/cmake.git;a=commitdiff;h=60dda7ff7b197afba2e3ba146f1ae4f04567c7ef [^]
(0035770)
Brad King   
2014-04-24 09:16   
Re 0014894:0035769: The write/read/compare sequence may not be clean due to windows newline conversions. It will be cleaner to use configure_file which automatically does replace-if-different.
(0035771)
Stephen Kelly   
2014-04-24 09:40   
I could not reproduce this with Linux or Windows.
(0035777)
Peter Kuemmel   
2014-04-25 03:58   
write/read/compare: using configure_file() would only complicate the code, in READ/WRITE iostreams are used in text mode, and the \n mapping to and from windows line ending is done automatically. Only when file(READ) is called with HEX the file is opened in binary mode.
(0035778)
Peter Kuemmel   
2014-04-25 04:06   
Is broken also on Linux.

To reproduce build cmake with -DBUILD_QtDialog=1, then call

cmake . && stat ./Source/QtDialog/moc_CMakeSetupDialog.cxx_parameters

and you see how the timestamps change.
(0035779)
Stephen Kelly   
2014-04-25 04:44   
stephen@hal:~/dev/src/cmake/ninja{master}$ ninja
ninja: no work to do.
stephen@hal:~/dev/src/cmake/ninja{master}$ cmake .
-- Configuring done
-- Generating done
-- Build files have been written to: /home/stephen/dev/src/cmake/ninja
stephen@hal:~/dev/src/cmake/ninja{master}$ ninja -d explain
ninja: no work to do.
stephen@hal:~/dev/src/cmake/ninja{master}$ cmake . && stat ./Source/QtDialog/moc_CMakeSetupDialog.cxx_parameters
-- Configuring done
-- Generating done
-- Build files have been written to: /home/stephen/dev/src/cmake/ninja
  File: ‘./Source/QtDialog/moc_CMakeSetupDialog.cxx_parameters’
  Size: 777 Blocks: 8 IO Block: 4096 regular file
Device: 806h/2054d Inode: 241685 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1000/ stephen) Gid: ( 1000/ stephen)
Access: 2014-04-24 09:32:19.507890645 +0200
Modify: 2014-04-24 09:32:08.435891108 +0200
Change: 2014-04-24 09:32:08.435891108 +0200
 Birth: -
stephen@hal:~/dev/src/cmake/ninja{master}$ cmake . && stat ./Source/QtDialog/moc_CMakeSetupDialog.cxx_parameters
-- Configuring done
-- Generating done
-- Build files have been written to: /home/stephen/dev/src/cmake/ninja
  File: ‘./Source/QtDialog/moc_CMakeSetupDialog.cxx_parameters’
  Size: 777 Blocks: 8 IO Block: 4096 regular file
Device: 806h/2054d Inode: 241685 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1000/ stephen) Gid: ( 1000/ stephen)
Access: 2014-04-24 09:32:19.507890645 +0200
Modify: 2014-04-24 09:32:08.435891108 +0200
Change: 2014-04-24 09:32:08.435891108 +0200
 Birth: -
(0035780)
Peter Kuemmel   
2014-04-25 06:38   
You use the cmake in PATH. Are you sure this calls the cmake build from master?

For instance, when I call cmake 2.8.9 the timestamps also does not change.
(0035781)
Stephen Kelly   
2014-04-25 07:37   
Yes, it is a recent build of cmake. Please create a smaller testcase than 'build cmake'.
(0035782)
Stephen Kelly   
2014-04-25 07:41   
Ah, it must not have been. I can reproduce it now.
(0035783)
Stephen Kelly   
2014-04-25 07:51   
Or rather, it was a recent cmake build, but the QtDialog was being built with Qt 5, which doesn't have that change in the macro yet, not Qt 4.
(0035784)
Stephen Kelly   
2014-04-25 07:54   
... which of course underscores why you should have created a standalone smaller testcase.
(0035785)
Peter Kuemmel   
2014-04-25 08:50   
I preferred fixing the bug.
(0035786)
Brad King   
2014-04-25 08:59   
Re 0014894:0035777: Using configure_file is *the* convention in CMake to do copy-if-different for file generation. The code is simply:

-    file(WRITE ${_moc_parameters_file} "${_moc_parameters}\n")
+    set(CMAKE_CONFIGURABLE_FILE_CONTENT "${_moc_parameters}")
+    configure_file("${CMAKE_ROOT}/Modules/CMakeConfigurableFile.in"
+      "${_moc_parameters_file}" @ONLY)


However, now that the parameters file timestamp really doesn't change, the Qt4Targets test fails its IncrementalMoc case because the ADD_DEF=1 rebuild adds a COMPILE_DEFINITIONS entry to the target but the code path taken in QT4_CREATE_MOC_COMMAND does not consider the target flags. Steve?

(0035787)
Stephen Kelly   
2014-04-25 09:51   
I think that file(GENERATE) needs to learn to not touch a file if the generate-time contents don't change.

That's in the other code branch though, so I'm surprised the test fails for you. I think I tried it and it passed (because Peters patch doesn't touch the other code branch). Also

 http://open.cdash.org/testSummary.php?project=1&name=Qt4Targets&date=2014-04-25 [^]

is green.
(0035790)
Brad King   
2014-04-25 10:06   
Re 0014894:0035787: The file(GENERATE) command could learn a COPY_IF_DIFFERENT option for this. However, when I run Qt4Targets locally the IncrementalMocBuild tree clearly takes the non-target code path and is not influenced by the ADD_DEF change.
(0035791)
Peter Kuemmel   
2014-04-25 12:30   
http://cmake.org/gitweb?p=stage/cmake.git;a=commitdiff;h=6a5bd7f0dacd96b66c294919fa5859ca12224d5f [^] ?
(0035801)
Stephen Kelly   
2014-04-29 10:39   
Peter, your patch introduces a failure in the Qt4Targets unit test. Could you have a look?

Thanks,
(0035805)
Peter Kuemmel   
2014-04-29 13:34   
I had a look at it but not really an idea how to fix it;

The test calls:

try_compile(RESULT
  "${CMAKE_CURRENT_BINARY_DIR}/IncrementalMocBuild"
  "${CMAKE_CURRENT_SOURCE_DIR}/IncrementalMoc"
  IncrementalMoc
  CMAKE_FLAGS -DADD_DEF=0 "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}")


and the macro calls get_directory_property(_defines COMPILE_DEFINITIONS) but -DADD_DEF=0 does not pop up as parameter. Where is it stored?
(0035813)
Peter Kuemmel   
2014-05-02 03:16   
The fix of this bug uncovers

http://public.kitware.com/Bug/view.php?id=14902 [^]
(0037128)
Robert Maynard   
2014-11-03 08:37   
Closing resolved issues that have not been updated in more than 4 months.