MantisBT - CMake
View Issue Details
0015523CMakeCMakepublic2015-04-20 09:042016-02-01 09:10
Norbert Pfeiler 
Brad King 
normalminoralways
closedfixed 
 
CMake 3.3CMake 3.3 
0015523: ninja AUTORCC with AUTOGEN_TARGET_DEPENDS generated resources
With the changes from http://www.cmake.org/Bug/view.php?id=15459, [^]
using AUTOGEN_TARGET_DEPENDS to generate files to be added as resource by AUTORCC adds rcc error messages for the not-yet-existing files to the generated makefile.
try to build the attached test case with ninja
No tags attached.
related to 0015459closed Brad King autogen broken for ninja generator 
related to 0015520closed Kitware Robot AUTORCC fails with multiple .qrc files in the same target 
related to 0015644closed Brad King AUTORCC not generating files with Qt 5.1 
7z cmake_generated_resource_test.7z (664) 2015-04-20 09:04
https://public.kitware.com/Bug/file/5435/cmake_generated_resource_test.7z
Issue History
2015-04-20 09:04Norbert PfeilerNew Issue
2015-04-20 09:04Norbert PfeilerFile Added: cmake_generated_resource_test.7z
2015-04-20 10:00Brad KingRelationship addedrelated to 0015459
2015-04-20 10:01Brad KingNote Added: 0038547
2015-04-20 10:02Brad KingRelationship addedrelated to 0015520
2015-04-20 10:04Brad KingNote Added: 0038548
2015-04-20 10:06Brad KingNote Added: 0038549
2015-04-20 11:11Norbert PfeilerNote Added: 0038550
2015-04-20 11:32Brad KingNote Added: 0038551
2015-04-20 11:42Norbert PfeilerNote Added: 0038552
2015-04-20 11:43Brad KingNote Added: 0038553
2015-04-20 11:44Brad KingAssigned To => Stephen Kelly
2015-04-20 11:44Brad KingStatusnew => assigned
2015-04-20 11:45Norbert PfeilerNote Added: 0038554
2015-04-20 15:56Brad KingNote Added: 0038564
2015-04-20 16:06Norbert PfeilerNote Added: 0038565
2015-04-20 16:28Norbert PfeilerNote Edited: 0038565bug_revision_view_page.php?bugnote_id=38565#r1771
2015-04-20 16:30Brad KingNote Added: 0038566
2015-04-20 16:43Brad KingAssigned ToStephen Kelly => Brad King
2015-04-20 16:43Brad KingTarget Version => CMake 3.3
2015-04-21 09:38Brad KingNote Added: 0038572
2015-04-21 09:38Brad KingStatusassigned => resolved
2015-04-21 09:38Brad KingResolutionopen => fixed
2015-04-21 09:38Brad KingFixed in Version => CMake 3.3
2015-05-17 20:28Norbert PfeilerNote Added: 0038755
2015-07-09 11:50Brad KingRelationship addedrelated to 0015644
2016-02-01 09:10Robert MaynardNote Added: 0040401
2016-02-01 09:10Robert MaynardStatusresolved => closed

Notes
(0038547)
Brad King   
2015-04-20 10:01   
AFAIK this is impossible to implement correctly because Ninja does not support build-time detection of build rule outputs.
(0038548)
Brad King   
2015-04-20 10:04   
Related Ninja issue:

 https://github.com/martine/ninja/issues/760 [^]

Basically there is no way to have Ninja run rules and recognize that files on which other rules depend have changed unless they are explicitly listed as outputs of the rules that generate them. With generated files CMake has no way to know these outputs up front when generating the build.ninja file, and Ninja offers no way to tell it later.
(0038549)
Brad King   
2015-04-20 10:06   
Related thread on Ninja mailing list about build-time output detection:

 Adding Ninja features needed for Fortran
 https://groups.google.com/forum/#!topic/ninja-build/tPOcu5EWXio [^]
(0038550)
Norbert Pfeiler   
2015-04-20 11:11   
> With generated files CMake has no way to know these outputs up front when generating the build.ninja file

Isn’t the output explicitly specified in add_custom_command?

