Regression: CMAKE_AUTOMOC_MOC_OPTIONS seems to be appended to the compiler in CMake 3.9
Currently CMake 3.9 combined with Qt 5.9 (and only this specific combination) cause compile errors in some projects, for example Apitrace or Telegram. It does work fine with previous version of CMake or previous versions of Qt.
It seems that the variable CMAKE_AUTOMOC_MOC_OPTIONS
is appended to the linker and hence causes issue:
- Gentoo issue: https://bugs.gentoo.org/634292
- Debian issue: https://bugs.debian.org/871158
- Apitrace upstream issue: https://github.com/apitrace/apitrace/issues/528
Generating MOC predefs moc_predefs.h
AutoMoc: Error: moc predefs generation command failed
AutoMoc: Command:
/usr/bin/c++ -dM -E -c /usr/share/cmake-3.9/Modules/CMakeCXXCompilerABI.cpp -I/tmp/tmp.cU62V3fLK5/src/apitrace-7.1/build/gui -I/tmp/tmp.cU62V3fLK5/src/apitrace-7.1/gui -I/tmp/tmp.cU62V3fLK5/src/apitrace-7.1/build/gui/qapitrace_autogen/include -I/tmp/tmp.cU62V3fLK5/src/apitrace-7.1/thirdparty/khronos -I/tmp/tmp.cU62V3fLK5/src/apitrace-7.1/thirdparty/snappy -I/tmp/tmp.cU62V3fLK5/src/apitrace-7.1/thirdparty/libbacktrace -I/tmp/tmp.cU62V3fLK5/src/apitrace-7.1/thirdparty/gtest/include -I/tmp/tmp.cU62V3fLK5/src/apitrace-7.1/common -I/tmp/tmp.cU62V3fLK5/src/apitrace-7.1 -I/usr/include/qt -I/usr/include/qt/QtWidgets -I/usr/include/qt/QtGui -I/usr/include/qt/QtCore -I/usr/lib/qt/mkspecs/linux-g++ -I/usr/include/qt/QtWebKitWidgets -I/usr/include/qt/QtWebKit -I/usr/include/qt/QtNetwork -I/usr/include -DHAVE_BACKTRACE=1 -DHAVE_READPROC_H -DHAVE_X11 -DQT_CORE_LIB -DQT_FORCE_ASSERTS -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_NO_DEBUG -DQT_WEBKITWIDGETS_LIB -DQT_WEBKIT_LIB -DQT_WIDGETS_LIB -D_GNU_SOURCE -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -nn
AutoMoc: Command output:
c++: error: unrecognized command line option ‘-nn’; did you mean ‘-Qn’?
The Parameter -nn
is added as a moc-only option the following way: https://github.com/apitrace/apitrace/blob/65d2605/gui/CMakeLists.txt#L74
Is this a regression in CMake or Qt?