MantisBT - CMake
View Issue Details
0015459CMakeCMakepublic2015-03-19 00:542015-11-02 09:13
Norbert Pfeiler 
Brad King 
normalmajoralways
closedfixed 
CMake 3.2.1 
CMake 3.3CMake 3.3 
0015459: autogen broken for ninja generator
Using automoc and autorcc,
cmake_autogen is only triggered when the resources change, leaving new or changed header files unprocessed.
Ironically (at least on linux) the target is now ›cmake_automoc‹ and not ›cmake_autogen‹ anymore.

Additionally on Windows all resources get assigned to »ident*« variables whose lines end with CRCRCRLF.
Ninja complains: »carriage returns are not allowed, use newlines«
The first 4 ident variables also only specify the source directory and no file
use automoc and autorcc with the ninja generator
on windows: can’t build in the first place due to ninja complaining
on linux or after fixing the newlines on windows:
build → remove a generated moc file → build again → fail
No tags attached.
related to 0015074closed Stephen Kelly Qt 5: resources aren't being updated when CMAKE_AUTORCC is used 
related to 0015523closed Brad King ninja AUTORCC with AUTOGEN_TARGET_DEPENDS generated resources 
7z cmake_autogen_test.7z (629) 2015-03-21 09:26
https://public.kitware.com/Bug/file/5410/cmake_autogen_test.7z
7z cmake_generated_resource_test.7z (664) 2015-04-18 14:51
https://public.kitware.com/Bug/file/5434/cmake_generated_resource_test.7z
Issue History
2015-03-19 00:54Norbert PfeilerNew Issue
2015-03-21 06:21Stephen KellyNote Added: 0038269
2015-03-21 06:23Stephen KellyNote Added: 0038270
2015-03-21 09:26Norbert PfeilerNote Added: 0038271
2015-03-21 09:26Norbert PfeilerFile Added: cmake_autogen_test.7z
2015-03-22 07:53Stephen KellyNote Added: 0038273
2015-03-27 15:38Brad KingNote Added: 0038353
2015-03-27 15:38Brad KingAssigned To => Brad King
2015-03-27 15:38Brad KingStatusnew => resolved
2015-03-27 15:38Brad KingResolutionopen => fixed
2015-03-27 15:38Brad KingFixed in Version => CMake 3.3
2015-03-27 15:38Brad KingTarget Version => CMake 3.3
2015-03-27 15:38Brad KingNote Added: 0038354
2015-03-27 15:39Brad KingRelationship addedrelated to 0015074
2015-04-15 20:57Norbert PfeilerNote Added: 0038528
2015-04-15 20:57Norbert PfeilerStatusresolved => feedback
2015-04-15 20:57Norbert PfeilerResolutionfixed => reopened
2015-04-16 08:25Brad KingAssigned ToBrad King =>
2015-04-16 08:25Brad KingStatusfeedback => acknowledged
2015-04-16 08:25Brad KingResolutionreopened => open
2015-04-16 08:25Brad KingFixed in VersionCMake 3.3 =>
2015-04-16 08:25Brad KingTarget VersionCMake 3.3 =>
2015-04-17 10:52Brad KingNote Added: 0038537
2015-04-17 10:52Brad KingAssigned To => Brad King
2015-04-17 10:52Brad KingStatusacknowledged => resolved
2015-04-17 10:52Brad KingResolutionopen => fixed
2015-04-17 10:52Brad KingFixed in Version => CMake 3.3
2015-04-17 10:52Brad KingTarget Version => CMake 3.3
2015-04-18 14:51Norbert PfeilerFile Added: cmake_generated_resource_test.7z
2015-04-18 14:57Norbert PfeilerNote Added: 0038540
2015-04-18 14:57Norbert PfeilerStatusresolved => feedback
2015-04-18 14:57Norbert PfeilerResolutionfixed => reopened
2015-04-20 08:37Brad KingNote Added: 0038543
2015-04-20 08:37Brad KingStatusfeedback => resolved
2015-04-20 08:37Brad KingResolutionreopened => fixed
2015-04-20 08:52Norbert PfeilerNote Added: 0038545
2015-04-20 10:00Brad KingRelationship addedrelated to 0015523
2015-11-02 09:13Robert MaynardNote Added: 0039781
2015-11-02 09:13Robert MaynardStatusresolved => closed