I’m not sure I follow…
The current issue is, that, instead of adding a dependency to a non-existing file for which a build rule exists, an error message is added.
It would even work if erroneous paths would not be added at all, because I add them via AUTOGEN_TARGET_DEPENDS explicitly.
(0038551)
Brad King   
2015-04-20 11:32   
Re 0015523:0038550: The problem is not the output of the custom command that generates the resources. The problem is the "cmake -E cmake_autogen" command that needs to run at the start of every build. That command may update several files as side effects that are also dependencies of later build rules. Ninja wants these to be listed as explicit outputs of the rule that runs cmake_autogen but we don't know these outputs until build time if the .qrc files are generated, and Ninja offers no facility to tell it later.
(0038552)
Norbert Pfeiler   
2015-04-20 11:42   
I’m not generating *.qrc files here. Just files which are listed inside of one.
(0038553)
Brad King   
2015-04-20 11:43   
Sorry, I jumped to the assumption that this issue is about generated .qrc files. The actual problem is that the warning message rcc generates about missing resource files is treated as a listed resource.

The problem is that the cmQtAutoGenerators methods use RunSingleCommand to run 'rcc --list' which merges its stdout/stderr together.
(0038554)
Norbert Pfeiler   
2015-04-20 11:45   
Under Windows 10 there are also messages about »untested Windows version 10 detected« which get listed there. I think this is the same issue.
(0038564)
Brad King   
2015-04-20 15:56   
With the attached cmake_generated_resource_test.7z I cannot get this to work even with the Unix Makefiles generator. Unless the generated file has already been created, on the first "make" I get:

make[2]: *** No rule to make target 'CMakeFiles/cmake_generated_resource_test.dir/qrc_resources.cpp', needed by 'CMakeFiles/cmake_generated_resource_test.dir/CMakeFiles/cmake_generated_resource_test.dir/qrc_resources.cpp.o'. Stop.
(0038565)
Norbert Pfeiler   
2015-04-20 16:06   
(edited on: 2015-04-20 16:28)
cmake --version && make --version && mkdir build && cd build && cmake .. && make
cmake version 3.2.20150420-g73ff2

CMake suite maintained and supported by Kitware (kitware.com/cmake).
GNU Make 4.1
Built for x86_64-unknown-linux-gnu
Copyright (C) 1988-2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> [^]
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
-- The C compiler identification is GNU 4.9.2
-- The CXX compiler identification is GNU 4.9.2
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/mobile/Downloads/cmake_generated_resource_test/build
Scanning dependencies of target cmake_generated_resource_test_automoc
[ 16%] Generating ../foo.txt
[ 33%] Automatic moc and rcc for target cmake_generated_resource_test
[ 33%] Built target cmake_generated_resource_test_automoc
Scanning dependencies of target cmake_generated_resource_test
[ 50%] Building CXX object CMakeFiles/cmake_generated_resource_test.dir/main.cpp.o
[ 66%] Building CXX object CMakeFiles/cmake_generated_resource_test.dir/cmake_generated_resource_test_automoc.cpp.o
[ 83%] Building CXX object CMakeFiles/cmake_generated_resource_test.dir/CMakeFiles/cmake_generated_resource_test.dir/qrc_resources.cpp.o
[100%] Linking CXX executable cmake_generated_resource_test
[100%] Built target cmake_generated_resource_test

(0038566)
Brad King   
2015-04-20 16:30   
In 0015523:0038564 I was testing a local change to cmQtAutoGenerators to separate stdout and stderr so that the rcc warning messages would be ignored. It turns out that cmQtAutoGenerators is depending on seeing the stderr lines to recognize the

 RCC: Error in '.../resources.qrc': Cannot find file 'foo.txt'

line and take that as a dependency.
(0038572)
Brad King   
2015-04-21 09:38   
Fixed and test added:

 QtAutogen: Process 'rcc --list' stdout and stderr separately
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=258ba828 [^]
(0038755)
Norbert Pfeiler   
2015-05-17 20:28   
I just want to add that the windows 10 thing i mentioned (http://www.cmake.org/Bug/view.php?id=15523#c38554 [^]) is fixed with this too.
(0040401)
Robert Maynard   
2016-02-01 09:10   
Closing resolved issues that have not been updated in more than 4 months.