Notes
(0038269)
Stephen Kelly   
2015-03-21 06:21   
It works for me:

  stephen@hal:~/dev/src/playground/cmake/build{master}$ cmake .. -G Ninja
  -- The C compiler identification is GNU 4.9.1
  -- The CXX compiler identification is GNU 4.9.1
  -- Check for working C compiler using: Ninja
  -- Check for working C compiler using: Ninja -- 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 using: Ninja
  -- Check for working CXX compiler using: Ninja -- 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/stephen/dev/src/playground/cmake/build
  stephen@hal:~/dev/src/playground/cmake/build{master}$ ninja -v
  [1/5] cd /home/stephen/dev/src/playground/cmake/build && /home/stephen/dev/prefix/qtbase/kde/bin/cmake -E cmake_autogen /home/stephen/dev/src/playground/cmake/build/CMakeFiles/mn_automoc.dir/ ""
  Generating main.moc
  [2/5] /usr/lib/ccache/c++ -DQT_CORE_LIB -DQT_NETWORK_LIB -DQT_NO_DEBUG -DQT_QML_LIB -fPIE -I. -I../ -isystem /home/stephen/dev/prefix/qtbase/include -isystem /home/stephen/dev/prefix/qtbase/include/QtQml -isystem /home/stephen/dev/prefix/qtbase/include/QtNetwork -isystem /home/stephen/dev/prefix/qtbase/include/QtCore -isystem /home/stephen/dev/prefix/qtbase/mkspecs/linux-g++ -MMD -MT CMakeFiles/mn.dir/main.cpp.o -MF CMakeFiles/mn.dir/main.cpp.o.d -o CMakeFiles/mn.dir/main.cpp.o -c ../main.cpp
  [3/5]
  [4/5] /usr/lib/ccache/c++ -DQT_CORE_LIB -DQT_NETWORK_LIB -DQT_NO_DEBUG -DQT_QML_LIB -fPIE -I. -I../ -isystem /home/stephen/dev/prefix/qtbase/include -isystem /home/stephen/dev/prefix/qtbase/include/QtQml -isystem /home/stephen/dev/prefix/qtbase/include/QtNetwork -isystem /home/stephen/dev/prefix/qtbase/include/QtCore -isystem /home/stephen/dev/prefix/qtbase/mkspecs/linux-g++ -MMD -MT CMakeFiles/mn.dir/mn_automoc.cpp.o -MF CMakeFiles/mn.dir/mn_automoc.cpp.o.d -o CMakeFiles/mn.dir/mn_automoc.cpp.o -c mn_automoc.cpp
  [5/5] : && /usr/lib/ccache/c++ CMakeFiles/mn.dir/main.cpp.o CMakeFiles/mn.dir/mn_automoc.cpp.o -o mn -rdynamic /home/stephen/dev/prefix/qtbase/lib/libQt5Qml.so.5.5.0 /home/stephen/dev/prefix/qtbase/lib/libQt5Network.so.5.5.0 /home/stephen/dev/prefix/qtbase/lib/libQt5Core.so.5.5.0 -Wl,-rpath,/home/stephen/dev/prefix/qtbase/lib && :
  stephen@hal:~/dev/src/playground/cmake/build{master}$ rm main.moc
  stephen@hal:~/dev/src/playground/cmake/build{master}$ ninja -v
  [1/3] cd /home/stephen/dev/src/playground/cmake/build && /home/stephen/dev/prefix/qtbase/kde/bin/cmake -E cmake_autogen /home/stephen/dev/src/playground/cmake/build/CMakeFiles/mn_automoc.dir/ ""
  Generating main.moc
  [2/3] /usr/lib/ccache/c++ -DQT_CORE_LIB -DQT_NETWORK_LIB -DQT_NO_DEBUG -DQT_QML_LIB -fPIE -I. -I../ -isystem /home/stephen/dev/prefix/qtbase/include -isystem /home/stephen/dev/prefix/qtbase/include/QtQml -isystem /home/stephen/dev/prefix/qtbase/include/QtNetwork -isystem /home/stephen/dev/prefix/qtbase/include/QtCore -isystem /home/stephen/dev/prefix/qtbase/mkspecs/linux-g++ -MMD -MT CMakeFiles/mn.dir/main.cpp.o -MF CMakeFiles/mn.dir/main.cpp.o.d -o CMakeFiles/mn.dir/main.cpp.o -c ../main.cpp
  [3/3] : && /usr/lib/ccache/c++ CMakeFiles/mn.dir/main.cpp.o CMakeFiles/mn.dir/mn_automoc.cpp.o -o mn -rdynamic /home/stephen/dev/prefix/qtbase/lib/libQt5Qml.so.5.5.0 /home/stephen/dev/prefix/qtbase/lib/libQt5Network.so.5.5.0 /home/stephen/dev/prefix/qtbase/lib/libQt5Core.so.5.5.0 -Wl,-rpath,/home/stephen/dev/prefix/qtbase/lib && :
  stephen@hal:~/dev/src/playground/cmake/build{master}$ cat ../CMakeLists.txt

  cmake_minimum_required(VERSION 3.0)
  project(cmaketest)

  set(CMAKE_AUTOMOC ON)
  set(CMAKE_INCLUDE_CURRENT_DIR ON)
  add_executable(mn main.cpp)

  find_package(Qt5Qml REQUIRED)
  target_link_libraries(mn Qt5::Qml)
(0038270)
Stephen Kelly   
2015-03-21 06:23   
I tested with master and with `cmake version 2.8.12.2`
(0038271)
Norbert Pfeiler   
2015-03-21 09:26   
That’s because you didn’t include resources.
I took the time and uploaded a minimal test case.
(0038273)
Stephen Kelly   
2015-03-22 07:53   
Thanks, confirmed.

It works with Makefiles, but not with Ninja. I don't know enough about Ninja to know why.
(0038353)
Brad King   
2015-03-27 15:38   
This should fix it:

 QtAutogen: Fix rcc rebuild with Ninja generator
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4d08e6b6 [^]

Back when 0015074 was addressed this was not possible to implement correctly with the Ninja generator. Fortunately it is now. See commit message for details.
(0038354)
Brad King   
2015-03-27 15:38   
Re 0015459:0038353: Steve, please look at updating the test suite to cover this case.
(0038528)
Norbert Pfeiler   
2015-04-15 20:57   
The test case still doesn’t work on Windows. (the second part of the issue)

> ninja --version && cmake --version && mkdir build && cd build && cmake -G Ninja .. && ninja
1.5.3
cmake version 3.2.20150415-g8469b

CMake suite maintained and supported by Kitware (kitware.com/cmake).
-- The C compiler identification is GNU 4.9.2
-- The CXX compiler identification is GNU 4.9.2
-- Check for working C compiler using: Ninja
-- Check for working C compiler using: Ninja -- 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 using: Ninja
-- Check for working CXX compiler using: Ninja -- 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: C:/dev/cmake_autogen_test/build
ninja: error: build.ninja:108: lexing error
ident0 = ../
            ^ near here
(0038537)
Brad King   
2015-04-17 10:52   
The CRCRLF problem has been fixed and a test case added:

 QtAutogen: Workaround rcc CRCRLF newlines on Windows
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e8fdd5f1 [^]
(0038540)
Norbert Pfeiler   
2015-04-18 14:57   
I attached a new test case.
It has a resource which is generated and marked as »AUTOGEN_TARGET_DEPENDS«.
Works with make, doesn’t with ninja.
(0038543)
Brad King   
2015-04-20 08:37   
Re 0015459:0038540: Please open a separate issue for that.
(0038545)
Norbert Pfeiler   
2015-04-20 08:52   
OK, i just thought it may have to do with the fixes for this bug…
(0039781)
Robert Maynard   
2015-11-02 09:13   
Closing resolved issues that have not been updated in more than 4 months.